Thread (34 messages) 34 messages, 2 authors, 2d ago

Re: [PATCH v6 23/24] dyndbg: change __dynamic_func_call_cls* macros into expressions

From: sashiko-bot@kernel.org
Date: 2026-07-08 02:41:50
Also in: dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] API Consistency / Build Breakage Trap: Dynamic debug wrappers evaluate to int when enabled but void when disabled
--
--- Patch [23]: [PATCH v6 23/24] dyndbg: change __dynamic_func_call_cls* macros into expressions ---
commit 003daac5c2950ded79f06209b5d0ab4dfeb11a5a
Author: Jim Cromie [off-list ref]

dyndbg: change __dynamic_func_call_cls* macros into expressions

This patch modifies the __dynamic_func_call_cls* macros to use statement
expressions instead of do-while loops, allowing them to return 0. It also
updates the fallback dynamic_hex_dump() macro to ensure it behaves
consistently by returning 0, allowing debug macros to be used inside
conditional expressions.
quoted hunk ↗ jump to hunk
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index 355f2cb117334..8822f9a3605f6 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -238,24 +238,26 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
  * (|_cls):	adds in _DPRINT_CLASS_DFLT as needed
  * (|_no_desc):	former gets callsite descriptor as 1st arg (for prdbgs)
  */
-#define __dynamic_func_call_cls(id, cls, fmt, func, ...) do {	\
+#define __dynamic_func_call_cls(id, cls, fmt, func, ...) ({	\
 	DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt);	\
 	if (DYNAMIC_DEBUG_BRANCH(id)) {				\
 		func(&id, ##__VA_ARGS__);			\
 		__dynamic_dump_stack(id);			\
 	}							\
-} while (0)
+	0; /* match no_printk return value */			\
+})
[Severity: Low]
Does this introduce a build breakage trap for configurations where
CONFIG_DYNAMIC_DEBUG is disabled?

While this macro now evaluates to an int (0) when enabled, the fallback
macros used when dynamic debug is disabled often evaluate to void.

For example, dev_dbg() falls back to dev_no_printk(), which evaluates to void:

include/linux/dev_printk.h:
#define dev_no_printk(level, dev, fmt, ...) 				\
	({								\
		if (0)							\
			_dev_printk(level, dev, fmt, ##__VA_ARGS__);	\
	})

Similarly, drm_dbg() falls back to the __drm_dev_dbg() function which returns
void, and print_hex_dump_debug() falls back to a void inline function.

If a driver developer uses these macros in a boolean expression (such as
if (cond && dev_dbg(...))), it will compile successfully during development
with CONFIG_DYNAMIC_DEBUG enabled, but will break the build with an invalid
operands to binary && error when compiled without dynamic debugging.

Could the fallback macros be updated to consistently return 0 as well to
prevent this mismatch?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260707-dd-maint-2-v6-0-381f3edb0045@gmail.com?part=23
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help