From b883ec4c9d09848a9c9a0822cde4bef4a347cbab Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 7 Apr 2011 20:37:56 -0400 Subject: 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. --- src/rt/rust_kernel.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/rt/rust_kernel.cpp') 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), -- cgit 1.4.1-3-g733a5