Re: [PATCH v4 1/2] sunrpc: fix unused variable warnings by using no_printk
From: Andrew Lunn
Date: Fri Feb 27 2026 - 13:08:05 EST
> > # 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__)
>
> You can omit fmt, then you don't need the ##
> #define dfprintk(fac, ...) no_printk(__VA_ARGS__)
/*
* Dummy printk for disabled debugging statements to use whilst maintaining
* gcc's format checking.
*/
#define no_printk(fmt, ...) \
({ \
if (0) \
_printk(fmt, ##__VA_ARGS__); \
0; \
})
Without fmt, gcc cannot do format checking. Or worse, it takes the
first member of __VA_ARGS__ as the format, and gives spurious errors?
Andrew