diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-08-27 19:02:53 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-08-27 19:49:09 +0200 |
commit | ab77c8793bbb63de3c0b693d662f82a2ac65524f (patch) | |
tree | 602cefe13e74ef51c1f8fb6ff34379116db04c70 | |
parent | sd-bus: adjust indentation of comments (diff) | |
download | systemd-ab77c8793bbb63de3c0b693d662f82a2ac65524f.tar.xz systemd-ab77c8793bbb63de3c0b693d662f82a2ac65524f.zip |
resolved: do not run loop twice
This doesn't matter much, but let's just do the loop once and allocate
the populate the result set on the fly. If we find an error, it'll get
cleaned up automatically.
-rw-r--r-- | src/resolve/resolved-link-bus.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/resolve/resolved-link-bus.c b/src/resolve/resolved-link-bus.c index 81ef5ffaa4..4e7685e889 100644 --- a/src/resolve/resolved-link-bus.c +++ b/src/resolve/resolved-link-bus.c @@ -544,6 +544,10 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v if (r < 0) return r; + ns = set_new(&dns_name_hash_ops); + if (!ns) + return -ENOMEM; + r = sd_bus_message_read_strv(message, &ntas); if (r < 0) return r; @@ -553,14 +557,9 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v if (r < 0) return r; if (r == 0) - return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid negative trust anchor domain: %s", *i); - } + return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, + "Invalid negative trust anchor domain: %s", *i); - ns = set_new(&dns_name_hash_ops); - if (!ns) - return -ENOMEM; - - STRV_FOREACH(i, ntas) { r = set_put_strdup(ns, *i); if (r < 0) return r; |