]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/resolve/resolved-dnssd.c
coccinelle: make use of SYNTHETIC_ERRNO
[thirdparty/systemd.git] / src / resolve / resolved-dnssd.c
index db589f4436040d5d40291e7006a662a184ecc802..ea96255dc1980b79845e963ee8fdc4bd731027b1 100644 (file)
@@ -1,21 +1,3 @@
-/***
-  This file is part of systemd.
-
-  Copyright 2017 Dmitry Rozhkov
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
 
 #include "conf-files.h"
 #include "conf-parser.h"
@@ -29,7 +11,7 @@ const char* const dnssd_service_dirs[] = {
         "/etc/systemd/dnssd",
         "/run/systemd/dnssd",
         "/usr/lib/systemd/dnssd",
-#ifdef HAVE_SPLIT_USR
+#if HAVE_SPLIT_USR
         "/lib/systemd/dnssd",
 #endif
     NULL
@@ -179,7 +161,7 @@ int dnssd_render_instance_name(DnssdService *s, char **ret_name) {
         static const Specifier specifier_table[] = {
                 { 'b', specifier_boot_id,         NULL },
                 { 'H', specifier_dnssd_host_name, NULL },
-                { 'm', specifier_machine_id, NULL },
+                { 'm', specifier_machine_id,      NULL },
                 { 'v', specifier_kernel_release,  NULL },
                 {}
         };
@@ -193,13 +175,12 @@ int dnssd_render_instance_name(DnssdService *s, char **ret_name) {
         if (r < 0)
                 return log_debug_errno(r, "Failed to replace specifiers: %m");
 
-        if (!dns_service_name_is_valid(name)) {
-                log_debug("Service instance name '%s' is invalid.", name);
-                return -EINVAL;
-        }
+        if (!dns_service_name_is_valid(name))
+                return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
+                                       "Service instance name '%s' is invalid.",
+                                       name);
 
-        *ret_name = name;
-        name = NULL;
+        *ret_name = TAKE_PTR(name);
 
         return 0;
 }
@@ -319,8 +300,7 @@ int dnssd_txt_item_new_from_string(const char *key, const char *value, DnsTxtIte
         }
         i->length = length;
 
-        *ret_item = i;
-        i = NULL;
+        *ret_item = TAKE_PTR(i);
 
         return 0;
 }
@@ -345,8 +325,7 @@ int dnssd_txt_item_new_from_data(const char *key, const void *data, const size_t
         }
         i->length = length;
 
-        *ret_item = i;
-        i = NULL;
+        *ret_item = TAKE_PTR(i);
 
         return 0;
 }