From: Yu Watanabe Date: Thu, 20 May 2021 05:28:20 +0000 (+0900) Subject: networkctl: use strextend() X-Git-Tag: v249-rc1~182^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4ff6ff9a91ce114e2f841a6cda59fbae81afe5e0;p=thirdparty%2Fsystemd.git networkctl: use strextend() --- diff --git a/src/network/networkctl.c b/src/network/networkctl.c index b4e3bfc7ae0..9d3e3f033b5 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -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)