Thread (27 messages) 27 messages, 4 authors, 2020-11-05

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

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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help