[PATCH v2 3/3] sunrpc: Fix compilation error (`make W=1`) when dprintk() is no-op

Andy Shevchenko posted 3 patches 3 days, 17 hours ago
There is a newer version of this series
[PATCH v2 3/3] sunrpc: Fix compilation error (`make W=1`) when dprintk() is no-op
Posted by Andy Shevchenko 3 days, 17 hours ago
Clang compiler is not happy about set but unused variables:

.../flexfilelayout/flexfilelayoutdev.c:56:9: error: variable 'ret' set but not used [-Werror,-Wunused-but-set-variable]
.../flexfilelayout/flexfilelayout.c:1505:6: error: variable 'err' set but not used [-Werror,-Wunused-but-set-variable]
.../nfs4proc.c:9244:12: error: variable 'ptr' set but not used [-Werror,-Wunused-but-set-variable]

Fix these by forwarding parameters of dprintk() to no_printk().
The positive side-effect is a format-string checker enabled even for the cases
when dprintk() is no-op.

Fixes: d67ae825a59d ("pnfs/flexfiles: Add the FlexFile Layout Driver")
Fixes: fc931582c260 ("nfs41: create_session operation")
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 fs/lockd/svclock.c           | 5 +++++
 include/linux/sunrpc/debug.h | 8 ++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 712df1e025d8..dcd3e0b4d997 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -80,6 +80,11 @@ static const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie)
 
 	return buf;
 }
+#else
+static inline const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie)
+{
+	return "???";
+}
 #endif
 
 /*
diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index e947d668f7b7..82239d5c262e 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -40,6 +40,8 @@ extern unsigned int		nlm_debug;
 do {									\
 	ifdebug(fac)							\
 		__sunrpc_printk(fmt, ##__VA_ARGS__);			\
+	else								\
+		no_printk(fmt, ##__VA_ARGS__);				\
 } while (0)
 
 # define dfprintk_rcu(fac, fmt, ...)					\
@@ -48,13 +50,15 @@ do {									\
 		rcu_read_lock();					\
 		__sunrpc_printk(fmt, ##__VA_ARGS__);			\
 		rcu_read_unlock();					\
+	} else {							\
+		no_printk(fmt, ##__VA_ARGS__);				\
 	}								\
 } while (0)
 
 #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__)
 #endif
 
 /*
-- 
2.50.1
Re: [PATCH v2 3/3] sunrpc: Fix compilation error (`make W=1`) when dprintk() is no-op
Posted by Andy Shevchenko 3 days, 9 hours ago
On Wed, Feb 04, 2026 at 10:41:23AM +0100, Andy Shevchenko wrote:
> Clang compiler is not happy about set but unused variables:
> 
> .../flexfilelayout/flexfilelayoutdev.c:56:9: error: variable 'ret' set but not used [-Werror,-Wunused-but-set-variable]
> .../flexfilelayout/flexfilelayout.c:1505:6: error: variable 'err' set but not used [-Werror,-Wunused-but-set-variable]
> .../nfs4proc.c:9244:12: error: variable 'ptr' set but not used [-Werror,-Wunused-but-set-variable]
> 
> Fix these by forwarding parameters of dprintk() to no_printk().
> The positive side-effect is a format-string checker enabled even for the cases
> when dprintk() is no-op.

I'm afraid this is not end of story...
I received a dozen of minutes ago a new report and now I'm investigating.

Patches 1 & 2 though are ready to go.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 3/3] sunrpc: Fix compilation error (`make W=1`) when dprintk() is no-op
Posted by Andy Shevchenko 3 days, 9 hours ago
On Wed, Feb 04, 2026 at 06:46:36PM +0200, Andy Shevchenko wrote:
> On Wed, Feb 04, 2026 at 10:41:23AM +0100, Andy Shevchenko wrote:
> > Clang compiler is not happy about set but unused variables:
> > 
> > .../flexfilelayout/flexfilelayoutdev.c:56:9: error: variable 'ret' set but not used [-Werror,-Wunused-but-set-variable]
> > .../flexfilelayout/flexfilelayout.c:1505:6: error: variable 'err' set but not used [-Werror,-Wunused-but-set-variable]
> > .../nfs4proc.c:9244:12: error: variable 'ptr' set but not used [-Werror,-Wunused-but-set-variable]
> > 
> > Fix these by forwarding parameters of dprintk() to no_printk().
> > The positive side-effect is a format-string checker enabled even for the cases
> > when dprintk() is no-op.
> 
> I'm afraid this is not end of story...
> I received a dozen of minutes ago a new report and now I'm investigating.
> 
> Patches 1 & 2 though are ready to go.

Okay, if I'm not mistaken the only leftover is the missing tk_pid field due to
conditional inclusion. However, if we do that unconditionally the data structure
won't be expanded (there is a gap of 3 bytes. (Dunno about m68k, there may be
actually +2 bytes due to 2-byte alignment.) The rest of the conditionally included
members seem not being used in dprintk().

That said, removing ifdeffery around tk_pid in struct rpc_task should fix that
problem.

If you can fold this to the patch 3, would be nice:

diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index ccba79ebf893..0dbdf3722537 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -95,10 +95,7 @@ struct rpc_task {
 	int			tk_rpc_status;	/* Result of last RPC operation */
 	unsigned short		tk_flags;	/* misc flags */
 	unsigned short		tk_timeouts;	/* maj timeouts */
