ip: iplink_bridge_slave: Port over to parse_on_off()

Invoke parse_on_off() from bridge_slave_parse_on_off() instead of
hand-rolling one. Exit on failure, because the invarg that was ivoked here
before would.

Signed-off-by: Petr Machata <me@pmachata.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
Petr Machata 2020-11-14 23:53:58 +01:00 committed by David Ahern
parent 5f685d064b
commit 3e0d2a73ba
1 changed files with 4 additions and 8 deletions

View File

@ -297,15 +297,11 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,
static void bridge_slave_parse_on_off(char *arg_name, char *arg_val,
struct nlmsghdr *n, int type)
{
__u8 val;
if (strcmp(arg_val, "on") == 0)
val = 1;
else if (strcmp(arg_val, "off") == 0)
val = 0;
else
invarg("should be \"on\" or \"off\"", arg_name);
int ret;
__u8 val = parse_on_off(arg_name, arg_val, &ret);
if (ret)
exit(1);
addattr8(n, 1024, type, val);
}