surround complex macros in ()

Greg KH greg at kroah.com
Thu Aug 26 03:28:22 EDT 2021


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@challenge-bot.com/
> 
> 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



More information about the Kernelnewbies mailing list