-
-#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) || IS_ENABLED(CONFIG_TRACEPOINTS)
 	unsigned short		tk_pid;		/* debugging aid */
-#endif
 	unsigned char		tk_priority : 2,/* Task priority */
 				tk_garb_retry : 2,
 				tk_cred_retry : 2;

Otherwise I can send a new version.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 3/3] sunrpc: Fix compilation error (`make W=1`) when dprintk() is no-op
Posted by Chuck Lever 3 days, 8 hours ago
On 2/4/26 11:58 AM, Andy Shevchenko wrote:
> On Wed, Feb 04, 2026 at 06:46:36PM +0200, Andy Shevchenko wrote:
>> On Wed, Feb 04, 2026 at 10:41:23AM +0100, Andy Shevchenko wrote:
>>> Clang compiler is not happy about set but unused variables:
>>>
>>> .../flexfilelayout/flexfilelayoutdev.c:56:9: error: variable 'ret' set but not used [-Werror,-Wunused-but-set-variable]
>>> .../flexfilelayout/flexfilelayout.c:1505:6: error: variable 'err' set but not used [-Werror,-Wunused-but-set-variable]
>>> .../nfs4proc.c:9244:12: error: variable 'ptr' set but not used [-Werror,-Wunused-but-set-variable]
>>>
>>> Fix these by forwarding parameters of dprintk() to no_printk().
>>> The positive side-effect is a format-string checker enabled even for the cases
>>> when dprintk() is no-op.
>>
>> I'm afraid this is not end of story...
>> I received a dozen of minutes ago a new report and now I'm investigating.
>>
>> Patches 1 & 2 though are ready to go.
> 
> Okay, if I'm not mistaken the only leftover is the missing tk_pid field due to
> conditional inclusion. However, if we do that unconditionally the data structure
> won't be expanded (there is a gap of 3 bytes. (Dunno about m68k, there may be
> actually +2 bytes due to 2-byte alignment.) The rest of the conditionally included
> members seem not being used in dprintk().
> 
> That said, removing ifdeffery around tk_pid in struct rpc_task should fix that
> problem.
> 
> If you can fold this to the patch 3, would be nice:
> 
> diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
> index ccba79ebf893..0dbdf3722537 100644
> --- a/include/linux/sunrpc/sched.h
> +++ b/include/linux/sunrpc/sched.h
> @@ -95,10 +95,7 @@ struct rpc_task {
>  	int			tk_rpc_status;	/* Result of last RPC operation */
>  	unsigned short		tk_flags;	/* misc flags */
>  	unsigned short		tk_timeouts;	/* maj timeouts */
> -
> -#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) || IS_ENABLED(CONFIG_TRACEPOINTS)
>  	unsigned short		tk_pid;		/* debugging aid */
> -#endif
>  	unsigned char		tk_priority : 2,/* Task priority */
>  				tk_garb_retry : 2,
>  				tk_cred_retry : 2;
> 
> Otherwise I can send a new version.

Please send a full series respin, thanks.


-- 
Chuck Lever
Re: [PATCH v2 3/3] sunrpc: Fix compilation error (`make W=1`) when dprintk() is no-op
Posted by Andy Shevchenko 3 days, 6 hours ago
On Wed, Feb 04, 2026 at 01:29:48PM -0500, Chuck Lever wrote:
> On 2/4/26 11:58 AM, Andy Shevchenko wrote:
> > On Wed, Feb 04, 2026 at 06:46:36PM +0200, Andy Shevchenko wrote:

...

> > Otherwise I can send a new version.
> 
> Please send a full series respin, thanks.

v3 has been sent.

-- 
With Best Regards,
Andy Shevchenko