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

Commitc08da32

Browse files
committed
Get rid of trailing semicolons in C macro definitions.
Writing a trailing semicolon in a macro is almost never the right thing,because you almost always want to write a semicolon after each macrocall instead. (Even if there was some reason to prefer not to, pgindentwould probably make a hash of code formatted that way; so within PG therule should basically be "don't do it".) Thus, if we have a semi insidethe macro, the compiler sees "something;;". Much of the time the extraempty statement is harmless, but it could lead to mysterious syntaxerrors at call sites. In perhaps an overabundance of neatnik-ism, let'srun around and get rid of the excess semicolons whereever possible.The only thing worse than a mysterious syntax error is a mysterioussyntax error that only happens in the back branches; therefore,backpatch these changes where relevant, which is most of them becausemost of these mistakes are old. (The lack of reported problems showsthat this is largely a hypothetical issue, but still, it could biteus in some future patch.)John Naylor and Tom LaneDiscussion:https://postgr.es/m/CACPNZCs0qWTqJ2QUSGJ07B7uvAvzMb-KbG2q+oo+J3tsWN5cqw@mail.gmail.com
1 parente1477db commitc08da32

File tree

13 files changed

+25
-22
lines changed

13 files changed

+25
-22
lines changed

‎contrib/btree_gist/btree_ts.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,13 @@ gbt_ts_union(PG_FUNCTION_ARGS)
345345
}
346346

347347

348-
#definepenalty_check_max_float(val) do { \
348+
#definepenalty_check_max_float(val) \
349+
do { \
349350
if ( val > FLT_MAX ) \
350351
val = FLT_MAX; \
351352
if ( val < -FLT_MAX ) \
352353
val = -FLT_MAX; \
353-
} while(false);
354+
} while (0)
354355

355356

356357
Datum

‎contrib/btree_gist/btree_utils_num.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ typedef struct
7474
(*(result)) += (float) ( ((double)(tmp)) / ( (double)(tmp) + ( ((double)(oupper))*0.49F - ((double)(olower))*0.49F ) ) ); \
7575
(*(result)) *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1)); \
7676
} \
77-
} while (0);
77+
} while (0)
7878

7979

8080
/*

‎contrib/pg_trgm/trgm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef char trgm[3];
4848
*(((char*)(a))+0) = *(((char*)(b))+0);\
4949
*(((char*)(a))+1) = *(((char*)(b))+1);\
5050
*(((char*)(a))+2) = *(((char*)(b))+2);\
51-
} while(0);
51+
} while(0)
5252

5353
#ifdefKEEPONLYALNUM
5454
#defineISWORDCHR(c)(t_isalpha(c) || t_isdigit(c))

‎contrib/pgcrypto/crypt-blowfish.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ BF_swap(BF_word *x, int count)
469469
tmp3 ^= tmp2; \
470470
(R) ^= data.ctx.P[(N) + 1]; \
471471
tmp3 += tmp1; \
472-
(R) ^= tmp3;
472+
(R) ^= tmp3
473473
#else
474474
/* Architectures with no complicated addressing modes supported */
475475
#defineBF_INDEX(S,i) \
@@ -490,7 +490,7 @@ BF_swap(BF_word *x, int count)
490490
tmp3 ^= tmp2; \
491491
(R) ^= data.ctx.P[(N) + 1]; \
492492
tmp3 += tmp1; \
493-
(R) ^= tmp3;
493+
(R) ^= tmp3
494494
#endif
495495

496496
/*
@@ -516,17 +516,18 @@ BF_swap(BF_word *x, int count)
516516
BF_ROUND(R, L, 15); \
517517
tmp4 = R; \
518518
R = L; \
519-
L = tmp4 ^ data.ctx.P[BF_N + 1];
519+
L = tmp4 ^ data.ctx.P[BF_N + 1]
520520

521521
#ifBF_ASM
522522

523523
externvoid_BF_body_r(BF_ctx*ctx);
524524

525525
#defineBF_body() \
526-
_BF_body_r(&data.ctx);
526+
_BF_body_r(&data.ctx)
527527
#else
528528

529529
#defineBF_body() \
530+
do { \
530531
L = R = 0; \
531532
ptr = data.ctx.P; \
532533
do { \
@@ -542,7 +543,8 @@ extern void _BF_body_r(BF_ctx *ctx);
542543
BF_ENCRYPT; \
543544
*(ptr - 2) = L; \
544545
*(ptr - 1) = R; \
545-
} while (ptr < &data.ctx.S[3][0xFF]);
546+
} while (ptr < &data.ctx.S[3][0xFF]); \
547+
} while (0)
546548
#endif
547549

548550
staticvoid

‎src/backend/nodes/readfuncs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,22 +154,22 @@
154154
/* Read an attribute number array */
155155
#defineREAD_ATTRNUMBER_ARRAY(fldname,len) \
156156
token = pg_strtok(&length);/* skip :fldname */ \
157-
local_node->fldname=readAttrNumberCols(len);
157+
local_node->fldname=readAttrNumberCols(len)
158158

159159
/* Read an oid array */
160160
#defineREAD_OID_ARRAY(fldname,len) \
161161
token = pg_strtok(&length);/* skip :fldname */ \
162-
local_node->fldname=readOidCols(len);
162+
local_node->fldname=readOidCols(len)
163163

164164
/* Read an int array */
165165
#defineREAD_INT_ARRAY(fldname,len) \
166166
token = pg_strtok(&length);/* skip :fldname */ \
167-
local_node->fldname=readIntCols(len);
167+
local_node->fldname=readIntCols(len)
168168

169169
/* Read a bool array */
170170
#defineREAD_BOOL_ARRAY(fldname,len) \
171171
token = pg_strtok(&length);/* skip :fldname */ \
172-
local_node->fldname=readBoolCols(len);
172+
local_node->fldname=readBoolCols(len)
173173

174174
/* Routine exit */
175175
#defineREAD_DONE() \

‎src/backend/optimizer/util/pathnode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,7 +3825,7 @@ do { \
38253825
(path) = reparameterize_path_by_child(root, (path), child_rel); \
38263826
if ((path) == NULL) \
38273827
return NULL; \
3828-
} while(0);
3828+
} while(0)
38293829

38303830
#defineREPARAMETERIZE_CHILD_PATH_LIST(pathlist) \
38313831
do { \
@@ -3836,7 +3836,7 @@ do { \
38363836
if ((pathlist) == NIL) \
38373837
return NULL; \
38383838
} \
3839-
} while(0);
3839+
} while(0)
38403840

38413841
Path*new_path;
38423842
ParamPathInfo*new_ppi;

‎src/backend/utils/adt/formatting.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ typedef struct
440440
(_X)->mode, (_X)->hh, (_X)->pm, (_X)->mi, (_X)->ss, (_X)->ssss, \
441441
(_X)->d, (_X)->dd, (_X)->ddd, (_X)->mm, (_X)->ms, (_X)->year, \
442442
(_X)->bc, (_X)->ww, (_X)->w, (_X)->cc, (_X)->j, (_X)->us, \
443-
(_X)->yysz, (_X)->clock);
443+
(_X)->yysz, (_X)->clock)
444444
#defineDEBUG_TM(_X) \
445445
elog(DEBUG_elog_output, "TM:\nsec %d\nyear %d\nmin %d\nwday %d\nhour %d\nyday %d\nmday %d\nnisdst %d\nmon %d\n",\
446446
(_X)->tm_sec, (_X)->tm_year,\

‎src/backend/utils/sort/gen_qsort_tuple.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ sub emit_qsort_boilerplate
125125
SortTuple t = *(a);\
126126
*(a) = *(b);\
127127
*(b) = t;\
128-
} while (0);
128+
} while (0)
129129
130130
#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n)
131131

‎src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ typedef z_stream *z_streamp;
100100
#defineK_VERS_MAJOR 1
101101
#defineK_VERS_MINOR 14
102102
#defineK_VERS_REV 0
103-
#defineK_VERS_SELF MAKE_ARCHIVE_VERSION(K_VERS_MAJOR, K_VERS_MINOR, K_VERS_REV);
103+
#defineK_VERS_SELF MAKE_ARCHIVE_VERSION(K_VERS_MAJOR, K_VERS_MINOR, K_VERS_REV)
104104

105105
/* Newest format we can read */
106106
#defineK_VERS_MAXMAKE_ARCHIVE_VERSION(K_VERS_MAJOR, K_VERS_MINOR, 255)

‎src/include/access/hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ typedef struct HashScanPosData
148148
(scanpos).firstItem = 0; \
149149
(scanpos).lastItem = 0; \
150150
(scanpos).itemIndex = 0; \
151-
} while (0);
151+
} while (0)
152152

153153
/*
154154
*HashScanOpaqueData is private state for a hash index scan.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp