diff options
author | Pierre-Clément Tosi <ptosi@google.com> | 2023-04-03 12:11:04 +0100 |
---|---|---|
committer | Pierre-Clément Tosi <ptosi@google.com> | 2023-04-03 17:19:14 +0100 |
commit | e7a3aab1c9043004e6045e0ddddfaa47ca04653b (patch) | |
tree | 6cf026b8e67faa9cddc3bb79f7362d2bbc01e6e2 | |
parent | b5591fb1763601652754340f293525544e0bf901 (diff) | |
download | avb-e7a3aab1c9043004e6045e0ddddfaa47ca04653b.tar.gz |
util: Refactor AVB_ENABLED_DEBUG gating
De-dup the #if-#else statements; no functional change intended.
Test: -
Change-Id: I478ebcfb4956dab5985040d1c14605915b974a6d
-rw-r--r-- | libavb/avb_util.h | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/libavb/avb_util.h b/libavb/avb_util.h index b6b036e..b51cf52 100644 --- a/libavb/avb_util.h +++ b/libavb/avb_util.h @@ -49,31 +49,16 @@ extern "C" { avb_fatal("assert fail: " #expr "\n"); \ } \ } while (0) -#else -#define avb_assert(expr) -#endif /* Aborts the program if reached. * * This has no effect unless AVB_ENABLE_DEBUG is defined. */ -#ifdef AVB_ENABLE_DEBUG #define avb_assert_not_reached() \ do { \ avb_fatal("assert_not_reached()\n"); \ } while (0) -#else -#define avb_assert_not_reached() -#endif - -/* Aborts the program if |addr| is not word-aligned. - * - * This has no effect unless AVB_ENABLE_DEBUG is defined. - */ -#define avb_assert_aligned(addr) \ - avb_assert((((uintptr_t)addr) & (AVB_ALIGNMENT_SIZE - 1)) == 0) -#ifdef AVB_ENABLE_DEBUG /* Print functions, used for diagnostics. * * These have no effect unless AVB_ENABLE_DEBUG is defined. @@ -97,10 +82,19 @@ extern "C" { ##__VA_ARGS__); \ } while (0) #else +#define avb_assert(expr) +#define avb_assert_not_reached() #define avb_debug(message) #define avb_debugv(message, ...) #endif +/* Aborts the program if |addr| is not word-aligned. + * + * This has no effect unless AVB_ENABLE_DEBUG is defined. + */ +#define avb_assert_aligned(addr) \ + avb_assert((((uintptr_t)addr) & (AVB_ALIGNMENT_SIZE - 1)) == 0) + /* Prints out a message. This is typically used if a runtime-error * occurs. */ |