What to do with macros with do while (0) body

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

please support me in what to do with the below macro as checkpatch seems to hate them.

In this case the macro is unused. Just remove macro?

When the macro is used how to remove this checkpatch message:
CHECK: Macro argument reuse 'iobase' - possible side-effects?
Even when iobase is just used in this macro this message does not go away.

I do prefer to make a function out of such macros but what is kernel standard?

CHECK: Avoid CamelCase: <MACvWriteCRC16_128>
#864: FILE: drivers/staging/vt6655/mac.h:864:
+#define MACvWriteCRC16_128(iobase, byRegOfs, wCRC)		\

CHECK: Avoid CamelCase: <wCRC>
#864: FILE: drivers/staging/vt6655/mac.h:864:
+#define MACvWriteCRC16_128(iobase, byRegOfs, wCRC)		\

CHECK: Macro argument reuse 'iobase' - possible side-effects?
#864: FILE: drivers/staging/vt6655/mac.h:864:
+#define MACvWriteCRC16_128(iobase, byRegOfs, wCRC)		\
+do {								\
+	VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1);		\
+	VNSvOutPortW(iobase + byRegOfs, wCRC);		\
+	VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 0);		\
+} while (0)

CHECK: Macro argument 'iobase' may be better as '(iobase)' to avoid precedence issues
#864: FILE: drivers/staging/vt6655/mac.h:864:
+#define MACvWriteCRC16_128(iobase, byRegOfs, wCRC)		\
+do {								\
+	VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1);		\
+	VNSvOutPortW(iobase + byRegOfs, wCRC);		\
+	VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 0);		\
+} while (0)

CHECK: Macro argument 'byRegOfs' may be better as '(byRegOfs)' to avoid precedence issues
#864: FILE: drivers/staging/vt6655/mac.h:864:
+#define MACvWriteCRC16_128(iobase, byRegOfs, wCRC)		\
+do {								\
+	VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1);		\
+	VNSvOutPortW(iobase + byRegOfs, wCRC);		\
+	VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 0);		\
+} while (0)

Thanks for your support.

Bye Philipp

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux