[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0ba73aaa-8fc5-d6ef-d106-b49844740df8@gmail.com>
Date: Wed, 23 Jan 2019 17:27:45 -0700
From: David Ahern <dsahern@...il.com>
To: Aya Levin <ayal@...lanox.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"David S. Miller" <davem@...emloft.net>,
Jiri Pirko <jiri@...lanox.com>
Cc: Moshe Shemesh <moshe@...lanox.com>,
Eran Ben Elisha <eranbe@...lanox.com>,
Tal Alon <talal@...lanox.com>,
Ariel Almog <ariela@...lanox.com>
Subject: Re: [PATCH iproute2-next v2] devlink: Add health command support
On 1/23/19 4:27 AM, Aya Levin wrote:
>>> @@ -1298,6 +1322,12 @@ static int dl_argv_parse(struct dl *dl, uint32_t o_required,
>>> return -EINVAL;
>>> }
>>>
>>> + if ((o_required & DL_OPT_HEALTH_REPORTER_NAME) &&
>>> + !(o_found & DL_OPT_HEALTH_REPORTER_NAME)) {
>>> + pr_err("Reporter name expected.\n");
>>> + return -EINVAL;
>>> + }
>>
>> I realize your are following suit with this change, but these checks for
>> 'required and not found' are getting really long. There is a better way
>> to do this.
> Do you mean somthing like:
> #define requiered_not_found(o_found, o_required, flag, msg) \
> ({ \
> if ((o_required & flag) && !(o_found & flag)) { \
> pr_err("%s \n", msg); \
> return -EINVAL; \
> } \
> })
>
That's one way.
I was also thinking a helper that does a single loop with an array of
bits and messages to print if required and not found.
That parse function is currently 355 lines long with a lot of repetition.
Powered by blists - more mailing lists