Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit785941c

Browse files
committed
Tweak __attribute__-wrapping macros for better pgindent results.
This improves on commitbbfd7ed bymaking two simple changes:* pg_attribute_noreturn now takes parentheses, ie pg_attribute_noreturn().Likewise pg_attribute_unused(), pg_attribute_packed(). This reducespgindent's tendency to misformat declarations involving them.* attributes are now always attached to function declarations, notdefinitions. Previously some places were taking creative shortcuts,which were not merely candidates for bad misformatting by pgindentbut often were outright wrong anyway. (It does little good to put anoreturn annotation where callers can't see it.) In any case, ifwe would like to believe that these macros can be used with non-gcccompilers, we should avoid gratuitous variance in usage patterns.I also went through and manually improved the formatting of a lot ofdeclarations, and got rid of excessively repetitive (and now obsoleteanyway) comments informing the reader what pg_attribute_printf is for.
1 parentd04c8ed commit785941c

File tree

71 files changed

+168
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+168
-356
lines changed

‎contrib/cube/cube.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ PG_MODULE_MAGIC;
2626
#defineARRPTR(x) ( (double *) ARR_DATA_PTR(x) )
2727
#defineARRNELEMS(x) ArrayGetNItems( ARR_NDIM(x), ARR_DIMS(x))
2828

29-
externintcube_yyparse(NDBOX**result);
30-
externvoidcube_yyerror(NDBOX**result,constchar*message);
31-
externvoidcube_scanner_init(constchar*str);
32-
externvoidcube_scanner_finish(void);
33-
3429
/*
3530
** Input/Output routines
3631
*/

‎contrib/cube/cubedata.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,12 @@ typedef struct NDBOX
4646
#defineDatumGetNDBOX(x)((NDBOX *) PG_DETOAST_DATUM(x))
4747
#definePG_GETARG_NDBOX(x)DatumGetNDBOX(PG_GETARG_DATUM(x))
4848
#definePG_RETURN_NDBOX(x)PG_RETURN_POINTER(x)
49+
50+
/* in cubescan.l */
51+
externintcube_yylex(void);
52+
externvoidcube_yyerror(NDBOX**result,constchar*message)pg_attribute_noreturn();
53+
externvoidcube_scanner_init(constchar*str);
54+
externvoidcube_scanner_finish(void);
55+
56+
/* in cubeparse.y */
57+
externintcube_yyparse(NDBOX**result);

‎contrib/cube/cubeparse.y

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,9 @@
2222
#defineYYMALLOC palloc
2323
#defineYYFREE pfree
2424

25-
externintcube_yylex(void);
26-
2725
staticchar *scanbuf;
2826
staticintscanbuflen;
2927

30-
externintcube_yyparse(NDBOX **result);
31-
externvoidcube_yyerror(NDBOX **result,constchar *message);
32-
3328
staticintdelim_count(char *s,char delim);
3429
static NDBOX *write_box(unsignedint dim,char *str1,char *str2);
3530
static NDBOX *write_point_as_box(char *s,int dim);

‎contrib/cube/cubescan.l

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* contrib/cube/cubescan.l
55
*/
66

7-
#include"postgres.h"
8-
97
/* No reason to constrain amount of data slurped*/
108
#defineYY_READ_BUF_SIZE16777216
119

@@ -24,12 +22,6 @@ static YY_BUFFER_STATE scanbufhandle;
2422
/* this is now declared in cubeparse.y:*/
2523
/* static char *scanbuf;*/
2624
/* static intscanbuflen;*/
27-
28-
/* flex 2.5.4 doesn't bother with a decl for this*/
29-
intcube_yylex(void);
30-
31-
voidcube_scanner_init(constchar *str);
32-
voidcube_scanner_finish(void);
3325
%}
3426

3527
%option8bit
@@ -60,7 +52,7 @@ float ({integer}|{real})([eE]{integer})?
6052

6153
%%
6254

63-
void pg_attribute_noreturn
55+
void
6456
yyerror(NDBOX **result,constchar *message)
6557
{
6658
if (*yytext == YY_END_OF_BUFFER_CHAR)

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,9 @@ voidoptionally_create_toast_tables(void);
356356
/* exec.c */
357357

358358
#defineEXEC_PSQL_ARGS "--echo-queries --set ON_ERROR_STOP=on --no-psqlrc --dbname=template1"
359-
bool
360-
exec_prog(constchar*log_file,constchar*opt_log_file,
361-
boolthrow_error,constchar*fmt,...)
362-
pg_attribute_printf(4,5);
359+
360+
boolexec_prog(constchar*log_file,constchar*opt_log_file,
361+
boolthrow_error,constchar*fmt,...)pg_attribute_printf(4,5);
363362
voidverify_directories(void);
364363
boolpid_lock_file_exists(constchar*datadir);
365364

@@ -443,9 +442,7 @@ voidinit_tablespaces(void);
443442
/* server.c */
444443

445444
PGconn*connectToServer(ClusterInfo*cluster,constchar*db_name);
446-
PGresult*
447-
executeQueryOrDie(PGconn*conn,constchar*fmt,...)
448-
pg_attribute_printf(2,3);
445+
PGresult*executeQueryOrDie(PGconn*conn,constchar*fmt,...)pg_attribute_printf(2,3);
449446

450447
char*cluster_conn_opts(ClusterInfo*cluster);
451448

@@ -460,19 +457,11 @@ voidcheck_pghost_envvar(void);
460457
char*quote_identifier(constchar*s);
461458
intget_user_info(char**user_name_p);
462459
voidcheck_ok(void);
463-
void
464-
report_status(eLogTypetype,constchar*fmt,...)
465-
pg_attribute_printf(2,3);
466-
void
467-
pg_log(eLogTypetype,constchar*fmt,...)
468-
pg_attribute_printf(2,3);
469-
void
470-
pg_fatal(constchar*fmt,...)
471-
pg_attribute_printf(1,2)pg_attribute_noreturn;
460+
voidreport_status(eLogTypetype,constchar*fmt,...)pg_attribute_printf(2,3);
461+
voidpg_log(eLogTypetype,constchar*fmt,...)pg_attribute_printf(2,3);
462+
voidpg_fatal(constchar*fmt,...)pg_attribute_printf(1,2)pg_attribute_noreturn();
472463
voidend_progress_output(void);
473-
void
474-
prep_status(constchar*fmt,...)
475-
pg_attribute_printf(1,2);
464+
voidprep_status(constchar*fmt,...)pg_attribute_printf(1,2);
476465
voidcheck_ok(void);
477466
constchar*getErrorText(interrNum);
478467
unsignedintstr2uint(constchar*str);
@@ -486,10 +475,8 @@ void new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster,
486475
voidold_9_3_check_for_line_data_type_usage(ClusterInfo*cluster);
487476

488477
/* parallel.c */
489-
void
490-
parallel_exec_prog(constchar*log_file,constchar*opt_log_file,
491-
constchar*fmt,...)
492-
pg_attribute_printf(3,4);
478+
voidparallel_exec_prog(constchar*log_file,constchar*opt_log_file,
479+
constchar*fmt,...)pg_attribute_printf(3,4);
493480
voidparallel_transfer_all_new_dbs(DbInfoArr*old_db_arr,DbInfoArr*new_db_arr,
494481
char*old_pgdata,char*new_pgdata,
495482
char*old_tablespace);

‎contrib/pg_upgrade/util.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
LogOptslog_opts;
1919

20+
staticvoidpg_log_v(eLogTypetype,constchar*fmt,va_listap)pg_attribute_printf(2,0);
21+
22+
2023
/*
2124
* report_status()
2225
*
@@ -81,9 +84,7 @@ prep_status(const char *fmt,...)
8184
}
8285

8386

84-
static
85-
pg_attribute_printf(2,0)
86-
void
87+
staticvoid
8788
pg_log_v(eLogTypetype,constchar*fmt,va_listap)
8889
{
8990
charmessage[QUERY_ALLOC];

‎contrib/pg_xlogdump/pg_xlogdump.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ typedef struct XLogDumpStats
6767
Statsrecord_stats[RM_NEXT_ID][MAX_XLINFO_TYPES];
6868
}XLogDumpStats;
6969

70-
staticvoid
71-
fatal_error(constchar*fmt,...)
72-
pg_attribute_printf(1,2);
70+
staticvoidfatal_error(constchar*fmt,...)pg_attribute_printf(1,2);
7371

7472
/*
7573
* Big red button to push when things go horribly wrong.

‎contrib/pgcrypto/px.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ voidpx_set_debug_handler(void (*handler) (const char *));
206206
voidpx_memset(void*ptr,intc,size_tlen);
207207

208208
#ifdefPX_DEBUG
209-
void
210-
px_debug(constchar*fmt,...)
211-
pg_attribute_printf(1,2);
209+
voidpx_debug(constchar*fmt,...)pg_attribute_printf(1,2);
212210
#else
213211
#definepx_debug(...)
214212
#endif

‎contrib/seg/seg.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@
2323

2424
PG_MODULE_MAGIC;
2525

26-
externintseg_yyparse(SEG*result);
27-
externvoidseg_yyerror(SEG*result,constchar*message);
28-
externvoidseg_scanner_init(constchar*str);
29-
externvoidseg_scanner_finish(void);
30-
31-
/*
32-
extern int seg_yydebug;
33-
*/
34-
3526
/*
3627
* Auxiliary data structure for picksplit method.
3728
*/
@@ -103,7 +94,6 @@ boolseg_different(SEG *a, SEG *b);
10394
** Auxiliary funxtions
10495
*/
10596
staticintrestore(char*s,floatval,intn);
106-
intsignificant_digits(char*s);
10797

10898

10999
/*****************************************************************************

‎contrib/seg/segdata.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ typedef struct SEG
1010
charl_ext;
1111
charu_ext;
1212
}SEG;
13+
14+
/* in seg.c */
15+
externintsignificant_digits(char*str);
16+
17+
/* in segscan.l */
18+
externintseg_yylex(void);
19+
externvoidseg_yyerror(SEG*result,constchar*message)pg_attribute_noreturn();
20+
externvoidseg_scanner_init(constchar*str);
21+
externvoidseg_scanner_finish(void);
22+
23+
/* in segparse.y */
24+
externintseg_yyparse(SEG*result);

‎contrib/seg/segparse.y

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include"fmgr.h"
99
#include"utils/builtins.h"
10+
1011
#include"segdata.h"
1112

1213
/*
@@ -20,13 +21,6 @@
2021
#defineYYMALLOC palloc
2122
#defineYYFREE pfree
2223

23-
externintseg_yylex(void);
24-
25-
externintsignificant_digits(char *str);/* defined in seg.c*/
26-
27-
externintseg_yyparse(SEG *result);
28-
externvoidseg_yyerror(SEG *result,constchar *message);
29-
3024
staticfloatseg_atof(char *value);
3125

3226
staticchar strbuf[25] = {

‎contrib/seg/segscan.l

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* A scanner for EMP-style numeric ranges
44
*/
55

6-
#include"postgres.h"
7-
86
/* No reason to constrain amount of data slurped*/
97
#defineYY_READ_BUF_SIZE16777216
108

@@ -22,12 +20,6 @@ fprintf_to_ereport(const char *fmt, const char *msg)
2220
static YY_BUFFER_STATE scanbufhandle;
2321
staticchar *scanbuf;
2422
staticintscanbuflen;
25-
26-
/* flex 2.5.4 doesn't bother with a decl for this*/
27-
intseg_yylex(void);
28-
29-
voidseg_scanner_init(constchar *str);
30-
voidseg_scanner_finish(void);
3123
%}
3224

3325
%option8bit
@@ -59,7 +51,7 @@ float ({integer}|{real})([eE]{integer})?
5951

6052
%%
6153

62-
void pg_attribute_noreturn
54+
void
6355
yyerror(SEG *result,constchar *message)
6456
{
6557
if (*yytext == YY_END_OF_BUFFER_CHAR)

‎src/backend/access/transam/xlogreader.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ static bool ValidXLogRecord(XLogReaderState *state, XLogRecord *record,
3232
XLogRecPtrrecptr);
3333
staticintReadPageInternal(XLogReaderState*state,XLogRecPtrpageptr,
3434
intreqLen);
35-
staticvoid
36-
report_invalid_record(XLogReaderState*state,constchar*fmt,...)
37-
/* This extension allows gcc to check the format string for consistency with
38-
the supplied arguments. */
39-
pg_attribute_printf(2,3);
35+
staticvoidreport_invalid_record(XLogReaderState*state,constchar*fmt,...)pg_attribute_printf(2,3);
4036

4137
staticvoidResetDecoder(XLogReaderState*state);
4238

‎src/backend/postmaster/autovacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ intAutovacuumLauncherPid = 0;
281281
staticpid_tavlauncher_forkexec(void);
282282
staticpid_tavworker_forkexec(void);
283283
#endif
284-
NON_EXEC_STATICvoidAutoVacWorkerMain(intargc,char*argv[])pg_attribute_noreturn;
285-
NON_EXEC_STATICvoidAutoVacLauncherMain(intargc,char*argv[])pg_attribute_noreturn;
284+
NON_EXEC_STATICvoidAutoVacWorkerMain(intargc,char*argv[])pg_attribute_noreturn();
285+
NON_EXEC_STATICvoidAutoVacLauncherMain(intargc,char*argv[])pg_attribute_noreturn();
286286

287287
staticOiddo_start_worker(void);
288288
staticvoidlauncher_determine_sleep(boolcanlaunch,boolrecursing,

‎src/backend/postmaster/pgarch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static volatile sig_atomic_t ready_to_stop = false;
8686
staticpid_tpgarch_forkexec(void);
8787
#endif
8888

89-
NON_EXEC_STATICvoidPgArchiverMain(intargc,char*argv[])pg_attribute_noreturn;
89+
NON_EXEC_STATICvoidPgArchiverMain(intargc,char*argv[])pg_attribute_noreturn();
9090
staticvoidpgarch_exit(SIGNAL_ARGS);
9191
staticvoidArchSigHupHandler(SIGNAL_ARGS);
9292
staticvoidArchSigTermHandler(SIGNAL_ARGS);

‎src/backend/postmaster/pgstat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static instr_time total_func_time;
251251
staticpid_tpgstat_forkexec(void);
252252
#endif
253253

254-
NON_EXEC_STATICvoidPgstatCollectorMain(intargc,char*argv[])pg_attribute_noreturn;
254+
NON_EXEC_STATICvoidPgstatCollectorMain(intargc,char*argv[])pg_attribute_noreturn();
255255
staticvoidpgstat_exit(SIGNAL_ARGS);
256256
staticvoidpgstat_beshutdown_hook(intcode,Datumarg);
257257
staticvoidpgstat_sighup_handler(SIGNAL_ARGS);

‎src/backend/postmaster/postmaster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ static void LogChildExit(int lev, const char *procname,
380380
intpid,intexitstatus);
381381
staticvoidPostmasterStateMachine(void);
382382
staticvoidBackendInitialize(Port*port);
383-
staticvoidBackendRun(Port*port)pg_attribute_noreturn;
384-
staticvoidExitPostmaster(intstatus)pg_attribute_noreturn;
383+
staticvoidBackendRun(Port*port)pg_attribute_noreturn();
384+
staticvoidExitPostmaster(intstatus)pg_attribute_noreturn();
385385
staticintServerLoop(void);
386386
staticintBackendStartup(Port*port);
387387
staticintProcessStartupPacket(Port*port,boolSSLdone);

‎src/backend/postmaster/syslogger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static volatile sig_atomic_t rotation_requested = false;
130130
staticpid_tsyslogger_forkexec(void);
131131
staticvoidsyslogger_parseArgs(intargc,char*argv[]);
132132
#endif
133-
NON_EXEC_STATICvoidSysLoggerMain(intargc,char*argv[])pg_attribute_noreturn;
133+
NON_EXEC_STATICvoidSysLoggerMain(intargc,char*argv[])pg_attribute_noreturn();
134134
staticvoidprocess_pipe_input(char*logbuffer,int*bytes_in_logbuffer);
135135
staticvoidflush_pipe_input(char*logbuffer,int*bytes_in_logbuffer);
136136
staticvoidopen_csvlogfile(void);

‎src/backend/replication/repl_scanner.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ addlitchar(unsigned char ychar)
205205
appendStringInfoChar(&litbuf, ychar);
206206
}
207207

208-
void pg_attribute_noreturn
208+
void
209209
yyerror(constchar *message)
210210
{
211211
ereport(ERROR,

‎src/backend/replication/walsender.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ typedef void (*WalSndSendDataCallback) (void);
193193
staticvoidWalSndLoop(WalSndSendDataCallbacksend_data);
194194
staticvoidInitWalSenderSlot(void);
195195
staticvoidWalSndKill(intcode,Datumarg);
196-
staticvoidWalSndShutdown(void)pg_attribute_noreturn;
196+
staticvoidWalSndShutdown(void)pg_attribute_noreturn();
197197
staticvoidXLogSendPhysical(void);
198198
staticvoidXLogSendLogical(void);
199199
staticvoidWalSndDone(WalSndSendDataCallbacksend_data);

‎src/backend/utils/error/elog.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@
8282
#undef _
8383
#define_(x) err_gettext(x)
8484

85-
staticconstchar*
86-
err_gettext(constchar*str)
87-
/* This extension allows gcc to check the format string for consistency with
88-
the supplied arguments. */
89-
pg_attribute_format_arg(1);
85+
staticconstchar*err_gettext(constchar*str)pg_attribute_format_arg(1);
9086
staticvoidset_errdata_field(MemoryContextData*cxt,char**ptr,constchar*str);
9187

9288
/* Global variables */

‎src/backend/utils/misc/guc.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ char *GUC_check_errmsg_string;
129129
char*GUC_check_errdetail_string;
130130
char*GUC_check_errhint_string;
131131

132-
staticvoid
133-
do_serialize(char**destptr,Size*maxbytes,constchar*fmt,...)
134-
/* This lets gcc check the format string for consistency. */
135-
pg_attribute_printf(3,4);
132+
staticvoiddo_serialize(char**destptr,Size*maxbytes,constchar*fmt,...)pg_attribute_printf(3,4);
136133

137134
staticvoidset_config_sourcefile(constchar*name,char*sourcefile,
138135
intsourceline);

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,7 @@ static pid_t postmasterPID = -1;
116116
#endif
117117

118118

119-
staticvoid
120-
write_stderr(constchar*fmt,...)
121-
/* This extension allows gcc to check the format string for consistency with
122-
the supplied arguments. */
123-
pg_attribute_printf(1,2);
119+
staticvoidwrite_stderr(constchar*fmt,...)pg_attribute_printf(1,2);
124120
staticvoiddo_advice(void);
125121
staticvoiddo_help(void);
126122
staticvoidset_mode(char*modeopt);

‎src/bin/pg_dump/parallel.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ static ShutdownInformation shutdown_info;
7878
staticconstchar*modulename=gettext_noop("parallel archiver");
7979

8080
staticParallelSlot*GetMyPSlot(ParallelState*pstate);
81-
staticvoid
82-
parallel_msg_master(ParallelSlot*slot,constchar*modulename,
83-
constchar*fmt,va_listap)
84-
pg_attribute_printf(3,0);
81+
staticvoidparallel_msg_master(ParallelSlot*slot,constchar*modulename,
82+
constchar*fmt,va_listap)pg_attribute_printf(3,0);
8583
staticvoidarchive_close_connection(intcode,void*arg);
8684
staticvoidShutdownWorkersHard(ParallelState*pstate);
8785
staticvoidWaitForTerminatingWorkers(ParallelState*pstate);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp