driver-core: use 'dev' argument in dev_dbg_ratelimited stub
PATCH 1/1 driver-core: use 'dev' argument in dev_dbg_ratelimited stub
dev_dbg_ratelimited() is a macro that ignores its first argument when DEBUG is not set, which can lead to unused variable warnings:
ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_sdq_handle':ethernet/mellanox/mlxsw/pci.c:646:18: warning: unused variable 'pdev' [-Wunused-variable] ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_rdq_handle':ethernet/mellanox/mlxsw/pci.c:671:18: warning: unused variable 'pdev' [-Wunused-variable]
The macro already ensures that all its other arguments are silently ignored by the compiler without triggering a warning, through the use of the no_printk() macro, but the dev argument is not passed into that.
This changes the definition to use the same trick as no_printk() with an if(0) that leads the compiler to not evaluate the side-effects but still see that 'dev' might not be unused.
--- include/linux/device.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
include/linux/device.h +5 -2
@@ -1293,8 +1293,11 @@ do { \ dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ } while (0) #else -#define dev_dbg_ratelimited (dev, fmt, ...) \ - no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#define dev_dbg_ratelimited (dev, fmt, ...) \ +do { \ + if (0) \ + dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ +} while (0)#endif #ifdef VERBOSE_DEBUG
Signature · 1 line
2.7.0
Quoted 13 lines · Arnd Bergmann
dev_dbg_ratelimited()is a macro that ignores its first argument when DEBUG is not set, which can lead to unused variable warnings:
ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_sdq_handle':ethernet/mellanox/mlxsw/pci.c:646:18: warning: unused variable 'pdev' [-Wunused-variable]ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_rdq_handle':ethernet/mellanox/mlxsw/pci.c:671:18: warning: unused variable 'pdev' [-Wunused-variable]The macro already ensures that all its other arguments are silently ignored by the compiler without triggering a warning, through the use of the
no_printk()macro, but the dev argument is not passed into that.
Quoted 7 lines
This changes the definition to use the same trick as
no_printk()with an if(0) that leads the compiler to not evaluate the side-effects but still see that 'dev' might not be unused.Signed-off-by Arnd Bergmann <[email protected]>Suggested-by Andrew Lunn <[email protected]>Fixes 6f586e663e3b ("driver-core: Shut up dev_dbg_reatelimited() without DEBUG")
Quoted 25 lines
--- include/linux/device.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)include/linux/device.h +5
-2@@ -1293,8 +1293,11 @@ do { \ dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ } while (0) #else -#define dev_dbg_ratelimited (dev, fmt, ...) \ - no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#define dev_dbg_ratelimited (dev, fmt, ...) \ +do { \ + if (0) \ + dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ +} while (0)#endif #ifdef VERBOSE_DEBUG Signature · 1 line
2.7.0
Signature · 1 line
Dmitry