Skip to contentSkip to conversation

aic94xx: avoid -Wempty-body warning

PATCH Applied Arnd Bergmann 2 participants 3 messages Mar 22, 2021 – Apr 6, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 aic94xx: avoid -Wempty-body warning

From: Arnd Bergmann <[email protected]>

Building with 'make W=1' shows a harmless -Wempty-body warning:

drivers/scsi/aic94xx/aic94xx_init.c: In function 'asd_free_queues':
drivers/scsi/aic94xx/aic94xx_init.c:858:62: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
858 | ASD_DPRINTK("Uh-oh! Pending is not empty!\n");

Change the empty ASD_DPRINTK() macro to no_printk(), which avoids this warning and adds format string checking.

---
 drivers/scsi/aic94xx/aic94xx.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/aic94xx/aic94xx.h +1 -1
index 98978bc199ff..8f24180646c2 100644
@@ -33,7 +33,7 @@
 #ifdef ASD_DEBUG
 #define ASD_DPRINTK asd_printk
 #else
-#define ASD_DPRINTK(fmt, ...)
+#define ASD_DPRINTK(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
 #endif
 
 /* 2*ITNL timeout + 1 second */
Signature · 1 line
2.29.2
#1 lore raw

PATCH 2/2 scsi: message: fusion: avoid -Wempty-body warnings

From: Arnd Bergmann <[email protected]>

There are a couple of warnings in this driver when building with W=1:

drivers/message/fusion/mptbase.c: In function 'PrimeIocFifos':
drivers/message/fusion/mptbase.c:4608:65: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
4608 | "restoring 64 bit addressing\n", ioc->name));
| ^
drivers/message/fusion/mptbase.c:4633:65: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
4633 | "restoring 64 bit addressing\n", ioc->name));

The macros are slightly suboptimal since are not proper statements. Change both versions to the usual "do { ... } while (0)" style to make them more robust and avoid the warning.

---
 drivers/message/fusion/mptdebug.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/message/fusion/mptdebug.h +4 -3
index 2205dcab0adb..c281b1359419 100644
@@ -67,12 +67,13 @@
 
 #ifdef CONFIG_FUSION_LOGGING
 #define MPT_CHECK_LOGGING(IOC, CMD, BITS)			\
-{								\
+do {								\
 	if (IOC->debug_level & BITS)				\
 		CMD;						\
-}
+} while (0)
 #else
-#define MPT_CHECK_LOGGING(IOC, CMD, BITS)
+#define MPT_CHECK_LOGGING(IOC, CMD, BITS)			\
+do { } while (0)
 #endif
 
 
Signature · 1 line
2.29.2
#2 lore raw
In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

Building with 'make W=1' shows a harmless -Wempty-body warning:

drivers/scsi/aic94xx/aic94xx_init.c: In function 'asd_free_queues':
drivers/scsi/aic94xx/aic94xx_init.c:858:62: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
858 | ASD_DPRINTK("Uh-oh! Pending is not empty!\n");

Change the empty ASD_DPRINTK() macro to no_printk(), which avoids this warning and adds format string checking.

Applied to 5.13/scsi-queue, thanks!

[1/2] aic94xx: avoid -Wempty-body warning

      https://git.kernel.org/mkp/scsi/c/6c26379def09
[2/2] scsi: message: fusion: avoid -Wempty-body warnings
      https://git.kernel.org/mkp/scsi/c/472c1cfb10f1
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering