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

Commit27db9ec

Browse files
committed
Fix macros that were not properly surrounded by parens or braces.
1 parent3af536a commit27db9ec

File tree

29 files changed

+462
-379
lines changed

29 files changed

+462
-379
lines changed

‎src/backend/access/common/scankey.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.11 1998/01/1519:41:46 pgsql Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/common/scankey.c,v 1.12 1998/06/1518:39:22 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -22,8 +22,10 @@
2222
*True iff the scan key entry is legal.
2323
*/
2424
#defineScanKeyEntryIsLegal(entry) \
25-
((bool) (AssertMacro(PointerIsValid(entry)) && \
26-
AttributeNumberIsValid(entry->sk_attno)))
25+
( \
26+
AssertMacro(PointerIsValid(entry)), \
27+
AttributeNumberIsValid((entry)->sk_attno) \
28+
)
2729

2830
/*
2931
* ScanKeyEntrySetIllegal --

‎src/backend/access/index/indexam.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.21 1998/02/26 12:07:10 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.22 1998/06/15 18:39:23 momjian Exp $
1111
*
1212
* INTERFACE ROUTINES
1313
*index_open- open an index relation by relationId
@@ -92,25 +92,35 @@
9292
* ----------------------------------------------------------------
9393
*/
9494
#defineRELATION_CHECKS \
95-
Assert(RelationIsValid(relation)); \
96-
Assert(PointerIsValid(relation->rd_am))
95+
( \
96+
AssertMacro(RelationIsValid(relation)), \
97+
AssertMacro(PointerIsValid(relation->rd_am)) \
98+
)
9799

98100
#defineSCAN_CHECKS \
99-
Assert(IndexScanIsValid(scan)); \
100-
Assert(RelationIsValid(scan->relation)); \
101-
Assert(PointerIsValid(scan->relation->rd_am))
101+
( \
102+
AssertMacro(IndexScanIsValid(scan)), \
103+
AssertMacro(RelationIsValid(scan->relation)), \
104+
AssertMacro(PointerIsValid(scan->relation->rd_am)) \
105+
)
102106

103107
#defineGET_REL_PROCEDURE(x,y) \
104-
procedure = relation->rd_am->y; \
105-
if (! RegProcedureIsValid(procedure)) \
106-
elog(ERROR, "index_%s: invalid %s regproc", \
107-
CppAsString(x), CppAsString(y))
108-
108+
( \
109+
procedure = relation->rd_am->y, \
110+
(!RegProcedureIsValid(procedure)) ? \
111+
elog(ERROR, "index_%s: invalid %s regproc", \
112+
CppAsString(x), CppAsString(y)) \
113+
: (void)NULL \
114+
)
115+
109116
#defineGET_SCAN_PROCEDURE(x,y) \
110-
procedure = scan->relation->rd_am->y; \
111-
if (! RegProcedureIsValid(procedure)) \
112-
elog(ERROR, "index_%s: invalid %s regproc", \
113-
CppAsString(x), CppAsString(y))
117+
( \
118+
procedure = scan->relation->rd_am->y, \
119+
(!RegProcedureIsValid(procedure)) ? \
120+
elog(ERROR, "index_%s: invalid %s regproc", \
121+
CppAsString(x), CppAsString(y)) \
122+
: (void)NULL \
123+
)
114124

115125

116126
/* ----------------------------------------------------------------

‎src/backend/executor/nodeMergejoin.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.14 1998/02/27 16:11:28 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.15 1998/06/15 18:39:24 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -88,12 +88,12 @@
8888
staticboolMergeCompare(List*eqQual,List*compareQual,ExprContext*econtext);
8989

9090
#defineMarkInnerTuple(innerTupleSlot,mergestate) \
91-
{ \
92-
ExecStoreTuple(heap_copytuple(innerTupleSlot->val), \
93-
mergestate->mj_MarkedTupleSlot, \
91+
( \
92+
ExecStoreTuple(heap_copytuple((innerTupleSlot)->val), \
93+
(mergestate)->mj_MarkedTupleSlot, \
9494
InvalidBuffer, \
95-
true); \
96-
}
95+
true) \
96+
)
9797

9898
/* ----------------------------------------------------------------
9999
*MJFormOSortopI

‎src/backend/optimizer/path/xfunc.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.13 1998/02/26 04:32:44 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.14 1998/06/15 18:39:26 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -1424,9 +1424,12 @@ xfunc_LispRemove(LispValue foo, List bar)
14241424
}
14251425

14261426
#defineNode_Copy(a,b,c,d) \
1427-
if (NodeCopy((Node)((a)->d), (Node*)&((b)->d), c) != true) { \
1428-
return false; \
1429-
}
1427+
do { \
1428+
if (NodeCopy((Node)((a)->d), (Node*)&((b)->d), c) != true) \
1429+
{ \
1430+
return false; \
1431+
} \
1432+
} while(0)
14301433

14311434
/*
14321435
** xfunc_copyrel --

‎src/backend/storage/buffer/freelist.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.9 1998/01/07 21:04:52 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.10 1998/06/15 18:39:28 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -40,14 +40,18 @@ static BufferDesc *SharedFreeList;
4040
externSPINLOCKBufMgrLock;
4141

4242
#defineIsInQueue(bf) \
43-
Assert((bf->freeNext != INVALID_DESCRIPTOR));\
44-
Assert((bf->freePrev != INVALID_DESCRIPTOR));\
45-
Assert((bf->flags & BM_FREE))
43+
( \
44+
AssertMacro((bf->freeNext != INVALID_DESCRIPTOR)), \
45+
AssertMacro((bf->freePrev != INVALID_DESCRIPTOR)), \
46+
AssertMacro((bf->flags & BM_FREE)) \
47+
)
4648

4749
#defineNotInQueue(bf) \
48-
Assert((bf->freeNext == INVALID_DESCRIPTOR));\
49-
Assert((bf->freePrev == INVALID_DESCRIPTOR));\
50-
Assert(! (bf->flags & BM_FREE))
50+
( \
51+
AssertMacro((bf->freeNext == INVALID_DESCRIPTOR)), \
52+
AssertMacro((bf->freePrev == INVALID_DESCRIPTOR)), \
53+
AssertMacro(! (bf->flags & BM_FREE)) \
54+
)
5155

5256

5357
/*

‎src/backend/tcop/utility.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.39 1998/06/04 17:26:48 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.40 1998/06/15 18:39:29 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -67,13 +67,18 @@ extern const char **ps_status;/* from postgres.c */
6767
*processing within an aborted transaction block.
6868
* ----------------
6969
*/
70+
/* we have to use IF because of the 'break' */
7071
#defineCHECK_IF_ABORTED() \
71-
if (IsAbortedTransactionBlockState()) { \
72+
if (1) \
73+
{ \
74+
if (IsAbortedTransactionBlockState()) \
75+
{ \
7276
elog(NOTICE, "(transaction aborted): %s", \
7377
"queries ignored until END"); \
7478
commandTag = "*ABORT STATE*"; \
7579
break; \
7680
} \
81+
} else
7782

7883
/* ----------------
7984
*general utility function invoker

‎src/backend/tioga/Arr_TgRecipe.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ typedef struct Arr_TgString
4343
(Arr_TgString *) NewVarray(ARR_TgString_INITIAL_SIZE, sizeof(TgString))
4444

4545
#defineenlargeArr_TgString(A,I) \
46-
(A)->size += (I); \
47-
(A)->val = (TgString *) realloc((A)->val, (A)->valSize * (A)->size)
46+
( \
47+
(A)->size += (I), \
48+
(A)->val = (TgString *) realloc((A)->val, (A)->valSize * (A)->size) \
49+
)
4850

4951
#defineaddArr_TgString(A,V) \
5052
AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgString)
@@ -79,8 +81,10 @@ typedef struct Arr_TgElementPtr
7981
(Arr_TgElementPtr *) NewVarray(ARR_TgElementPtr_INITIAL_SIZE, sizeof(TgElementPtr))
8082

8183
#defineenlargeArr_TgElementPtr(A,I) \
82-
(A)->size += (I); \
83-
(A)->val = (TgElementPtr *) realloc((A)->val, (A)->valSize * (A)->size)
84+
( \
85+
(A)->size += (I), \
86+
(A)->val = (TgElementPtr *) realloc((A)->val, (A)->valSize * (A)->size) \
87+
)
8488

8589
#defineaddArr_TgElementPtr(A,V) \
8690
AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgElementPtr)
@@ -115,8 +119,10 @@ typedef struct Arr_TgNodePtr
115119
(Arr_TgNodePtr *) NewVarray(ARR_TgNodePtr_INITIAL_SIZE, sizeof(TgNodePtr))
116120

117121
#defineenlargeArr_TgNodePtr(A,I) \
118-
(A)->size += (I); \
119-
(A)->val = (TgNodePtr *) realloc((A)->val, (A)->valSize * (A)->size)
122+
( \
123+
(A)->size += (I), \
124+
(A)->val = (TgNodePtr *) realloc((A)->val, (A)->valSize * (A)->size) \
125+
)
120126

121127
#defineaddArr_TgNodePtr(A,V) \
122128
AppendVarray((Varray *) (A), (void *) (V), (CopyingFunct) copyTgNodePtr)

‎src/backend/tioga/Varray.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ typedef void (*CopyingFunct) (void *from, void *to);
2323
#defineVARRAY_INITIAL_SIZE 32
2424

2525
#defineENLARGE_VARRAY(ARRAY,INC) \
26-
(ARRAY)->maxObj += (INC); \
26+
( \
27+
(ARRAY)->maxObj += (INC), \
2728
(ARRAY)->val = (void *) realloc((ARRAY)->val, \
28-
(ARRAY)->size * (ARRAY)->maxObj)
29+
(ARRAY)->size * (ARRAY)->maxObj) \
30+
)
2931

3032
#defineVARRAY_NTH(VAL,SIZE,N) (((char *) (VAL)) + (SIZE) * (N))
3133

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.24 1998/02/26 04:36:57 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.25 1998/06/15 18:39:34 momjian Exp $
1313
*
1414
* NOTES
1515
* This code is actually (almost) unused.
@@ -187,8 +187,11 @@ reltimeout(int32 time)
187187
}/* reltimeout() */
188188

189189

190-
#defineTMODULO(t,q,u) {q = (t / u); \
191-
if (q != 0) t -= (q * u);}
190+
#defineTMODULO(t,q,u) \
191+
do { \
192+
q = (t / u); \
193+
if (q != 0) t -= (q * u); \
194+
} while(0)
192195

193196
staticvoid
194197
reltime2tm(int32time,structtm*tm)

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.53 1998/05/09 22:38:18 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.54 1998/06/15 18:39:37 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -66,8 +66,12 @@ char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
6666
/* TMODULO()
6767
* Macro to replace modf(), which is broken on some platforms.
6868
*/
69-
#defineTMODULO(t,q,u) {q = ((t < 0)? ceil(t / u): floor(t / u)); \
70-
if (q != 0) t -= rint(q * u);}
69+
#defineTMODULO(t,q,u) \
70+
do { \
71+
q = ((t < 0)? ceil(t / u): floor(t / u)); \
72+
if (q != 0) \
73+
t -= rint(q * u); \
74+
} while(0)
7175

7276
staticvoidGetEpochTime(structtm*tm);
7377

‎src/backend/utils/cache/catcache.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.27 1998/04/26 04:08:01 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.28 1998/06/15 18:39:40 momjian Exp $
1111
*
1212
* Notes:
1313
*XXX This needs to use exception.h to handle recovery when
@@ -96,21 +96,27 @@ static long eqproc[] = {
9696
*/
9797
#ifdefCACHEDEBUG
9898
#defineCatalogCacheInitializeCache_DEBUG1 \
99+
do { \
99100
elog(DEBUG, "CatalogCacheInitializeCache: cache @%08lx", cache); \
100101
if (relation) \
101102
elog(DEBUG, "CatalogCacheInitializeCache: called w/relation(inval)"); \
102103
else \
103104
elog(DEBUG, "CatalogCacheInitializeCache: called w/relname %s", \
104-
cache->cc_relname)
105+
cache->cc_relname) \
106+
} while(0)
107+
105108
#defineCatalogCacheInitializeCache_DEBUG2 \
109+
do { \
106110
if (cache->cc_key[i] > 0) { \
107111
elog(DEBUG, "CatalogCacheInitializeCache: load %d/%d w/%d, %d", \
108112
i+1, cache->cc_nkeys, cache->cc_key[i], \
109113
relation->rd_att->attrs[cache->cc_key[i] - 1]->attlen); \
110114
} else { \
111115
elog(DEBUG, "CatalogCacheInitializeCache: load %d/%d w/%d", \
112116
i+1, cache->cc_nkeys, cache->cc_key[i]); \
113-
}
117+
} \
118+
} while(0)
119+
114120
#else
115121
#defineCatalogCacheInitializeCache_DEBUG1
116122
#defineCatalogCacheInitializeCache_DEBUG2
@@ -654,16 +660,20 @@ SystemCacheRelationFlushed(Oid relId)
654660
*/
655661
#ifdefCACHEDEBUG
656662
#defineInitSysCache_DEBUG1 \
657-
elog(DEBUG, "InitSysCache: rid=%d id=%d nkeys=%d size=%d\n", \
658-
cp->relationId, cp->id, cp->cc_nkeys, cp->cc_size); \
659-
for (i = 0; i < nkeys; i += 1) { \
660-
elog(DEBUG, "InitSysCache: key=%d len=%d skey=[%d %d %d %d]\n", \
661-
cp->cc_key[i], cp->cc_klen[i], \
662-
cp->cc_skey[i].sk_flags, \
663-
cp->cc_skey[i].sk_attno, \
664-
cp->cc_skey[i].sk_procedure, \
665-
cp->cc_skey[i].sk_argument); \
666-
}
663+
do { \
664+
elog(DEBUG, "InitSysCache: rid=%d id=%d nkeys=%d size=%d\n", \
665+
cp->relationId, cp->id, cp->cc_nkeys, cp->cc_size); \
666+
for (i = 0; i < nkeys; i += 1) \
667+
{ \
668+
elog(DEBUG, "InitSysCache: key=%d len=%d skey=[%d %d %d %d]\n", \
669+
cp->cc_key[i], cp->cc_klen[i], \
670+
cp->cc_skey[i].sk_flags, \
671+
cp->cc_skey[i].sk_attno, \
672+
cp->cc_skey[i].sk_procedure, \
673+
cp->cc_skey[i].sk_argument); \
674+
} \
675+
} while(0)
676+
667677
#else
668678
#defineInitSysCache_DEBUG1
669679
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp