Re: [PATCH v2 1/2] nfs: fix unused variable warnings

From: Sean

Date: Tue Feb 17 2026 - 04:56:04 EST


On Tue, Feb 17, 2026 at 4:06 AM Andrew Lunn <andrew@xxxxxxx> wrote:
>
>
> There is no #ifdef'ery here. How is ptr not used? Is status always
> true, so the goto it always taken? But then rpcdata should also be
> unused?
>

If CONFIG_SUNRPC_DEBUG is not enabled, dprintk expands to
do {} while (0) during preprocessing. This means unsigned *ptr has
no remaining references in the function, as its only 'read' was inside
the macro.

Regarding rpcdata, the compiler's unused-variable check doesn't care if a
specific branch (like the goto out) might skip the variable's usage at runtime.
As long as there is at least one valid code path where the variable is
referenced
which there is for rpcdata in the call to
rpc_clnt_probe_trunked_xprts() -> the warning is avoided.
For ptr, the macro expansion leaves it with zero references in any path.

Best regards,
Sean