about summary refs log tree commit diff
path: root/src/rt/rust_kernel.cpp
diff options
context:
space:
mode:
authorBrian Anderson <andersrb@gmail.com>2011-04-07 20:37:56 -0400
committerBrian Anderson <andersrb@gmail.com>2011-04-07 22:53:16 -0400
commitb883ec4c9d09848a9c9a0822cde4bef4a347cbab (patch)
tree56880d5c7818ecd71d41ef8d061bea096b2b7223 /src/rt/rust_kernel.cpp
parent0abccc6370a6f943f9f41e6baec444dd3de2182a (diff)
downloadrust-b883ec4c9d09848a9c9a0822cde4bef4a347cbab.tar.gz
rust-b883ec4c9d09848a9c9a0822cde4bef4a347cbab.zip
Avoid some gotchas with logging macros
I think this is sufficient to eliminate multiple evaluation and the
possibility of accidental miscompilation from the logging macros.
Diffstat (limited to 'src/rt/rust_kernel.cpp')
-rw-r--r--src/rt/rust_kernel.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index 9b8347bc1f8..1eba9585ad6 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -1,9 +1,11 @@
 #include "rust_internal.h"
 
 #define KLOG(...)                                 \
-  if (_log.is_tracing(rust_log::KERN)) {          \
-      log(rust_log::KERN, __VA_ARGS__);           \
-  } else
+  do {                                            \
+    if (_log.is_tracing(rust_log::KERN)) {        \
+        log(rust_log::KERN, __VA_ARGS__);         \
+    }                                             \
+  } while(0)
 
 rust_kernel::rust_kernel(rust_srv *srv) :
     _region(&srv->local_region),