]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
log: make debug_cond() function like
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 4 Jan 2021 07:02:53 +0000 (08:02 +0100)
committerTom Rini <trini@konsulko.com>
Sun, 17 Jan 2021 00:17:11 +0000 (19:17 -0500)
Change debug_cond() such that it can be used instead of a function like
debug().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
include/log.h

index 6bce5606489aa62be359b52e4f917ba29bbc8c53..40ab551f375ef2292c314091c7192b8ae5e4f67c 100644 (file)
@@ -217,10 +217,9 @@ static inline int _log_nop(enum log_category_t cat, enum log_level_t level,
 #if !_DEBUG && CONFIG_IS_ENABLED(LOG)
 
 #define debug_cond(cond, fmt, args...)                 \
-       do {                                            \
-               if (1)                                  \
-                       log(LOG_CATEGORY, LOGL_DEBUG, fmt, ##args); \
-       } while (0)
+({                                                     \
+       log(LOG_CATEGORY, LOGL_DEBUG, fmt, ##args);     \
+})
 
 #else /* _DEBUG */
 
@@ -229,11 +228,11 @@ static inline int _log_nop(enum log_category_t cat, enum log_level_t level,
  * computed by a preprocessor in the best case, allowing for the best
  * optimization.
  */
-#define debug_cond(cond, fmt, args...)                 \
-       do {                                            \
-               if (cond)                               \
-                       printf(pr_fmt(fmt), ##args);    \
-       } while (0)
+#define debug_cond(cond, fmt, args...)         \
+({                                             \
+       if (cond)                               \
+               printf(pr_fmt(fmt), ##args);    \
+})
 
 #endif /* _DEBUG */