# 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 
- List: netdev
- Page: https://ratatoskr.run/netdev/2026/02/3431447
- Thread: https://ratatoskr.run/netdev/2026/02/3431210/t.md

```text
On Fri, 27 Feb 2026 23:26:23 +0800
Sean Chang [ref] wrote:

> 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
>  

```
