From c58bd76a6af673196ad283131cbe3edcf2bf6291 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Fri, 11 Nov 2016 12:58:41 -0500 Subject: tree-wide: make invocations of extract_first_word more uniform (#4627) extract_first_words deals fine with the string being NULL, so drop the upfront check for that. --- src/resolve/resolved-link.c | 61 ++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) (limited to 'src/resolve') diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c index 13e1f91192..e7e5c5f5a7 100644 --- a/src/resolve/resolved-link.c +++ b/src/resolve/resolved-link.c @@ -997,6 +997,7 @@ int link_load_user(Link *l) { *ntas = NULL; ResolveSupport s; + const char *p; int r; assert(l); @@ -1037,48 +1038,40 @@ int link_load_user(Link *l) { /* If we can't recognize the DNSSEC setting, then set it to invalid, so that the daemon default is used. */ l->dnssec_mode = dnssec_mode_from_string(dnssec); - if (servers) { - const char *p = servers; + for (p = servers;;) { + _cleanup_free_ char *word = NULL; - for (;;) { - _cleanup_free_ char *word = NULL; - - r = extract_first_word(&p, &word, NULL, 0); - if (r < 0) - goto fail; - if (r == 0) - break; + r = extract_first_word(&p, &word, NULL, 0); + if (r < 0) + goto fail; + if (r == 0) + break; - r = link_update_dns_server_one(l, word); - if (r < 0) { - log_debug_errno(r, "Failed to load DNS server '%s', ignoring: %m", word); - continue; - } + r = link_update_dns_server_one(l, word); + if (r < 0) { + log_debug_errno(r, "Failed to load DNS server '%s', ignoring: %m", word); + continue; } } - if (domains) { - const char *p = domains; + for (p = domains;;) { + _cleanup_free_ char *word = NULL; + const char *n; + bool is_route; - for (;;) { - _cleanup_free_ char *word = NULL; - const char *n; - bool is_route; - - r = extract_first_word(&p, &word, NULL, 0); - if (r < 0) - goto fail; - if (r == 0) - break; + r = extract_first_word(&p, &word, NULL, 0); + if (r < 0) + goto fail; + if (r == 0) + break; - is_route = word[0] == '~'; - n = is_route ? word + 1 : word; + is_route = word[0] == '~'; + n = is_route ? word + 1 : word; - r = link_update_search_domain_one(l, n, is_route); - if (r < 0) { - log_debug_errno(r, "Failed to load search domain '%s', ignoring: %m", word); - continue; - } + r = link_update_search_domain_one(l, n, is_route); + if (r < 0) { + log_debug_errno(r, "Failed to load search domain '%s', ignoring: %m", word); + continue; } } -- cgit v1.2.3-54-g00ecf