Re: surround complex macros in ()

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

 



On Wed, Aug 25, 2021 at 10:21:44PM -0700, daniel watson wrote:
> let me know if this is the right place to ask.
> 
> i recently tried to make a commit adding parentheses around a macro
> value.
> 
> https://lore.kernel.org/linux-staging/20210817043038.GA9492@xxxxxxxxxxxxxxxxx/
> 
> it was rejected as "This is not a real change that is needed."
> 
> at first, i thought this meant that the code would be identical with and
> without parentheses surrounding a complex macro's definition, when the
> macro is just typecasting an expression.  but then i came up with code
> where having parens or not changes the meaning of the code.
> 
> -------delete-me.c--------
> #define with ((int)a)
> #define sans (int)a

Note, this is NOT what your change was doing.

To duplicate what your change wanted to do, try doing:

#define with ((int)(10 * 20))
#define sans (int)(10 * 20)

Now see if that is any different when you use it.

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