Re: [PATCH iproute2-next v2 02/11] lib: Add parse_one_of(), parse_on_off()
From: Petr Machata <hidden>
Date: 2020-10-31 21:25:24
From: Petr Machata <hidden>
Date: 2020-10-31 21:25:24
David Ahern [off-list ref] writes:
On 10/30/20 6:29 AM, Petr Machata wrote:quoted
+int parse_on_off(const char *msg, const char *realval, int *p_err) +{ + static const char * const values_on_off[] = { "off", "on" }; + + return parse_one_of(msg, realval, values_on_off, ARRAY_SIZE(values_on_off), p_err); +}This has weird semantics to me. You have a buried array of strings and returning the index of the one that matches. Let's use a 'bool' return for parse_on_off that makes it clear that the string is 'off' = false or 'on' = true.
Agreed, it should return bool.