What to do with macros with do while (0) body
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
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Quoted 6 lines · Philipp Hortmann
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?
Yes.
Quoted 6 lines
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?
Making it a function please.
Quoted 10 lines
CHECK: Avoid CamelCase: <
MACvWriteCRC16_128>
#864: FILE:drivers/staging/vt6655/mac.h:864:
+#defineMACvWriteCRC16_128(iobase, byRegOfs, wCRC)\CHECK: Avoid CamelCase: <wCRC>
#864: FILE:drivers/staging/vt6655/mac.h:864:
+#defineMACvWriteCRC16_128(iobase, byRegOfs, wCRC)\CHECK: Macro argument reuse 'iobase' - possible side-effects? #864: FILE:
drivers/staging/vt6655/mac.h:864:
Review
Quoted 6 lines
(quoted diff) +6
-0+#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)
checkpatch is right here, this is a horrid macro and can cause problems if used incorrectly. Make this a function.
thanks,
greg k-h
_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies