Subject: Re: [PATCH v6 net-next 1/7] netlink: Add a macro to set policy message with format string

From: Jakub Kicinski <[email-masked]>
Date: Wed, 22 Mar 2023 11:40:41 -0700

On Wed, 22 Mar 2023 14:39:49 +0200 Shay Agroskin wrote:
> > You should use '__extack' even above, to avoid multiple 
> > evaluation of
> > the 'extack' expression.  
> 
> I've got to admit that I don't understand the cost of such 
> evaluations. I thought that it was added to help readers of the 
> source code to understand what is the type of this attribute and 
> have a better warning message when the wrong variable is passed 
> (kind of typing in Python which isn't strictly needed).
> What cost is there for casting a pointer ?

It's not about the cost, the macros are unfolded by the preprocessor,
in the unlikely case someone passes extack++ as an argument using it
twice inside the body of the macro will increment the value twice.

#define MACRO(arg) function_bla(arg, arg) // use arg twice

int a = 1;
MACRO(a++);
print(a); // should print 2, will print 3