[PATCH 3/5] log: Fix up debug_cond() when LOG is enabled

Simon Glass sjg at chromium.org
Mon Mar 22 06:13:09 CET 2021


At present debug() statements can cause debuf output to appear when LOG is
enabled but DEBUG is not. This is not intended and it seems that the
condition is wrong.

Fix it.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 include/log.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/log.h b/include/log.h
index ed7ba6d705a..f5288c549b8 100644
--- a/include/log.h
+++ b/include/log.h
@@ -234,11 +234,14 @@ int _log_buffer(enum log_category_t cat, enum log_level_t level,
 #define _SPL_BUILD	0
 #endif
 
-#if !_DEBUG && CONFIG_IS_ENABLED(LOG)
+#if CONFIG_IS_ENABLED(LOG)
 
-#define debug_cond(cond, fmt, args...)			\
-({							\
-	log(LOG_CATEGORY, LOGL_DEBUG, fmt, ##args);	\
+#define debug_cond(cond, fmt, args...)					\
+({									\
+	if (cond)							\
+		log(LOG_CATEGORY,					\
+		    (enum log_level_t)(LOGL_FORCE_DEBUG | _LOG_DEBUG),	\
+		    fmt, ##args);					\
 })
 
 #else /* _DEBUG */
-- 
2.31.0.rc2.261.g7f71774620-goog



More information about the U-Boot mailing list