Re: [PATCH v6 1/2] sunrpc: simplify dprintk macros and cleanup redundant debug guards
From: Andy Shevchenko <hidden>
Date: 2026-03-02 13:27:31
Also in:
linux-nfs, lkml
On Mon, Mar 02, 2026 at 12:17:08AM +0800, Sean Chang 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. Verification with .lst files under -O2 confirms that the compiler successfully performs "dead code elimination". Even when variables (like char buf[] in nfsfh.c) or static helper functions (like nlmdbg_cookie2a in svclock.c) are declared without #ifdef, they are completely optimized out (no stack allocation, no symbol references in the final executable) as they are only referenced within no_printk(). This allows for significant cleanup: - Remove RPC_IFDEBUG() and associated #if blocks in fs/nfsd/nfsfh.c and net/sunrpc/xprtrdma/svc_rdma_transport.c. - Remove the #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) guard around nlmdbg_cookie2a in fs/lockd/svclock.c. - Consolidate the dprintk definition to be more idiomatic. This fixes the build errors reported by the kernel test robot while improving code maintainability.
If you feel something has to be done against nfsd-next, please rebase and send as a standalone patch. -- With Best Regards, Andy Shevchenko