]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd: minor refactoring 20109/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 7 Jul 2021 09:40:16 +0000 (11:40 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 9 Jul 2021 09:11:25 +0000 (11:11 +0200)
src/network/networkd-route.c

index 7b36b481419c89a890adbd31809d23fa7e4770d9..7734c82721e35f354a5fcd0cf74ead992a55d142 100644 (file)
@@ -110,6 +110,7 @@ int manager_get_route_table_from_string(const Manager *m, const char *s, uint32_
 int manager_get_route_table_to_string(const Manager *m, uint32_t table, char **ret) {
         _cleanup_free_ char *str = NULL;
         const char *s;
+        int r;
 
         assert(m);
         assert(ret);
@@ -121,17 +122,13 @@ int manager_get_route_table_to_string(const Manager *m, uint32_t table, char **r
         if (!s)
                 s = hashmap_get(m->route_table_names_by_number, UINT32_TO_PTR(table));
 
-        if (s) {
+        if (s)
                 /* Currently, this is only used in debugging logs. To not confuse any bug
                  * reports, let's include the table number. */
-                if (asprintf(&str, "%s(%" PRIu32 ")", s, table) < 0)
-                        return -ENOMEM;
-
-                *ret = TAKE_PTR(str);
-                return 0;
-        }
-
-        if (asprintf(&str, "%" PRIu32, table) < 0)
+                r = asprintf(&str, "%s(%" PRIu32 ")", s, table);
+        else
+                r = asprintf(&str, "%" PRIu32, table);
+        if (r < 0)
                 return -ENOMEM;
 
         *ret = TAKE_PTR(str);