[Concept,02/30] tools: Fix debug() to avoid unused-variable warnings

Message ID 20251120025614.2215587-3-sjg@u-boot.org
State New
Headers
Series fit: Improve and test the code to print FIT info |

Commit Message

Simon Glass Nov. 20, 2025, 2:55 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

The debug() macro in mkimage.h expands to nothing when MKIMAGE_DEBUG
is not defined. This causes the compiler to warn about unused variables
that are only referenced in debug() statements.

Fix this using the same approach as the debug_cond() macro.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 tools/mkimage.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
  

Patch

diff --git a/tools/mkimage.h b/tools/mkimage.h
index 5d6bcc9301a..a356d20c3b1 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -25,9 +25,13 @@ 
 #undef MKIMAGE_DEBUG
 
 #ifdef MKIMAGE_DEBUG
-#define debug(fmt,args...)	printf (fmt ,##args)
+#define debug(fmt, args...)	printf(fmt, ##args)
 #else
-#define debug(fmt,args...)
+#define debug(fmt, args...) \
+	do { \
+		if (0) \
+			printf(fmt, ##args); \
+	} while (0)
 #endif /* MKIMAGE_DEBUG */
 
 #define log_debug(fmt, args...)	debug(fmt, ##args)