]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkctl: use strextend()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 May 2021 05:28:20 +0000 (14:28 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 May 2021 09:18:56 +0000 (18:18 +0900)
src/network/networkctl.c

index b4e3bfc7ae0619bb298f220efcc370fe66b06a06..9d3e3f033b5601ae1c850054b9c7775e2773ce4f 100644 (file)
@@ -1046,26 +1046,25 @@ static int dump_gateways(
                 return n;
 
         for (int i = 0; i < n; i++) {
-                _cleanup_free_ char *gateway = NULL, *description = NULL, *with_description = NULL;
+                _cleanup_free_ char *gateway = NULL, *description = NULL;
                 char name[IF_NAMESIZE+1];
 
                 r = in_addr_to_string(local[i].family, &local[i].address, &gateway);
                 if (r < 0)
-                        return r;
+                        return log_oom();
 
                 r = get_gateway_description(rtnl, hwdb, local[i].ifindex, local[i].family, &local[i].address, &description);
                 if (r < 0)
                         log_debug_errno(r, "Could not get description of gateway, ignoring: %m");
 
                 if (description) {
-                        with_description = strjoin(gateway, " (", description, ")");
-                        if (!with_description)
+                        if (!strextend(&gateway, " (", description, ")"))
                                 return log_oom();
                 }
 
                 /* Show interface name for the entry if we show entries for all interfaces */
                 r = strv_extendf(&buf, "%s%s%s",
-                                 with_description ?: gateway,
+                                 gateway,
                                  ifindex <= 0 ? " on " : "",
                                  ifindex <= 0 ? format_ifname_full(local[i].ifindex, name, FORMAT_IFNAME_IFINDEX_WITH_PERCENT) : "");
                 if (r < 0)