]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/resolve/resolved-dns-synthesize.c
tree-wide: use TAKE_PTR() and TAKE_FD() macros
[thirdparty/systemd.git] / src / resolve / resolved-dns-synthesize.c
index ad38c6a5610c28d249524dcfd78b921d9fcb7ba3..a66f488dd60bcc621ee5573207eabe861f67fa09 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -383,8 +384,7 @@ int dns_synthesize_answer(
                 const char *name;
                 int af;
 
-                if (key->class != DNS_CLASS_IN &&
-                    key->class != DNS_CLASS_ANY)
+                if (!IN_SET(key->class, DNS_CLASS_IN, DNS_CLASS_ANY))
                         continue;
 
                 name = dns_resource_key_name(key);
@@ -423,11 +423,11 @@ int dns_synthesize_answer(
 
                         v = synthesize_system_hostname_ptr(m, af, &address, ifindex, &answer);
                         if (v < 0)
-                                return log_error_errno(r, "Failed to synthesize system hostname PTR RR: %m");
+                                return log_error_errno(v, "Failed to synthesize system hostname PTR RR: %m");
 
                         w = synthesize_gateway_ptr(m, af, &address, ifindex, &answer);
                         if (w < 0)
-                                return log_error_errno(r, "Failed to synthesize gateway hostname PTR RR: %m");
+                                return log_error_errno(w, "Failed to synthesize gateway hostname PTR RR: %m");
 
                         if (v == 0 && w == 0) /* This IP address is neither a local one nor a gateway */
                                 continue;
@@ -440,10 +440,8 @@ int dns_synthesize_answer(
 
         if (found) {
 
-                if (ret) {
-                        *ret = answer;
-                        answer = NULL;
-                }
+                if (ret)
+                        *ret = TAKE_PTR(answer);
 
                 return 1;
         } else if (nxdomain)