daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
Brian Stinson 2593d8
From d95afbca80cf52f0bc84b2e1b4af6aadda007138 Mon Sep 17 00:00:00 2001
4bff0a
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
4bff0a
Date: Tue, 27 Aug 2019 19:02:53 +0200
4bff0a
Subject: [PATCH] resolved: do not run loop twice
4bff0a
4bff0a
This doesn't matter much, but let's just do the loop once and allocate
4bff0a
the populate the result set on the fly. If we find an error, it'll get
4bff0a
cleaned up automatically.
4bff0a
4bff0a
Related: #1746857
4bff0a
---
4bff0a
 src/resolve/resolved-link-bus.c | 13 ++++++-------
4bff0a
 1 file changed, 6 insertions(+), 7 deletions(-)
4bff0a
4bff0a
diff --git a/src/resolve/resolved-link-bus.c b/src/resolve/resolved-link-bus.c
4bff0a
index b1581740d8..46d2b11636 100644
4bff0a
--- a/src/resolve/resolved-link-bus.c
4bff0a
+++ b/src/resolve/resolved-link-bus.c
4bff0a
@@ -492,6 +492,10 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
4bff0a
         if (r < 0)
4bff0a
                 return r;
4bff0a
 
4bff0a
+        ns = set_new(&dns_name_hash_ops);
4bff0a
+        if (!ns)
4bff0a
+                return -ENOMEM;
4bff0a
+
4bff0a
         r = sd_bus_message_read_strv(message, &ntas);
4bff0a
         if (r < 0)
4bff0a
                 return r;
4bff0a
@@ -501,14 +505,9 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
4bff0a
                 if (r < 0)
4bff0a
                         return r;
4bff0a
                 if (r == 0)
4bff0a
-                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid negative trust anchor domain: %s", *i);
4bff0a
-        }
4bff0a
+                        return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS,
4bff0a
+                                                 "Invalid negative trust anchor domain: %s", *i);
4bff0a
 
4bff0a
-        ns = set_new(&dns_name_hash_ops);
4bff0a
-        if (!ns)
4bff0a
-                return -ENOMEM;
4bff0a
-
4bff0a
-        STRV_FOREACH(i, ntas) {
4bff0a
                 r = set_put_strdup(ns, *i);
4bff0a
                 if (r < 0)
4bff0a
                         return r;