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: Thu, 23 Mar 2023 13:34:22 -0700

On Thu, 23 Mar 2023 21:44:52 +0200 Shay Agroskin wrote:
> > That's why we have the local variable called __extack, that we 
> > *can*
> > use multiple times, because it's a separate variable, (extack) 
> > is
> > evaluated only once, to initialize it...
> >
> > We don't need to copy the string formatting, unless I'm missing
> > something. Paolo was just asking for:  
> 
> There is an issue with shadowing __extack by NL_SET_ERR_MSG_FMT 
> causing the changes to __extack not to be propagated back to the 
> caller.
> I'm not that big of an expert in C but changing __extack -> 
> _extack fixes the shadowing issue.
> 
> Might not be the most robust solution, though it might suffice for 
> this use case.

TBH the hierarchy should be the other way around, NL_SET_ERR_MSG_FMT()
should be converted to be:

#define NL_SET_ERR_MSG_FMT(extack, attr, msg, args...) \
	NL_SET_ERR_MSG_ATTR_POL_FMT(extack, NULL, NULL, msg, ##args)

and that'd fix the shadowing, right?