diff options
author | Eric Blake <eblake@redhat.com> | 2016-04-05 21:35:03 -0600 |
---|---|---|
committer | Timothy Pearson <tpearson@raptorengineering.com> | 2019-11-29 20:01:35 -0600 |
commit | 9d6eeef7e4694676177a2ef92ba2c57d9157eb57 (patch) | |
tree | fcfa9b671cdfdd9234cd698063fe3794dbfb5a6a /nbd | |
parent | 8c7325cf057346649cecc595c0db856121291a8e (diff) | |
download | hqemu-9d6eeef7e4694676177a2ef92ba2c57d9157eb57.zip hqemu-9d6eeef7e4694676177a2ef92ba2c57d9157eb57.tar.gz |
nbd: Avoid bitrot in TRACE() usage
The compiler is smart enough to optimize out 'if (0)', but won't
type-check our printfs if they are hidden behind #if.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1459913704-19949-3-git-send-email-eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'nbd')
-rw-r--r-- | nbd/nbd-internal.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h index d09b4ee..3791535 100644 --- a/nbd/nbd-internal.h +++ b/nbd/nbd-internal.h @@ -33,18 +33,21 @@ /* #define DEBUG_NBD */ #ifdef DEBUG_NBD -#define TRACE(msg, ...) do { \ - LOG(msg, ## __VA_ARGS__); \ -} while(0) +#define DEBUG_NBD_PRINT 1 #else -#define TRACE(msg, ...) \ - do { } while (0) +#define DEBUG_NBD_PRINT 0 #endif +#define TRACE(msg, ...) do { \ + if (DEBUG_NBD_PRINT) { \ + LOG(msg, ## __VA_ARGS__); \ + } \ +} while (0) + #define LOG(msg, ...) do { \ fprintf(stderr, "%s:%s():L%d: " msg "\n", \ __FILE__, __FUNCTION__, __LINE__, ## __VA_ARGS__); \ -} while(0) +} while (0) /* This is all part of the "official" NBD API. * |