Skip to content

Commit 0da06d9

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 d669354 commit 0da06d9

File tree

13 files changed

+28
-23
lines changed

13 files changed

+28
-23
lines changed

contrib/btree_gist/btree_ts.c

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

343343

344-
#define penalty_check_max_float(val) do { \
344+
#define penalty_check_max_float(val) \
345+
do { \
345346
if ( val > FLT_MAX ) \
346347
val = FLT_MAX; \
347348
if ( val < -FLT_MAX ) \
348349
val = -FLT_MAX; \
349-
} while(false);
350+
} while (0)
350351

351352

352353
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
@@ -154,22 +154,22 @@
154154
/* Read an attribute number array */
155155
#define READ_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
#define READ_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
#define READ_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
#define READ_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
#define READ_DONE() \

src/backend/optimizer/util/pathnode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3859,7 +3859,7 @@ do { \
38593859
(path) = reparameterize_path_by_child(root, (path), child_rel); \
38603860
if ((path) == NULL) \
38613861
return NULL; \
3862-
} while(0);
3862+
} while(0)
38633863

38643864
#define REPARAMETERIZE_CHILD_PATH_LIST(pathlist) \
38653865
do { \
@@ -3870,7 +3870,7 @@ do { \
38703870
if ((pathlist) == NIL) \
38713871
return NULL; \
38723872
} \
3873-
} while(0);
3873+
} while(0)
38743874

38753875
Path *new_path;
38763876
ParamPathInfo *new_ppi;

src/backend/utils/adt/formatting.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ typedef struct
479479
(_X)->mode, (_X)->hh, (_X)->pm, (_X)->mi, (_X)->ss, (_X)->ssss, \
480480
(_X)->d, (_X)->dd, (_X)->ddd, (_X)->mm, (_X)->ms, (_X)->year, \
481481
(_X)->bc, (_X)->ww, (_X)->w, (_X)->cc, (_X)->j, (_X)->us, \
482-
(_X)->yysz, (_X)->clock);
482+
(_X)->yysz, (_X)->clock)
483483
#define DEBUG_TM(_X) \
484484
elog(DEBUG_elog_output, "TM:\nsec %d\nyear %d\nmin %d\nwday %d\nhour %d\nyday %d\nmday %d\nnisdst %d\nmon %d\n",\
485485
(_X)->tm_sec, (_X)->tm_year,\
@@ -2731,11 +2731,13 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col
27312731
str_numth(s, s, S_TH_TYPE(n->suffix));
27322732
s += strlen(s);
27332733
break;
2734+
27342735
#define DCH_to_char_fsec(frac_fmt, frac_val) \
27352736
sprintf(s, frac_fmt, (int) (frac_val)); \
27362737
if (S_THth(n->suffix)) \
27372738
str_numth(s, s, S_TH_TYPE(n->suffix)); \
2738-
s += strlen(s);
2739+
s += strlen(s)
2740+
27392741
case DCH_FF1: /* tenth of second */
27402742
DCH_to_char_fsec("%01d", in->fsec / 100000);
27412743
break;

src/backend/utils/sort/gen_qsort_tuple.pl

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

src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ typedef z_stream *z_streamp;
9898
#define K_VERS_MAJOR 1
9999
#define K_VERS_MINOR 14
100100
#define K_VERS_REV 0
101-
#define K_VERS_SELF MAKE_ARCHIVE_VERSION(K_VERS_MAJOR, K_VERS_MINOR, K_VERS_REV);
101+
#define K_VERS_SELF MAKE_ARCHIVE_VERSION(K_VERS_MAJOR, K_VERS_MINOR, K_VERS_REV)
102102

103103
/* Newest format we can read */
104104
#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
@@ -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.

src/include/access/nbtree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ typedef BTScanPosData *BTScanPos;
888888
(scanpos).buf = InvalidBuffer; \
889889
(scanpos).lsn = InvalidXLogRecPtr; \
890890
(scanpos).nextTupleOffset = 0; \
891-
} while (0);
891+
} while (0)
892892

893893
/* We need one of these for each equality-type SK_SEARCHARRAY scan key */
894894
typedef struct BTArrayKeyInfo

src/port/qsort.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ do { \
8080
} while (0)
8181

8282
#define SWAPINIT(a, es) swaptype = ((char *)(a) - (char *)0) % sizeof(long) || \
83-
(es) % sizeof(long) ? 2 : (es) == sizeof(long)? 0 : 1;
83+
(es) % sizeof(long) ? 2 : (es) == sizeof(long)? 0 : 1
8484

8585
static void
8686
swapfunc(char *a, char *b, size_t n, int swaptype)

src/port/qsort_arg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ do { \
8080
} while (0)
8181

8282
#define SWAPINIT(a, es) swaptype = ((char *)(a) - (char *)0) % sizeof(long) || \
83-
(es) % sizeof(long) ? 2 : (es) == sizeof(long)? 0 : 1;
83+
(es) % sizeof(long) ? 2 : (es) == sizeof(long)? 0 : 1
8484

8585
static void
8686
swapfunc(char *a, char *b, size_t n, int swaptype)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy