Re: [PATCH v4 1/2] sunrpc: fix unused variable warnings by using no_printk

From
Chuck Lever <cel@kernel.org>
Date
2026-02-27 15:59:12
Also in
linux-nfs, lkml
Reply to
Sean Chang, 2026-02-27

On Fri, Feb 27, 2026, at 10:26 AM, Sean Chang wrote:
quoted hunk ↗ jump to hunk
When CONFIG_SUNRPC_DEBUG is disabled, the dfprintk() macros currently
expand to empty do-while loops. This causes variables used solely
within these calls to appear unused, triggering -Wunused-variable
warnings.

Instead of marking every affected variable with __maybe_unused,
update the dfprintk and dfprintk_rcu stubs to use no_printk().
This allows the compiler to see the variables and perform type
checking without emitting any code, thus silencing the warnings
globally for these macros.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Sean Chang <redacted>
---
 include/linux/sunrpc/debug.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index eb4bd62df319..55c54df8bc7d 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -52,8 +52,8 @@ do {									\
 # define RPC_IFDEBUG(x)		x
 #else
 # define ifdebug(fac)		if (0)
-# define dfprintk(fac, fmt, ...)	do {} while (0)
-# define dfprintk_rcu(fac, fmt, ...)	do {} while (0)
+# define dfprintk(fac, fmt, ...)	no_printk(fmt, ##__VA_ARGS__)
+# define dfprintk_rcu(fac, fmt, ...)	no_printk(fmt, ##__VA_ARGS__)
 # define RPC_IFDEBUG(x)
 #endif
-- 
2.34.1
Seems obviously good to me.

Reviewed-by: Chuck Lever <redacted>


-- 
Chuck Lever
Thread (12 messages) 12 messages, 4 authors, last reply 2026-03-01
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help