[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220824154636.2368afb3@kernel.org>
Date: Wed, 24 Aug 2022 15:46:36 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Johannes Berg <johannes@...solutions.net>
Cc: davem@...emloft.net, netdev@...r.kernel.org, edumazet@...gle.com,
pabeni@...hat.com, mkubecek@...e.cz
Subject: Re: [PATCH net-next 3/6] genetlink: add helper for checking
required attrs and use it in devlink
On Wed, 24 Aug 2022 21:44:22 +0200 Johannes Berg wrote:
> On Tue, 2022-08-23 at 21:50 -0700, Jakub Kicinski wrote:
> >
> > +/* Report that a root attribute is missing */
> > +#define GENL_REQ_ATTR_CHECK(info, attr) ({ \
> > + struct genl_info *__info = (info); \
> > + u32 __attr = (attr); \
> > + int __retval; \
> > + \
> > + __retval = !__info->attrs[__attr]; \
> > + if (__retval) \
> > + NL_SET_ERR_ATTR_MISS(__info->extack, \
> > + __info->userhdr ? : __info->genlhdr, \
> > + __attr); \
> > + __retval; \
> > +})
>
> Not sure this needs to be a macro btw, could be an inline returning a
> bool? You're not really expanding anything here, nor doing something
> with strings (unlike GENL_SET_ERR_MSG for example.)
Initially I typed up both flavors with and without the message
but I dropped the _MSG() one since I didn't find a strong enough
reason to use it.
If we do get the _MSG() version at some point (perhaps to preserve
an existing message during conversion?) having different case
would seem off.
I have no opinion which way is better, LMK if you prefer lower case
(ignoring existing non-MSG helpers being upper case) and I'll sed thru
the patches, no problem at all.
Powered by blists - more mailing lists