summaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-06-17 18:22:39 +0000
committerNick Mathewson <nickm@torproject.org>2007-06-17 18:22:39 +0000
commit5adfa09fce2c61239f9a7fa5fb154282f802af0a (patch)
treeffd522053a544617737cc38128c2e315dce464b1 /src/common/util.h
parent93f32db438cff63662761374f4a69b710f3d71d9 (diff)
downloadtor-5adfa09fce2c61239f9a7fa5fb154282f802af0a.tar.gz
tor-5adfa09fce2c61239f9a7fa5fb154282f802af0a.zip
r13477@catbus: nickm | 2007-06-17 14:22:03 -0400
Sun CC likes to give warnings for the do { } while(0) construction for making statement-like macros. Define STMT_BEGIN/STMT_END macros that do the right thing, and use them everywhere. svn:r10645
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/common/util.h b/src/common/util.h
index 0f0902452f..0da98625c0 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -47,14 +47,14 @@
/** Like assert(3), but send assertion failures to the log as well as to
* stderr. */
-#define tor_assert(expr) do { \
+#define tor_assert(expr) STMT_BEGIN \
if (PREDICT_UNLIKELY(IS_FALSE_AS_INT(expr))) { \
log(LOG_ERR, LD_BUG, "%s:%d: %s: Assertion %s failed; aborting.", \
_SHORT_FILE_, __LINE__, __func__, #expr); \
fprintf(stderr,"%s:%d %s: Assertion %s failed; aborting.\n", \
_SHORT_FILE_, __LINE__, __func__, #expr); \
abort(); \
- } } while (0)
+ } STMT_END
#endif
#ifdef USE_DMALLOC
@@ -83,19 +83,19 @@ void _tor_free(void *mem);
#ifdef USE_DMALLOC
extern int dmalloc_free(const char *file, const int line, void *pnt,
const int func_id);
-#define tor_free(p) do { \
+#define tor_free(p) STMT_BEGIN \
if (PREDICT_LIKELY((p)!=NULL)) { \
dmalloc_free(_SHORT_FILE_, __LINE__, (p), 0); \
(p)=NULL; \
} \
- } while (0)
+ STMT_END
#else
-#define tor_free(p) do { \
+#define tor_free(p) STMT_BEGIN \
if (PREDICT_LIKELY((p)!=NULL)) { \
free(p); \
(p)=NULL; \
} \
- } while (0)
+ STMT_END
#endif
#define tor_malloc(size) _tor_malloc(size DMALLOC_ARGS)