From 8aa0aa40cf0e6968671a575571f881a861edd018 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 10 Aug 2023 20:13:32 +0900 Subject: [PATCH] udev-builtin-net_id: use strjoin() if possible Addresses the post-merge comment https://github.com/systemd/systemd/pull/28623#pullrequestreview-1571307466. --- src/udev/udev-builtin-net_id.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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", -- 2.47.3