netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2-next 0/3] Change parse_one_of(), parse_on_off() to strcmp()
@ 2023-11-15 15:31 Petr Machata
  2023-11-15 15:31 ` [PATCH iproute2-next 1/3] lib: utils: Switch matches() to returning int again Petr Machata
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Petr Machata @ 2023-11-15 15:31 UTC (permalink / raw)
  To: David Ahern, Stephen Hemminger, netdev; +Cc: Patrisious Haddad, Petr Machata

Library functions parse_one_of() and parse_on_off() were added about three
years ago to unify all the disparate reimplementations of the same basic
idea. It used the matches() function to determine whether a string under
consideration corresponds to one of the patterns. This reflected many,
though not all cases of on/off parsing at the time.

This decision has some odd consequences. In particular, "o" can be used as
a shorthand for "off", which is not obvious, because "o" is the prefix of
both. By sheer luck, the end result actually makes some sense: "on" means
on, anything else either means off or errors out. Similar issues are in
principle also possible for parse_one_of() uses, though currently this does
not come up.

Ideally parse_on_off() would accept the strings "on" and "off" and no
others, likewise for parse_one_of().

Hence this patchset, which renames the existing functions to
parse_one_of_deprecated() and parse_on_off_deprecated(), respectively,
and introduces the new functions in their place, parse_one_of() and
parse_on_off(), which use strcmp() under the hood.

Petr Machata (3):
  lib: utils: Switch matches() to returning int again
  lib: utils: Generalize code of parse_one_of(), parse_on_off()
  lib: utils: Add parse_one_of_deprecated(), parse_on_off_deprecated()

 bridge/link.c            | 48 ++++++++++++++++++++++++++--------------
 bridge/vlan.c            |  4 ++--
 dcb/dcb_ets.c            |  6 +++--
 dcb/dcb_pfc.c            |  5 +++--
 include/utils.h          |  6 ++++-
 ip/iplink.c              | 15 ++++++++-----
 ip/iplink_bridge_slave.c |  2 +-
 ip/ipmacsec.c            | 27 +++++++++++++---------
 ip/ipstats.c             |  3 ++-
 lib/utils.c              | 44 ++++++++++++++++++++++++++++--------
 10 files changed, 109 insertions(+), 51 deletions(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-11-20 22:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-15 15:31 [PATCH iproute2-next 0/3] Change parse_one_of(), parse_on_off() to strcmp() Petr Machata
2023-11-15 15:31 ` [PATCH iproute2-next 1/3] lib: utils: Switch matches() to returning int again Petr Machata
2023-11-15 15:31 ` [PATCH iproute2-next 2/3] lib: utils: Generalize code of parse_one_of(), parse_on_off() Petr Machata
2023-11-15 15:31 ` [PATCH iproute2-next 3/3] lib: utils: Add parse_one_of_deprecated(), parse_on_off_deprecated() Petr Machata
2023-11-15 15:57   ` Stephen Hemminger
2023-11-15 15:59   ` Stephen Hemminger
2023-11-15 16:57     ` Petr Machata
2023-11-20 22:27       ` David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).