Re: [PATCH v5 1/2] sunrpc: simplify dfprintk macros and fix nfsd build error

From: Geert Uytterhoeven

Date: Mon Mar 02 2026 - 04:41:19 EST


Hi Sean,

On Sat, 28 Feb 2026 at 22:29, Sean Chang <seanwascoding@xxxxxxxxx> 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.
>
> Following David Laight's suggestion, simplify the macro definitions by
> removing the unnecessary 'fmt' argument and using no_printk(__VA_ARGS__)
> directly. This ensures the compiler performs type checking and "sees"
> the variables, silencing the warnings without emitting any code.
>
> Additionally, fix a build error in fs/nfsd/nfsfh.c reported by syzbot.
> In nfsd_setuser_and_check_port(), the variable 'buf' is conditionally
> defined via RPC_IFDEBUG. Since no_printk() now performs type checking,
> it triggers an 'undeclared identifier' error when debug is disabled.
> Wrap the dprintk call in an #if block to synchronize its lifecycle
> with 'buf', following the pattern in svc_rdma_transport.c.
>
> Link: https://lore.kernel.org/all/69a2e269.050a0220.3a55be.003e.GAE@xxxxxxxxxx/
> Suggested-by: Andrew Lunn <andrew@xxxxxxx>
> Suggested-by: David Laight <david.laight.linux@xxxxxxxxx>
> Signed-off-by: Sean Chang <seanwascoding@xxxxxxxxx>

This should have been fixed alteady, cfr.
"Re: [PATCH v3 0/3] sunrpc: Fix `make W=1` build issues"?
https://lore.kernel.org/177024270291.126397.9981743455921781902.b4-ty@xxxxxxxxxx

> ---
> fs/nfsd/nfsfh.c | 2 ++
> include/linux/sunrpc/debug.h | 4 ++--
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
> index ed85dd43da18..f7386fd483a6 100644
> --- a/fs/nfsd/nfsfh.c
> +++ b/fs/nfsd/nfsfh.c
> @@ -106,8 +106,10 @@ static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp,
> /* Check if the request originated from a secure port. */
> if (rqstp && !nfsd_originating_port_ok(rqstp, cred, exp)) {
> RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
> +#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
> dprintk("nfsd: request from insecure port %s!\n",
> svc_print_addr(rqstp, buf, sizeof(buf)));
> +#endif
> return nfserr_perm;
> }
>
> diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
> index eb4bd62df319..cb33c7e1f370 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, ...) no_printk(__VA_ARGS__)
> +# define dfprintk_rcu(fac, ...) no_printk(__VA_ARGS__)
> # define RPC_IFDEBUG(x)
> #endif

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds