]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-builtin-net_id: use strjoin() if possible 28749/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 10 Aug 2023 11:13:32 +0000 (20:13 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 10 Aug 2023 11:13:43 +0000 (20:13 +0900)
Addresses the post-merge comment
https://github.com/systemd/systemd/pull/28623#pullrequestreview-1571307466.

src/udev/udev-builtin-net_id.c

index 298aabe61740df7b06209e97efc5da10fa38301e..d88d4f7dd5e9555d43ce10369cdf453c3bd7229c 100644 (file)
@@ -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",