mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Tweak __attribute__-wrapping macros for better pgindent results.
This improves on commit bbfd7edae5
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.
This commit is contained in:
@ -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
|
||||
*/
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -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);
|
||||
|
@ -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] = {
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user