summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorTom Lane2015-03-26 18:03:19 +0000
committerTom Lane2015-03-26 18:03:25 +0000
commit785941cdc359c6e595201ffb0df9d28f3f7173a4 (patch)
treef1cb5a309c53bf1b9112bc51e99c94bfa55f77c7 /contrib
parentd04c8ed9044eccebce043143a930617e3998c005 (diff)
Tweak __attribute__-wrapping macros for better pgindent results.
This improves on commit bbfd7edae5aa5ad5553d3c7e102f2e450d4380d4 by making two simple changes: * pg_attribute_noreturn now takes parentheses, ie pg_attribute_noreturn(). Likewise pg_attribute_unused(), pg_attribute_packed(). This reduces pgindent's tendency to misformat declarations involving them. * attributes are now always attached to function declarations, not definitions. Previously some places were taking creative shortcuts, which were not merely candidates for bad misformatting by pgindent but often were outright wrong anyway. (It does little good to put a noreturn annotation where callers can't see it.) In any case, if we would like to believe that these macros can be used with non-gcc compilers, we should avoid gratuitous variance in usage patterns. I also went through and manually improved the formatting of a lot of declarations, and got rid of excessively repetitive (and now obsolete anyway) comments informing the reader what pg_attribute_printf is for.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/cube/cube.c5
-rw-r--r--contrib/cube/cubedata.h9
-rw-r--r--contrib/cube/cubeparse.y5
-rw-r--r--contrib/cube/cubescan.l10
-rw-r--r--contrib/pg_upgrade/pg_upgrade.h33
-rw-r--r--contrib/pg_upgrade/util.c7
-rw-r--r--contrib/pg_xlogdump/pg_xlogdump.c4
-rw-r--r--contrib/pgcrypto/px.h4
-rw-r--r--contrib/seg/seg.c10
-rw-r--r--contrib/seg/segdata.h12
-rw-r--r--contrib/seg/segparse.y8
-rw-r--r--contrib/seg/segscan.l10
12 files changed, 40 insertions, 77 deletions
diff --git a/contrib/cube/cube.c b/contrib/cube/cube.c
index b0305ef431d..b9ccad994a8 100644
--- a/contrib/cube/cube.c
+++ b/contrib/cube/cube.c
@@ -26,11 +26,6 @@ PG_MODULE_MAGIC;
#define ARRPTR(x) ( (double *) ARR_DATA_PTR(x) )
#define ARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
-extern int cube_yyparse(NDBOX **result);
-extern void cube_yyerror(NDBOX **result, const char *message);
-extern void cube_scanner_init(const char *str);
-extern void cube_scanner_finish(void);
-
/*
** Input/Output routines
*/
diff --git a/contrib/cube/cubedata.h b/contrib/cube/cubedata.h
index 719e43d421c..59c23ded6ac 100644
--- a/contrib/cube/cubedata.h
+++ b/contrib/cube/cubedata.h
@@ -46,3 +46,12 @@ typedef struct NDBOX
#define DatumGetNDBOX(x) ((NDBOX *) PG_DETOAST_DATUM(x))
#define PG_GETARG_NDBOX(x) DatumGetNDBOX(PG_GETARG_DATUM(x))
#define PG_RETURN_NDBOX(x) PG_RETURN_POINTER(x)
+
+/* in cubescan.l */
+extern int cube_yylex(void);
+extern void cube_yyerror(NDBOX **result, const char *message) pg_attribute_noreturn();
+extern void cube_scanner_init(const char *str);
+extern void cube_scanner_finish(void);
+
+/* in cubeparse.y */
+extern int cube_yyparse(NDBOX **result);
diff --git a/contrib/cube/cubeparse.y b/contrib/cube/cubeparse.y
index 0baee8e1324..33606c741c5 100644
--- a/contrib/cube/cubeparse.y
+++ b/contrib/cube/cubeparse.y
@@ -22,14 +22,9 @@
#define YYMALLOC palloc
#define YYFREE pfree
-extern int cube_yylex(void);
-
static char *scanbuf;
static int scanbuflen;
-extern int cube_yyparse(NDBOX **result);
-extern void cube_yyerror(NDBOX **result, const char *message);
-
static int delim_count(char *s, char delim);
static NDBOX * write_box(unsigned int dim, char *str1, char *str2);
static NDBOX * write_point_as_box(char *s, int dim);
diff --git a/contrib/cube/cubescan.l b/contrib/cube/cubescan.l
index 1c2522a2398..4408e28387e 100644
--- a/contrib/cube/cubescan.l
+++ b/contrib/cube/cubescan.l
@@ -4,8 +4,6 @@
* contrib/cube/cubescan.l
*/
-#include "postgres.h"
-
/* No reason to constrain amount of data slurped */
#define YY_READ_BUF_SIZE 16777216
@@ -24,12 +22,6 @@ static YY_BUFFER_STATE scanbufhandle;
/* this is now declared in cubeparse.y: */
/* static char *scanbuf; */
/* static int scanbuflen; */
-
-/* flex 2.5.4 doesn't bother with a decl for this */
-int cube_yylex(void);
-
-void cube_scanner_init(const char *str);
-void cube_scanner_finish(void);
%}
%option 8bit
@@ -60,7 +52,7 @@ float ({integer}|{real})([eE]{integer})?
%%
-void pg_attribute_noreturn
+void
yyerror(NDBOX **result, const char *message)
{
if (*yytext == YY_END_OF_BUFFER_CHAR)
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
index 9b873adbc08..f6b13c08786 100644
--- a/contrib/pg_upgrade/pg_upgrade.h
+++ b/contrib/pg_upgrade/pg_upgrade.h
@@ -356,10 +356,9 @@ void optionally_create_toast_tables(void);
/* exec.c */
#define EXEC_PSQL_ARGS "--echo-queries --set ON_ERROR_STOP=on --no-psqlrc --dbname=template1"
-bool
-exec_prog(const char *log_file, const char *opt_log_file,
- bool throw_error, const char *fmt,...)
-pg_attribute_printf(4, 5);
+
+bool exec_prog(const char *log_file, const char *opt_log_file,
+ bool throw_error, const char *fmt,...) pg_attribute_printf(4, 5);
void verify_directories(void);
bool pid_lock_file_exists(const char *datadir);
@@ -443,9 +442,7 @@ void init_tablespaces(void);
/* server.c */
PGconn *connectToServer(ClusterInfo *cluster, const char *db_name);
-PGresult *
-executeQueryOrDie(PGconn *conn, const char *fmt,...)
-pg_attribute_printf(2, 3);
+PGresult *executeQueryOrDie(PGconn *conn, const char *fmt,...) pg_attribute_printf(2, 3);
char *cluster_conn_opts(ClusterInfo *cluster);
@@ -460,19 +457,11 @@ void check_pghost_envvar(void);
char *quote_identifier(const char *s);
int get_user_info(char **user_name_p);
void check_ok(void);
-void
-report_status(eLogType type, const char *fmt,...)
-pg_attribute_printf(2, 3);
-void
-pg_log(eLogType type, const char *fmt,...)
-pg_attribute_printf(2, 3);
-void
-pg_fatal(const char *fmt,...)
-pg_attribute_printf(1, 2) pg_attribute_noreturn;
+void report_status(eLogType type, const char *fmt,...) pg_attribute_printf(2, 3);
+void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2, 3);
+void pg_fatal(const char *fmt,...) pg_attribute_printf(1, 2) pg_attribute_noreturn();
void end_progress_output(void);
-void
-prep_status(const char *fmt,...)
-pg_attribute_printf(1, 2);
+void prep_status(const char *fmt,...) pg_attribute_printf(1, 2);
void check_ok(void);
const char *getErrorText(int errNum);
unsigned int str2uint(const char *str);
@@ -486,10 +475,8 @@ void new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster,
void old_9_3_check_for_line_data_type_usage(ClusterInfo *cluster);
/* parallel.c */
-void
-parallel_exec_prog(const char *log_file, const char *opt_log_file,
- const char *fmt,...)
-pg_attribute_printf(3, 4);
+void parallel_exec_prog(const char *log_file, const char *opt_log_file,
+ const char *fmt,...) pg_attribute_printf(3, 4);
void parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
char *old_pgdata, char *new_pgdata,
char *old_tablespace);
diff --git a/contrib/pg_upgrade/util.c b/contrib/pg_upgrade/util.c
index ce17aa0d476..6184ceef933 100644
--- a/contrib/pg_upgrade/util.c
+++ b/contrib/pg_upgrade/util.c
@@ -17,6 +17,9 @@
LogOpts log_opts;
+static void pg_log_v(eLogType type, const char *fmt, va_list ap) pg_attribute_printf(2, 0);
+
+
/*
* report_status()
*
@@ -81,9 +84,7 @@ prep_status(const char *fmt,...)
}
-static
-pg_attribute_printf(2, 0)
-void
+static void
pg_log_v(eLogType type, const char *fmt, va_list ap)
{
char message[QUERY_ALLOC];
diff --git a/contrib/pg_xlogdump/pg_xlogdump.c b/contrib/pg_xlogdump/pg_xlogdump.c
index 15805be2940..4f297e95720 100644
--- a/contrib/pg_xlogdump/pg_xlogdump.c
+++ b/contrib/pg_xlogdump/pg_xlogdump.c
@@ -67,9 +67,7 @@ typedef struct XLogDumpStats
Stats record_stats[RM_NEXT_ID][MAX_XLINFO_TYPES];
} XLogDumpStats;
-static void
-fatal_error(const char *fmt,...)
-pg_attribute_printf(1, 2);
+static void fatal_error(const char *fmt,...) pg_attribute_printf(1, 2);
/*
* Big red button to push when things go horribly wrong.
diff --git a/contrib/pgcrypto/px.h b/contrib/pgcrypto/px.h
index 297747c60a3..7255ebf04c8 100644
--- a/contrib/pgcrypto/px.h
+++ b/contrib/pgcrypto/px.h
@@ -206,9 +206,7 @@ void px_set_debug_handler(void (*handler) (const char *));
void px_memset(void *ptr, int c, size_t len);
#ifdef PX_DEBUG
-void
-px_debug(const char *fmt,...)
-pg_attribute_printf(1, 2);
+void px_debug(const char *fmt,...) pg_attribute_printf(1, 2);
#else
#define px_debug(...)
#endif
diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c
index 0807e238f16..8e2d5343ae9 100644
--- a/contrib/seg/seg.c
+++ b/contrib/seg/seg.c
@@ -23,15 +23,6 @@
PG_MODULE_MAGIC;
-extern int seg_yyparse(SEG *result);
-extern void seg_yyerror(SEG *result, const char *message);
-extern void seg_scanner_init(const char *str);
-extern void seg_scanner_finish(void);
-
-/*
-extern int seg_yydebug;
-*/
-
/*
* Auxiliary data structure for picksplit method.
*/
@@ -103,7 +94,6 @@ bool seg_different(SEG *a, SEG *b);
** Auxiliary funxtions
*/
static int restore(char *s, float val, int n);
-int significant_digits(char *s);
/*****************************************************************************
diff --git a/contrib/seg/segdata.h b/contrib/seg/segdata.h
index 90be6e27aaf..cac68ee2b2e 100644
--- a/contrib/seg/segdata.h
+++ b/contrib/seg/segdata.h
@@ -10,3 +10,15 @@ typedef struct SEG
char l_ext;
char u_ext;
} SEG;
+
+/* in seg.c */
+extern int significant_digits(char *str);
+
+/* in segscan.l */
+extern int seg_yylex(void);
+extern void seg_yyerror(SEG *result, const char *message) pg_attribute_noreturn();
+extern void seg_scanner_init(const char *str);
+extern void seg_scanner_finish(void);
+
+/* in segparse.y */
+extern int seg_yyparse(SEG *result);
diff --git a/contrib/seg/segparse.y b/contrib/seg/segparse.y
index 3fad9910bd5..045ff91f3e7 100644
--- a/contrib/seg/segparse.y
+++ b/contrib/seg/segparse.y
@@ -7,6 +7,7 @@
#include "fmgr.h"
#include "utils/builtins.h"
+
#include "segdata.h"
/*
@@ -20,13 +21,6 @@
#define YYMALLOC palloc
#define YYFREE pfree
-extern int seg_yylex(void);
-
-extern int significant_digits(char *str); /* defined in seg.c */
-
-extern int seg_yyparse(SEG *result);
-extern void seg_yyerror(SEG *result, const char *message);
-
static float seg_atof(char *value);
static char strbuf[25] = {
diff --git a/contrib/seg/segscan.l b/contrib/seg/segscan.l
index 5fe4a2c4537..6db24fdd1f7 100644
--- a/contrib/seg/segscan.l
+++ b/contrib/seg/segscan.l
@@ -3,8 +3,6 @@
* A scanner for EMP-style numeric ranges
*/
-#include "postgres.h"
-
/* No reason to constrain amount of data slurped */
#define YY_READ_BUF_SIZE 16777216
@@ -22,12 +20,6 @@ fprintf_to_ereport(const char *fmt, const char *msg)
static YY_BUFFER_STATE scanbufhandle;
static char *scanbuf;
static int scanbuflen;
-
-/* flex 2.5.4 doesn't bother with a decl for this */
-int seg_yylex(void);
-
-void seg_scanner_init(const char *str);
-void seg_scanner_finish(void);
%}
%option 8bit
@@ -59,7 +51,7 @@ float ({integer}|{real})([eE]{integer})?
%%
-void pg_attribute_noreturn
+void
yyerror(SEG *result, const char *message)
{
if (*yytext == YY_END_OF_BUFFER_CHAR)