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

From
David Laight <hidden>
Date
2026-02-27 17:38:17
Also in
linux-nfs, lkml
Reply to
Sean Chang, 2026-02-27
On Fri, 27 Feb 2026 23:26:23 +0800
Sean Chang [off-list ref] 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__)
You can omit fmt, then you don't need the ##
#define dfprintk(fac, ...)	no_printk(__VA_ARGS__)

	David
 # define RPC_IFDEBUG(x)
 #endif
 
  
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