]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostnamed: trivial optimization
authorLennart Poettering <lennart@poettering.net>
Thu, 3 Feb 2022 16:19:32 +0000 (17:19 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 3 Feb 2022 22:51:51 +0000 (22:51 +0000)
src/hostname/hostnamed.c

index a60e0f8295895d08c8a25008e1043fcfdec8dce2..0a922ec494278ec289fb0bfa80ceddbc818ed27f 100644 (file)
@@ -185,15 +185,16 @@ static int get_dmi_data(const char *database_key, const char *regular_key, char
         if (!s && regular_key)
                 (void) sd_device_get_property_value(device, regular_key, &s);
 
+        if (!ret)
+                return !!s;
+
         if (s) {
                 b = strdup(s);
                 if (!b)
                         return -ENOMEM;
         }
 
-        if (ret)
-                *ret = TAKE_PTR(b);
-
+        *ret = TAKE_PTR(b);
         return !!s;
 }