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 /src/port | |
| parent | 13b729ca5267b58005f1ca9c873a86c2b0db3591 (diff) | |
Add parentheses to macros when args are used in computations. Without
them, the executation behavior could be unexpected.
Diffstat (limited to 'src/port')
| -rw-r--r-- | src/port/crypt.c | 8 | ||||
| -rw-r--r-- | src/port/qsort.c | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/port/crypt.c b/src/port/crypt.c index 7d0f14a6d10..2c71be98a94 100644 --- a/src/port/crypt.c +++ b/src/port/crypt.c @@ -740,7 +740,7 @@ int num_iter; { #define SPTAB(t, i) \ - (*(int32_t *)((unsigned char *)t + i*(sizeof(int32_t)/4))) + (*(int32_t *)((unsigned char *)(t) + (i)*(sizeof(int32_t)/4))) #if defined(gould) /* use this if B.b[i] is evaluated just once ... */ #define DOXOR(x,y,i) x^=SPTAB(SPE[0][i],B.b[i]); y^=SPTAB(SPE[1][i],B.b[i]); @@ -755,9 +755,9 @@ int num_iter; #endif #define CRUNCH(p0, p1, q0, q1) \ - k = (q0 ^ q1) & SALT; \ - B.b32.i0 = k ^ q0 ^ kp->b32.i0; \ - B.b32.i1 = k ^ q1 ^ kp->b32.i1; \ + k = ((q0) ^ (q1)) & SALT; \ + B.b32.i0 = k ^ (q0) ^ kp->b32.i0; \ + B.b32.i1 = k ^ (q1) ^ kp->b32.i1; \ kp = (C_block *)((char *)kp+ks_inc); \ \ DOXOR(p0, p1, 0); \ diff --git a/src/port/qsort.c b/src/port/qsort.c index 2fb5149a8b3..08b53890442 100644 --- a/src/port/qsort.c +++ b/src/port/qsort.c @@ -3,7 +3,7 @@ * Add do ... while() macro fix * Remove __inline, _DIAGASSERTs, __P * - * $PostgreSQL: pgsql/src/port/qsort.c,v 1.5 2004/10/05 00:12:49 neilc Exp $ + * $PostgreSQL: pgsql/src/port/qsort.c,v 1.6 2005/05/25 21:40:43 momjian Exp $ */ /* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */ @@ -63,8 +63,8 @@ do { \ } while (--i > 0); \ } while (0) -#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ - es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; +#define SWAPINIT(a, es) swaptype = ((char *)(a) - (char *)0) % sizeof(long) || \ + (es) % sizeof(long) ? 2 : (es) == sizeof(long)? 0 : 1; static void swapfunc(a, b, n, swaptype) |
