summaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-05-25 21:40:43 +0000
committerBruce Momjian <bruce@momjian.us>2005-05-25 21:40:43 +0000
commitb492c3acccb3f8c97559ddfc2a25f25953a026d2 (patch)
treea9c42aa2bd86a88a849ffaa005766ffe3dee762a /src/interfaces
parent13b729ca5267b58005f1ca9c873a86c2b0db3591 (diff)
downloadpostgresql-b492c3acccb3f8c97559ddfc2a25f25953a026d2.tar.gz
Add parentheses to macros when args are used in computations. Without
them, the executation behavior could be unexpected.
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/ecpg/pgtypeslib/dt.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/interfaces/ecpg/pgtypeslib/dt.h b/src/interfaces/ecpg/pgtypeslib/dt.h
index 53108a85bf..c85a7cce68 100644
--- a/src/interfaces/ecpg/pgtypeslib/dt.h
+++ b/src/interfaces/ecpg/pgtypeslib/dt.h
@@ -193,8 +193,8 @@ typedef struct
*/
#define FMODULO(t,q,u) \
do { \
- q = ((t < 0) ? ceil(t / u): floor(t / u)); \
- if (q != 0) t -= rint(q * u); \
+ (q) = (((t) < 0) ? ceil((t) / (u)): floor((t) / (u))); \
+ if ((q) != 0) (t) -= rint((q) * (u)); \
} while(0)
/* TMODULO()
@@ -205,14 +205,14 @@ do { \
#ifdef HAVE_INT64_TIMESTAMP
#define TMODULO(t,q,u) \
do { \
- q = (t / u); \
- if (q != 0) t -= (q * u); \
+ (q) = ((t) / (u)); \
+ if ((q) != 0) (t) -= ((q) * (u)); \
} while(0)
#else
#define TMODULO(t,q,u) \
do { \
- q = ((t < 0) ? ceil(t / u): floor(t / u)); \
- if (q != 0) t -= rint(q * u); \
+ (q) = (((t) < 0) ? ceil((t) / (u)): floor((t) / (u))); \
+ if ((q) != 0) (t) -= rint((q) * (u)); \
} while(0)
#endif
@@ -277,8 +277,8 @@ do { \
#endif
#endif /* HAVE_INT64_TIMESTAMP */
-#define TIMESTAMP_NOBEGIN(j) do {j = DT_NOBEGIN;} while (0)
-#define TIMESTAMP_NOEND(j) do {j = DT_NOEND;} while (0)
+#define TIMESTAMP_NOBEGIN(j) do {(j) = DT_NOBEGIN;} while (0)
+#define TIMESTAMP_NOEND(j) do {(j) = DT_NOEND;} while (0)
#define TIMESTAMP_IS_NOBEGIN(j) ((j) == DT_NOBEGIN)
#define TIMESTAMP_IS_NOEND(j) ((j) == DT_NOEND)
#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))