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

From
Sean <hidden>
Date
2026-02-17 09:55:56
Also in
linux-nfs, lkml
Reply to
Andrew Lunn, 2026-02-16
On Tue, Feb 17, 2026 at 4:06 AM Andrew Lunn [off-list ref] 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
Thread (11 messages) 11 messages, 2 authors, last reply 2026-02-18
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