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

From: David Laight <[email-masked]>
Date: Fri, 27 Feb 2026 17:38:14 +0000

On Fri, 27 Feb 2026 23:26:23 +0800
Sean Chang <[email-masked]> 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 <[email-masked]>
> Signed-off-by: Sean Chang <[email-masked]>
> ---
>  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