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);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp