From: Yu Watanabe Date: Thu, 10 Aug 2023 11:13:32 +0000 (+0900) Subject: udev-builtin-net_id: use strjoin() if possible X-Git-Tag: v255-rc1~758^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F28749%2Fhead;p=thirdparty%2Fsystemd.git udev-builtin-net_id: use strjoin() if possible Addresses the post-merge comment https://github.com/systemd/systemd/pull/28623#pullrequestreview-1571307466. --- diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 298aabe6174..d88d4f7dd5e 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -248,7 +248,8 @@ static int get_port_specifier(sd_device *dev, bool fallback_to_dev_id, char **re } /* Otherwise, use phys_port_name as is. */ - if (asprintf(&buf, "n%s", phys_port_name) < 0) + buf = strjoin("n", phys_port_name); + if (!buf) return log_oom_debug(); *ret = buf; @@ -947,10 +948,10 @@ static int get_usb_specifier(sd_device *dev, char **ret) { if (streq(interf, "0")) interf = NULL; - if (asprintf(&buf, "u%s%s%s%s%s", - ports, - config ? "c" : "", strempty(config), - interf ? "i" : "", strempty(interf)) < 0) + buf = strjoin("u", ports, + config ? "c" : "", strempty(config), + interf ? "i" : "", strempty(interf)); + if (!buf) return log_oom_debug(); log_device_debug(dev, "USB name identifier: ports=%s config=%s interface=%s %s %s",