From 0eb25f1d62a910aa7e2e2b871f9eee659557e7a7 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Tue, 4 Aug 2020 11:32:34 -0600 Subject: [PATCH] interface file: simplify scanning iface directives for relevant keywords --- libifupdown/interface-file.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libifupdown/interface-file.c b/libifupdown/interface-file.c index c451d47..4d6f63a 100644 --- a/libifupdown/interface-file.c +++ b/libifupdown/interface-file.c @@ -82,18 +82,16 @@ lif_interface_file_parse(struct lif_dict *collection, const char *filename) * or "inet dhcp" or such to designate hints. lets pick up * those hints here. */ - char *inet_type = lif_next_token(&bufp); - if (!*inet_type) - continue; - - char *hint = lif_next_token(&bufp); - if (!*hint) - continue; - - if (!strcmp(hint, "dhcp")) + char *token = lif_next_token(&bufp); + while (*token) { - cur_iface->is_dhcp = true; - lif_dict_add(&cur_iface->vars, "use", strdup("dhcp")); + if (!strcmp(token, "dhcp")) + { + cur_iface->is_dhcp = true; + lif_dict_add(&cur_iface->vars, "use", strdup("dhcp")); + } + + token = lif_next_token(&bufp); } } else if (!strcmp(token, "use"))