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

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

 



On Sat, Mar 19, 2022 at 08:25:34AM +0100, Philipp Hortmann wrote:
> 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.

> 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.

> 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)

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
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