diff options
author | Bruce Momjian | 2005-05-25 21:40:43 +0000 |
---|---|---|
committer | Bruce Momjian | 2005-05-25 21:40:43 +0000 |
commit | b492c3acccb3f8c97559ddfc2a25f25953a026d2 (patch) | |
tree | a9c42aa2bd86a88a849ffaa005766ffe3dee762a /contrib | |
parent | 13b729ca5267b58005f1ca9c873a86c2b0db3591 (diff) |
Add parentheses to macros when args are used in computations. Without
them, the executation behavior could be unexpected.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/intarray/_int_bool.c | 2 | ||||
-rw-r--r-- | contrib/ltree/crc32.c | 2 | ||||
-rw-r--r-- | contrib/ltree/ltree.h | 2 | ||||
-rw-r--r-- | contrib/ltree/ltxtquery_io.c | 10 | ||||
-rw-r--r-- | contrib/pgcrypto/crypt-blowfish.c | 26 | ||||
-rw-r--r-- | contrib/pgcrypto/rijndael.c | 96 | ||||
-rw-r--r-- | contrib/pgcrypto/sha1.c | 4 | ||||
-rw-r--r-- | contrib/rtree_gist/rtree_gist.c | 14 | ||||
-rw-r--r-- | contrib/tsearch/crc32.c | 2 | ||||
-rw-r--r-- | contrib/tsearch/gistidx.h | 16 | ||||
-rw-r--r-- | contrib/tsearch/query.c | 10 | ||||
-rw-r--r-- | contrib/tsearch/query.h | 4 | ||||
-rw-r--r-- | contrib/tsearch2/crc32.c | 2 | ||||
-rw-r--r-- | contrib/tsearch2/gistidx.h | 20 | ||||
-rw-r--r-- | contrib/tsearch2/query.c | 10 | ||||
-rw-r--r-- | contrib/tsearch2/query.h | 6 | ||||
-rw-r--r-- | contrib/tsearch2/ts_stat.h | 10 | ||||
-rw-r--r-- | contrib/tsearch2/tsvector.h | 12 |
18 files changed, 124 insertions, 124 deletions
diff --git a/contrib/intarray/_int_bool.c b/contrib/intarray/_int_bool.c index d57a94e8709..06759c44e34 100644 --- a/contrib/intarray/_int_bool.c +++ b/contrib/intarray/_int_bool.c @@ -466,7 +466,7 @@ typedef struct int4 buflen; } INFIX; -#define RESIZEBUF(inf,addsize) while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) { \ +#define RESIZEBUF(inf,addsize) while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) { \ int4 len = inf->cur - inf->buf; \ inf->buflen *= 2; \ inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \ diff --git a/contrib/ltree/crc32.c b/contrib/ltree/crc32.c index 8a4f27b3066..c82b3a644c8 100644 --- a/contrib/ltree/crc32.c +++ b/contrib/ltree/crc32.c @@ -20,7 +20,7 @@ * Oroginal code by Spencer Garrett <srg@quick.com> */ -#define _CRC32_(crc, ch) (crc = (crc >> 8) ^ crc32tab[(crc ^ (ch)) & 0xff]) +#define _CRC32_(crc, ch) ((crc) = ((crc) >> 8) ^ crc32tab[((crc) ^ (ch)) & 0xff]) /* generated using the AUTODIN II polynomial * x^32 + x^26 + x^23 + x^22 + x^16 + diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h index c55c757016a..2057751cfe2 100644 --- a/contrib/ltree/ltree.h +++ b/contrib/ltree/ltree.h @@ -109,7 +109,7 @@ typedef struct } ltxtquery; #define HDRSIZEQT MAXALIGN( 2*sizeof(int4) ) -#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + size * sizeof(ITEM) + lenofoperand ) +#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) ) #define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT ) #define GETOPERAND(x) ( (char*)GETQUERY(x) + ((ltxtquery*)x)->size * sizeof(ITEM) ) diff --git a/contrib/ltree/ltxtquery_io.c b/contrib/ltree/ltxtquery_io.c index f63c9ee6fbf..0751a6b718e 100644 --- a/contrib/ltree/ltxtquery_io.c +++ b/contrib/ltree/ltxtquery_io.c @@ -386,12 +386,12 @@ typedef struct } INFIX; #define RESIZEBUF(inf,addsize) \ -while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) \ +while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) \ { \ - int4 len = inf->cur - inf->buf; \ - inf->buflen *= 2; \ - inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \ - inf->cur = inf->buf + len; \ + int4 len = (inf)->cur - (inf)->buf; \ + (inf)->buflen *= 2; \ + (inf)->buf = (char*) repalloc( (void*)(inf)->buf, (inf)->buflen ); \ + (inf)->cur = (inf)->buf + len; \ } /* diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c index ed32da9a7f9..a882cf4c876 100644 --- a/contrib/pgcrypto/crypt-blowfish.c +++ b/contrib/pgcrypto/crypt-blowfish.c @@ -452,41 +452,41 @@ BF_swap(BF_word * x, int count) #if BF_SCALE /* Architectures which can shift addresses left by 2 bits with no extra cost */ #define BF_ROUND(L, R, N) \ - tmp1 = L & 0xFF; \ - tmp2 = L >> 8; \ + tmp1 = (L) & 0xFF; \ + tmp2 = (L) >> 8; \ tmp2 &= 0xFF; \ - tmp3 = L >> 16; \ + tmp3 = (L) >> 16; \ tmp3 &= 0xFF; \ - tmp4 = L >> 24; \ + tmp4 = (L) >> 24; \ tmp1 = data.ctx.S[3][tmp1]; \ tmp2 = data.ctx.S[2][tmp2]; \ tmp3 = data.ctx.S[1][tmp3]; \ tmp3 += data.ctx.S[0][tmp4]; \ tmp3 ^= tmp2; \ - R ^= data.ctx.P[N + 1]; \ + (R) ^= data.ctx.P[(N) + 1]; \ tmp3 += tmp1; \ - R ^= tmp3; + (R) ^= tmp3; #else /* Architectures with no complicated addressing modes supported */ #define BF_INDEX(S, i) \ - (*((BF_word *)(((unsigned char *)S) + (i)))) + (*((BF_word *)(((unsigned char *)(S)) + (i)))) #define BF_ROUND(L, R, N) \ - tmp1 = L & 0xFF; \ + tmp1 = (L) & 0xFF; \ tmp1 <<= 2; \ - tmp2 = L >> 6; \ + tmp2 = (L) >> 6; \ tmp2 &= 0x3FC; \ - tmp3 = L >> 14; \ + tmp3 = (L) >> 14; \ tmp3 &= 0x3FC; \ - tmp4 = L >> 22; \ + tmp4 = (L) >> 22; \ tmp4 &= 0x3FC; \ tmp1 = BF_INDEX(data.ctx.S[3], tmp1); \ tmp2 = BF_INDEX(data.ctx.S[2], tmp2); \ tmp3 = BF_INDEX(data.ctx.S[1], tmp3); \ tmp3 += BF_INDEX(data.ctx.S[0], tmp4); \ tmp3 ^= tmp2; \ - R ^= data.ctx.P[N + 1]; \ + (R) ^= data.ctx.P[(N) + 1]; \ tmp3 += tmp1; \ - R ^= tmp3; + (R) ^= tmp3; #endif /* diff --git a/contrib/pgcrypto/rijndael.c b/contrib/pgcrypto/rijndael.c index 8b2b99f13b4..8a68e3f166b 100644 --- a/contrib/pgcrypto/rijndael.c +++ b/contrib/pgcrypto/rijndael.c @@ -57,11 +57,11 @@ static void gen_tabs(void); /* Invert byte order in a 32 bit variable */ -#define bswap(x) ((rotl(x, 8) & 0x00ff00ff) | (rotr(x, 8) & 0xff00ff00)) +#define bswap(x) ((rotl((x), 8) & 0x00ff00ff) | (rotr((x), 8) & 0xff00ff00)) /* Extract byte from a 32 bit quantity (little endian notation) */ -#define byte(x,n) ((u1byte)((x) >> (8 * n))) +#define byte(x,n) ((u1byte)((x) >> (8 * (n)))) #if BYTE_ORDER != LITTLE_ENDIAN #define BYTE_SWAP @@ -100,19 +100,19 @@ static u4byte il_tab[4][256]; static u4byte tab_gen = 0; #endif /* !PRE_CALC_TABLES */ -#define ff_mult(a,b) (a && b ? pow_tab[(log_tab[a] + log_tab[b]) % 255] : 0) +#define ff_mult(a,b) ((a) && (b) ? pow_tab[(log_tab[a] + log_tab[b]) % 255] : 0) -#define f_rn(bo, bi, n, k) \ - bo[n] = ft_tab[0][byte(bi[n],0)] ^ \ - ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \ - ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n) +#define f_rn(bo, bi, n, k) \ + (bo)[n] = ft_tab[0][byte((bi)[n],0)] ^ \ + ft_tab[1][byte((bi)[((n) + 1) & 3],1)] ^ \ + ft_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \ + ft_tab[3][byte((bi)[((n) + 3) & 3],3)] ^ *((k) + (n)) #define i_rn(bo, bi, n, k) \ - bo[n] = it_tab[0][byte(bi[n],0)] ^ \ - it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \ - it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n) + (bo)[n] = it_tab[0][byte((bi)[n],0)] ^ \ + it_tab[1][byte((bi)[((n) + 3) & 3],1)] ^ \ + it_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \ + it_tab[3][byte((bi)[((n) + 1) & 3],3)] ^ *((k) + (n)) #ifdef LARGE_TABLES @@ -122,17 +122,17 @@ static u4byte tab_gen = 0; fl_tab[2][byte(x, 2)] ^ \ fl_tab[3][byte(x, 3)] ) -#define f_rl(bo, bi, n, k) \ - bo[n] = fl_tab[0][byte(bi[n],0)] ^ \ - fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \ - fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n) +#define f_rl(bo, bi, n, k) \ + (bo)[n] = fl_tab[0][byte((bi)[n],0)] ^ \ + fl_tab[1][byte((bi)[((n) + 1) & 3],1)] ^ \ + fl_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \ + fl_tab[3][byte((bi)[((n) + 3) & 3],3)] ^ *((k) + (n)) -#define i_rl(bo, bi, n, k) \ - bo[n] = il_tab[0][byte(bi[n],0)] ^ \ - il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \ - il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \ - il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n) +#define i_rl(bo, bi, n, k) \ + (bo)[n] = il_tab[0][byte((bi)[n],0)] ^ \ + il_tab[1][byte((bi)[((n) + 3) & 3],1)] ^ \ + il_tab[2][byte((bi)[((n) + 2) & 3],2)] ^ \ + il_tab[3][byte((bi)[((n) + 1) & 3],3)] ^ *((k) + (n)) #else @@ -142,17 +142,17 @@ static u4byte tab_gen = 0; ((u4byte)sbx_tab[byte(x, 2)] << 16) ^ \ ((u4byte)sbx_tab[byte(x, 3)] << 24) -#define f_rl(bo, bi, n, k) \ - bo[n] = (u4byte)sbx_tab[byte(bi[n],0)] ^ \ - rotl(((u4byte)sbx_tab[byte(bi[(n + 1) & 3],1)]), 8) ^ \ - rotl(((u4byte)sbx_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \ - rotl(((u4byte)sbx_tab[byte(bi[(n + 3) & 3],3)]), 24) ^ *(k + n) - -#define i_rl(bo, bi, n, k) \ - bo[n] = (u4byte)isb_tab[byte(bi[n],0)] ^ \ - rotl(((u4byte)isb_tab[byte(bi[(n + 3) & 3],1)]), 8) ^ \ - rotl(((u4byte)isb_tab[byte(bi[(n + 2) & 3],2)]), 16) ^ \ - rotl(((u4byte)isb_tab[byte(bi[(n + 1) & 3],3)]), 24) ^ *(k + n) +#define f_rl(bo, bi, n, k) \ + (bo)[n] = (u4byte)sbx_tab[byte((bi)[n],0)] ^ \ + rotl(((u4byte)sbx_tab[byte((bi)[((n) + 1) & 3],1)]), 8) ^ \ + rotl(((u4byte)sbx_tab[byte((bi)[((n) + 2) & 3],2)]), 16) ^ \ + rotl(((u4byte)sbx_tab[byte((bi)[((n) + 3) & 3],3)]), 24) ^ *((k) + (n)) + +#define i_rl(bo, bi, n, k) \ + (bo)[n] = (u4byte)isb_tab[byte((bi)[n],0)] ^ \ + rotl(((u4byte)isb_tab[byte((bi)[((n) + 3) & 3],1)]), 8) ^ \ + rotl(((u4byte)isb_tab[byte((bi)[((n) + 2) & 3],2)]), 16) ^ \ + rotl(((u4byte)isb_tab[byte((bi)[((n) + 1) & 3],3)]), 24) ^ *((k) + (n)) #endif static void @@ -282,25 +282,25 @@ do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ #define loop6(i) \ do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ - t ^= e_key[6 * i]; e_key[6 * i + 6] = t; \ - t ^= e_key[6 * i + 1]; e_key[6 * i + 7] = t; \ - t ^= e_key[6 * i + 2]; e_key[6 * i + 8] = t; \ - t ^= e_key[6 * i + 3]; e_key[6 * i + 9] = t; \ - t ^= e_key[6 * i + 4]; e_key[6 * i + 10] = t; \ - t ^= e_key[6 * i + 5]; e_key[6 * i + 11] = t; \ + t ^= e_key[6 * (i)]; e_key[6 * (i) + 6] = t; \ + t ^= e_key[6 * (i) + 1]; e_key[6 * (i) + 7] = t; \ + t ^= e_key[6 * (i) + 2]; e_key[6 * (i) + 8] = t; \ + t ^= e_key[6 * (i) + 3]; e_key[6 * (i) + 9] = t; \ + t ^= e_key[6 * (i) + 4]; e_key[6 * (i) + 10] = t; \ + t ^= e_key[6 * (i) + 5]; e_key[6 * (i) + 11] = t; \ } while (0) #define loop8(i) \ do { t = ls_box(rotr(t, 8)) ^ rco_tab[i]; \ - t ^= e_key[8 * i]; e_key[8 * i + 8] = t; \ - t ^= e_key[8 * i + 1]; e_key[8 * i + 9] = t; \ - t ^= e_key[8 * i + 2]; e_key[8 * i + 10] = t; \ - t ^= e_key[8 * i + 3]; e_key[8 * i + 11] = t; \ - t = e_key[8 * i + 4] ^ ls_box(t); \ - e_key[8 * i + 12] = t; \ - t ^= e_key[8 * i + 5]; e_key[8 * i + 13] = t; \ - t ^= e_key[8 * i + 6]; e_key[8 * i + 14] = t; \ - t ^= e_key[8 * i + 7]; e_key[8 * i + 15] = t; \ + t ^= e_key[8 * (i)]; e_key[8 * (i) + 8] = t; \ + t ^= e_key[8 * (i) + 1]; e_key[8 * (i) + 9] = t; \ + t ^= e_key[8 * (i) + 2]; e_key[8 * (i) + 10] = t; \ + t ^= e_key[8 * (i) + 3]; e_key[8 * (i) + 11] = t; \ + t = e_key[8 * (i) + 4] ^ ls_box(t); \ + e_key[8 * (i) + 12] = t; \ + t ^= e_key[8 * (i) + 5]; e_key[8 * (i) + 13] = t; \ + t ^= e_key[8 * (i) + 6]; e_key[8 * (i) + 14] = t; \ + t ^= e_key[8 * (i) + 7]; e_key[8 * (i) + 15] = t; \ } while (0) rijndael_ctx * diff --git a/contrib/pgcrypto/sha1.c b/contrib/pgcrypto/sha1.c index 1a013f54095..b1c189ab4dd 100644 --- a/contrib/pgcrypto/sha1.c +++ b/contrib/pgcrypto/sha1.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.14 2004/08/29 16:43:05 tgl Exp $ */ +/* $PostgreSQL: pgsql/contrib/pgcrypto/sha1.c,v 1.15 2005/05/25 21:40:39 momjian Exp $ */ /* $KAME: sha1.c,v 1.3 2000/02/22 14:01:18 itojun Exp $ */ /* @@ -59,7 +59,7 @@ static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6}; #define F2(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) #define F3(b, c, d) (((b) ^ (c)) ^ (d)) -#define S(n, x) (((x) << (n)) | ((x) >> (32 - n))) +#define S(n, x) (((x) << (n)) | ((x) >> (32 - (n)))) #define H(n) (ctxt->h.b32[(n)]) #define COUNT (ctxt->count) diff --git a/contrib/rtree_gist/rtree_gist.c b/contrib/rtree_gist/rtree_gist.c index d2f41569200..55a480915fb 100644 --- a/contrib/rtree_gist/rtree_gist.c +++ b/contrib/rtree_gist/rtree_gist.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.11 2005/05/21 12:08:05 neilc Exp $ + * $PostgreSQL: pgsql/contrib/rtree_gist/rtree_gist.c,v 1.12 2005/05/25 21:40:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -276,14 +276,14 @@ gbox_picksplit(PG_FUNCTION_ARGS) #define ADDLIST( list, unionD, pos, num ) do { \ if ( pos ) { \ - if ( unionD->high.x < cur->high.x ) unionD->high.x = cur->high.x; \ - if ( unionD->low.x > cur->low.x ) unionD->low.x = cur->low.x; \ - if ( unionD->high.y < cur->high.y ) unionD->high.y = cur->high.y; \ - if ( unionD->low.y > cur->low.y ) unionD->low.y = cur->low.y; \ + if ( (unionD)->high.x < cur->high.x ) (unionD)->high.x = cur->high.x; \ + if ( (unionD)->low.x > cur->low.x ) (unionD)->low.x = cur->low.x; \ + if ( (unionD)->high.y < cur->high.y ) (unionD)->high.y = cur->high.y; \ + if ( (unionD)->low.y > cur->low.y ) (unionD)->low.y = cur->low.y; \ } else { \ - memcpy( (void*)unionD, (void*) cur, sizeof( BOX ) ); \ + memcpy( (void*)(unionD), (void*) cur, sizeof( BOX ) ); \ } \ - list[pos] = num; \ + (list)[pos] = num; \ (pos)++; \ } while(0) diff --git a/contrib/tsearch/crc32.c b/contrib/tsearch/crc32.c index dc93db727c1..c314019b7f0 100644 --- a/contrib/tsearch/crc32.c +++ b/contrib/tsearch/crc32.c @@ -13,7 +13,7 @@ * Oroginal code by Spencer Garrett <srg@quick.com> */ -#define _CRC32_(crc, ch) (crc = (crc >> 8) ^ crc32tab[(crc ^ (ch)) & 0xff]) +#define _CRC32_(crc, ch) ((crc) = ((crc) >> 8) ^ crc32tab[((crc) ^ (ch)) & 0xff]) /* generated using the AUTODIN II polynomial * x^32 + x^26 + x^23 + x^22 + x^16 + diff --git a/contrib/tsearch/gistidx.h b/contrib/tsearch/gistidx.h index 90ce6a9263e..449e2ac8423 100644 --- a/contrib/tsearch/gistidx.h +++ b/contrib/tsearch/gistidx.h @@ -27,7 +27,7 @@ typedef char *BITVECP; } #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) ) -#define GETBITBYTE(x,i) ( ((char)(x)) >> i & 0x01 ) +#define GETBITBYTE(x,i) ( ((char)(x)) >> (i) & 0x01 ) #define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) ) #define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) ) #define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 ) @@ -50,15 +50,15 @@ typedef struct #define SIGNKEY 0x02 #define ALLISTRUE 0x04 -#define ISARRKEY(x) ( ((GISTTYPE*)x)->flag & ARRKEY ) -#define ISSIGNKEY(x) ( ((GISTTYPE*)x)->flag & SIGNKEY ) -#define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE ) +#define ISARRKEY(x) ( ((GISTTYPE*)(x))->flag & ARRKEY ) +#define ISSIGNKEY(x) ( ((GISTTYPE*)(x))->flag & SIGNKEY ) +#define ISALLTRUE(x) ( ((GISTTYPE*)(x))->flag & ALLISTRUE ) -#define GTHDRSIZE ( sizeof(int4)*2 ) +#define GTHDRSIZE ( sizeof(int4)* 2 ) #define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) ) -#define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) ) -#define GETARR(x) ( (int4*)( (char*)x+GTHDRSIZE ) ) -#define ARRNELEM(x) ( ( ((GISTTYPE*)x)->len - GTHDRSIZE )/sizeof(int4) ) +#define GETSIGN(x) ( (BITVECP)( (char*)(x) + GTHDRSIZE ) ) +#define GETARR(x) ( (int4*)( (char*)(x) + GTHDRSIZE ) ) +#define ARRNELEM(x) ( ( ((GISTTYPE*)(x))->len - GTHDRSIZE ) / sizeof(int4) ) #endif diff --git a/contrib/tsearch/query.c b/contrib/tsearch/query.c index 76e21c524a8..1dcc9c86789 100644 --- a/contrib/tsearch/query.c +++ b/contrib/tsearch/query.c @@ -658,12 +658,12 @@ typedef struct } INFIX; #define RESIZEBUF(inf,addsize) \ -while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) \ +while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) \ { \ - int4 len = inf->cur - inf->buf; \ - inf->buflen *= 2; \ - inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \ - inf->cur = inf->buf + len; \ + int4 len = (inf)->cur - (inf)->buf; \ + (inf)->buflen *= 2; \ + (inf)->buf = (char*) repalloc( (void*)(inf)->buf, (inf)->buflen ); \ + (inf)->cur = (inf)->buf + len; \ } /* diff --git a/contrib/tsearch/query.h b/contrib/tsearch/query.h index 6d55f6b411e..e7ca700be28 100644 --- a/contrib/tsearch/query.h +++ b/contrib/tsearch/query.h @@ -31,9 +31,9 @@ typedef struct } QUERYTYPE; #define HDRSIZEQT ( 2*sizeof(int4) ) -#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + size * sizeof(ITEM) + lenofoperand ) +#define COMPUTESIZE(size, lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) ) #define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT ) -#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)x)->size * sizeof(ITEM) ) +#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)(x))->size * sizeof(ITEM) ) #define ISOPERATOR(x) ( (x)=='!' || (x)=='&' || (x)=='|' || (x)=='(' || (x)==')' ) diff --git a/contrib/tsearch2/crc32.c b/contrib/tsearch2/crc32.c index dc93db727c1..c314019b7f0 100644 --- a/contrib/tsearch2/crc32.c +++ b/contrib/tsearch2/crc32.c @@ -13,7 +13,7 @@ * Oroginal code by Spencer Garrett <srg@quick.com> */ -#define _CRC32_(crc, ch) (crc = (crc >> 8) ^ crc32tab[(crc ^ (ch)) & 0xff]) +#define _CRC32_(crc, ch) ((crc) = ((crc) >> 8) ^ crc32tab[((crc) ^ (ch)) & 0xff]) /* generated using the AUTODIN II polynomial * x^32 + x^26 + x^23 + x^22 + x^16 + diff --git a/contrib/tsearch2/gistidx.h b/contrib/tsearch2/gistidx.h index 6c8898da867..b4422a306ac 100644 --- a/contrib/tsearch2/gistidx.h +++ b/contrib/tsearch2/gistidx.h @@ -12,8 +12,8 @@ #define BITBYTE 8 #define SIGLENINT 63 /* >121 => key will toast, so it will not * work !!! */ -#define SIGLEN ( sizeof(int4)*SIGLENINT ) -#define SIGLENBIT (SIGLEN*BITBYTE) +#define SIGLEN ( sizeof(int4) * SIGLENINT ) +#define SIGLENBIT (SIGLEN * BITBYTE) typedef char BITVEC[SIGLEN]; typedef char *BITVECP; @@ -28,7 +28,7 @@ typedef char *BITVECP; } #define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITBYTE ) ) ) -#define GETBITBYTE(x,i) ( ((char)(x)) >> i & 0x01 ) +#define GETBITBYTE(x,i) ( ((char)(x)) >> (i) & 0x01 ) #define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITBYTE ) ) #define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITBYTE ) ) #define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITBYTE )) & 0x01 ) @@ -51,15 +51,15 @@ typedef struct #define SIGNKEY 0x02 #define ALLISTRUE 0x04 -#define ISARRKEY(x) ( ((GISTTYPE*)x)->flag & ARRKEY ) -#define ISSIGNKEY(x) ( ((GISTTYPE*)x)->flag & SIGNKEY ) -#define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE ) +#define ISARRKEY(x) ( ((GISTTYPE*)(x))->flag & ARRKEY ) +#define ISSIGNKEY(x) ( ((GISTTYPE*)(x))->flag & SIGNKEY ) +#define ISALLTRUE(x) ( ((GISTTYPE*)(x))->flag & ALLISTRUE ) -#define GTHDRSIZE ( sizeof(int4)*2 ) +#define GTHDRSIZE ( sizeof(int4) * 2 ) #define CALCGTSIZE(flag, len) ( GTHDRSIZE + ( ( (flag) & ARRKEY ) ? ((len)*sizeof(int4)) : (((flag) & ALLISTRUE) ? 0 : SIGLEN) ) ) -#define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) ) -#define GETARR(x) ( (int4*)( (char*)x+GTHDRSIZE ) ) -#define ARRNELEM(x) ( ( ((GISTTYPE*)x)->len - GTHDRSIZE )/sizeof(int4) ) +#define GETSIGN(x) ( (BITVECP)( (char*)(x)+GTHDRSIZE ) ) +#define GETARR(x) ( (int4*)( (char*)(x)+GTHDRSIZE ) ) +#define ARRNELEM(x) ( ( ((GISTTYPE*)(x))->len - GTHDRSIZE )/sizeof(int4) ) #endif diff --git a/contrib/tsearch2/query.c b/contrib/tsearch2/query.c index ee4f779d58d..eb45ba078e1 100644 --- a/contrib/tsearch2/query.c +++ b/contrib/tsearch2/query.c @@ -680,12 +680,12 @@ typedef struct } INFIX; #define RESIZEBUF(inf,addsize) \ -while( ( inf->cur - inf->buf ) + addsize + 1 >= inf->buflen ) \ +while( ( (inf)->cur - (inf)->buf ) + (addsize) + 1 >= (inf)->buflen ) \ { \ - int4 len = inf->cur - inf->buf; \ - inf->buflen *= 2; \ - inf->buf = (char*) repalloc( (void*)inf->buf, inf->buflen ); \ - inf->cur = inf->buf + len; \ + int4 len = (inf)->cur - (inf)->buf; \ + (inf)->buflen *= 2; \ + (inf)->buf = (char*) repalloc( (void*)(inf)->buf, (inf)->buflen ); \ + (inf)->cur = (inf)->buf + len; \ } /* diff --git a/contrib/tsearch2/query.h b/contrib/tsearch2/query.h index a65dbca762f..3ac757a1621 100644 --- a/contrib/tsearch2/query.h +++ b/contrib/tsearch2/query.h @@ -33,10 +33,10 @@ typedef struct char data[1]; } QUERYTYPE; -#define HDRSIZEQT ( 2*sizeof(int4) ) -#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + size * sizeof(ITEM) + lenofoperand ) +#define HDRSIZEQT ( 2 * sizeof(int4) ) +#define COMPUTESIZE(size,lenofoperand) ( HDRSIZEQT + (size) * sizeof(ITEM) + (lenofoperand) ) #define GETQUERY(x) (ITEM*)( (char*)(x)+HDRSIZEQT ) -#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)x)->size * sizeof(ITEM) ) +#define GETOPERAND(x) ( (char*)GETQUERY(x) + ((QUERYTYPE*)(x))->size * sizeof(ITEM) ) #define ISOPERATOR(x) ( (x)=='!' || (x)=='&' || (x)=='|' || (x)=='(' || (x)==')' ) diff --git a/contrib/tsearch2/ts_stat.h b/contrib/tsearch2/ts_stat.h index de43c606031..7d163360451 100644 --- a/contrib/tsearch2/ts_stat.h +++ b/contrib/tsearch2/ts_stat.h @@ -24,10 +24,10 @@ typedef struct char data[1]; } tsstat; -#define STATHDRSIZE (sizeof(int4)*4) -#define CALCSTATSIZE(x, lenstr) ( x * sizeof(StatEntry) + STATHDRSIZE + lenstr ) -#define STATPTR(x) ( (StatEntry*) ( (char*)x + STATHDRSIZE ) ) -#define STATSTRPTR(x) ( (char*)x + STATHDRSIZE + ( sizeof(StatEntry) * ((tsvector*)x)->size ) ) -#define STATSTRSIZE(x) ( ((tsvector*)x)->len - STATHDRSIZE - ( sizeof(StatEntry) * ((tsvector*)x)->size ) ) +#define STATHDRSIZE (sizeof(int4) * 4) +#define CALCSTATSIZE(x, lenstr) ( (x) * sizeof(StatEntry) + STATHDRSIZE + (lenstr) ) +#define STATPTR(x) ( (StatEntry*) ( (char*)(x) + STATHDRSIZE ) ) +#define STATSTRPTR(x) ( (char*)(x) + STATHDRSIZE + ( sizeof(StatEntry) * ((tsvector*)(x))->size ) ) +#define STATSTRSIZE(x) ( ((tsvector*)(x))->len - STATHDRSIZE - ( sizeof(StatEntry) * ((tsvector*)(x))->size ) ) #endif diff --git a/contrib/tsearch2/tsvector.h b/contrib/tsearch2/tsvector.h index 358ec570b69..e2fd0b6faef 100644 --- a/contrib/tsearch2/tsvector.h +++ b/contrib/tsearch2/tsvector.h @@ -37,7 +37,7 @@ typedef struct typedef uint16 WordEntryPos; #define WEP_GETWEIGHT(x) ( (x) >> 14 ) -#define WEP_GETPOS(x) ( (x) & 0x3fff ) +#define WEP_GETPOS(x) ( (x) & 0x3fff ) #define WEP_SETWEIGHT(x,v) (x) = ( (v) << 14 ) | ( (x) & 0x3fff ) #define WEP_SETPOS(x,v) (x) = ( (x) & 0xc000 ) | ( (v) & 0x3fff ) @@ -54,11 +54,11 @@ typedef struct char data[1]; } tsvector; -#define DATAHDRSIZE (sizeof(int4)*2) -#define CALCDATASIZE(x, lenstr) ( x * sizeof(WordEntry) + DATAHDRSIZE + lenstr ) -#define ARRPTR(x) ( (WordEntry*) ( (char*)x + DATAHDRSIZE ) ) -#define STRPTR(x) ( (char*)x + DATAHDRSIZE + ( sizeof(WordEntry) * ((tsvector*)x)->size ) ) -#define STRSIZE(x) ( ((tsvector*)x)->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((tsvector*)x)->size ) ) +#define DATAHDRSIZE (sizeof(int4) * 2) +#define CALCDATASIZE(x, lenstr) ( (x) * sizeof(WordEntry) + DATAHDRSIZE + (lenstr) ) +#define ARRPTR(x) ( (WordEntry*) ( (char*)(x) + DATAHDRSIZE ) ) +#define STRPTR(x) ( (char*)(x) + DATAHDRSIZE + ( sizeof(WordEntry) * ((tsvector*)(x))->size ) ) +#define STRSIZE(x) ( ((tsvector*)(x))->len - DATAHDRSIZE - ( sizeof(WordEntry) * ((tsvector*)(x))->size ) ) #define _POSDATAPTR(x,e) (STRPTR(x)+((WordEntry*)(e))->pos+SHORTALIGN(((WordEntry*)(e))->len)) #define POSDATALEN(x,e) ( ( ((WordEntry*)(e))->haspos ) ? (*(uint16*)_POSDATAPTR(x,e)) : 0 ) #define POSDATAPTR(x,e) ( (WordEntryPos*)( _POSDATAPTR(x,e)+sizeof(uint16) ) ) |