Skip to content

Commit a2098b6

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 macro call instead. (Even if there was some reason to prefer not to, pgindent would probably make a hash of code formatted that way; so within PG the rule should basically be "don't do it".) Thus, if we have a semi inside the macro, the compiler sees "something;;". Much of the time the extra empty statement is harmless, but it could lead to mysterious syntax errors at call sites. In perhaps an overabundance of neatnik-ism, let's run around and get rid of the excess semicolons whereever possible. The only thing worse than a mysterious syntax error is a mysterious syntax error that only happens in the back branches; therefore, backpatch these changes where relevant, which is most of them because most of these mistakes are old. (The lack of reported problems shows that this is largely a hypothetical issue, but still, it could bite us in some future patch.) John Naylor and Tom Lane Discussion: https://postgr.es/m/CACPNZCs0qWTqJ2QUSGJ07B7uvAvzMb-KbG2q+oo+J3tsWN5cqw@mail.gmail.com
1 parent 5734785 commit a2098b6

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
@@ -344,12 +344,13 @@ gbt_ts_union(PG_FUNCTION_ARGS)
344344
}
345345

346346

347-
#define penalty_check_max_float(val) do { \
347+
#define penalty_check_max_float(val) \
348+
do { \
348349
if ( val > FLT_MAX ) \
349350
val = FLT_MAX; \
350351
if ( val < -FLT_MAX ) \
351352
val = -FLT_MAX; \
352-
} while(false);
353+
} while (0)
353354

354355

355356
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
#ifdef KEEPONLYALNUM
5454
#define ISWORDCHR(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
#define BF_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
#if BF_ASM
522522

523523
extern void _BF_body_r(BF_ctx *ctx);
524524

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

529529
#define BF_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
static void

src/backend/nodes/readfuncs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,22 @@
143143
/* Read an attribute number array */
144144
#define READ_ATTRNUMBER_ARRAY(fldname, len) \
145145
token = pg_strtok(&length); /* skip :fldname */ \
146-
local_node->fldname = readAttrNumberCols(len);
146+
local_node->fldname = readAttrNumberCols(len)
147147

148148
/* Read an oid array */
149149
#define READ_OID_ARRAY(fldname, len) \
150150
token = pg_strtok(&length); /* skip :fldname */ \
151-
local_node->fldname = readOidCols(len);
151+
local_node->fldname = readOidCols(len)
152152

153153
/* Read an int array */
154154
#define READ_INT_ARRAY(fldname, len) \
155155
token = pg_strtok(&length); /* skip :fldname */ \
156-
local_node->fldname = readIntCols(len);
156+
local_node->fldname = readIntCols(len)
157157

158158
/* Read a bool array */
159159
#define READ_BOOL_ARRAY(fldname, len) \
160160
token = pg_strtok(&length); /* skip :fldname */ \
161-
local_node->fldname = readBoolCols(len);
161+
local_node->fldname = readBoolCols(len)
162162

163163
/* Routine exit */
164164
#define READ_DONE() \

src/backend/optimizer/util/pathnode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,7 +3660,7 @@ do { \
36603660
(path) = reparameterize_path_by_child(root, (path), child_rel); \
36613661
if ((path) == NULL) \
36623662
return NULL; \
3663-
} while(0);
3663+
} while(0)
36643664

36653665
#define REPARAMETERIZE_CHILD_PATH_LIST(pathlist) \
36663666
do { \
@@ -3671,7 +3671,7 @@ do { \
36713671
if ((pathlist) == NIL) \
36723672
return NULL; \
36733673
} \
3674-
} while(0);
3674+
} while(0)
36753675

36763676
Path *new_path;
36773677
ParamPathInfo *new_ppi;

src/backend/utils/adt/formatting.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ typedef struct
424424
(_X)->mode, (_X)->hh, (_X)->pm, (_X)->mi, (_X)->ss, (_X)->ssss, \
425425
(_X)->d, (_X)->dd, (_X)->ddd, (_X)->mm, (_X)->ms, (_X)->year, \
426426
(_X)->bc, (_X)->ww, (_X)->w, (_X)->cc, (_X)->j, (_X)->us, \
427-
(_X)->yysz, (_X)->clock);
427+
(_X)->yysz, (_X)->clock)
428428
#define DEBUG_TM(_X) \
429429
elog(DEBUG_elog_output, "TM:\nsec %d\nyear %d\nmin %d\nwday %d\nhour %d\nyday %d\nmday %d\nnisdst %d\nmon %d\n",\
430430
(_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
@@ -99,7 +99,7 @@ typedef z_stream *z_streamp;
9999
#define K_VERS_MAJOR 1
100100
#define K_VERS_MINOR 13
101101
#define K_VERS_REV 0
102-
#define K_VERS_SELF MAKE_ARCHIVE_VERSION(K_VERS_MAJOR, K_VERS_MINOR, K_VERS_REV);
102+
#define K_VERS_SELF MAKE_ARCHIVE_VERSION(K_VERS_MAJOR, K_VERS_MINOR, K_VERS_REV)
103103

104104
/* Newest format we can read */
105105
#define K_VERS_MAX MAKE_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
@@ -158,7 +158,7 @@ typedef struct HashScanPosData
158158
(scanpos).firstItem = 0; \
159159
(scanpos).lastItem = 0; \
160160
(scanpos).itemIndex = 0; \
161-
} while (0);
161+
} while (0)
162162

163163
/*
164164
* HashScanOpaqueData is private state for a hash index scan.

0 commit comments

Comments
 (0)