]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-builtin-net_id: use sd_device_get_sysnum() to get index of netdevsim
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 28 Sep 2022 09:00:17 +0000 (18:00 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 29 Jul 2023 13:14:24 +0000 (22:14 +0900)
src/udev/udev-builtin-net_id.c

index 31202567a2e463b2a7a4bc9fbb08ccd2a6e08433..b214eb1348a5b7c7e7320fd6e6ad351e8628549e 100644 (file)
@@ -1037,7 +1037,7 @@ static int names_mac(sd_device *dev, const char *prefix, bool test) {
 
 static int names_netdevsim(sd_device *dev, const char *prefix, bool test) {
         sd_device *netdevsimdev;
-        const char *sysname, *phys_port_name;
+        const char *sysnum, *phys_port_name;
         unsigned addr;
         int r;
 
@@ -1052,12 +1052,14 @@ static int names_netdevsim(sd_device *dev, const char *prefix, bool test) {
         r = sd_device_get_parent_with_subsystem_devtype(dev, "netdevsim", NULL, &netdevsimdev);
         if (r < 0)
                 return r;
-        r = sd_device_get_sysname(netdevsimdev, &sysname);
+
+        r = sd_device_get_sysnum(netdevsimdev, &sysnum);
         if (r < 0)
                 return r;
 
-        if (sscanf(sysname, "netdevsim%u", &addr) != 1)
-                return -EINVAL;
+        r = safe_atou(sysnum, &addr);
+        if (r < 0)
+                return r;
 
         r = sd_device_get_sysattr_value(dev, "phys_port_name", &phys_port_name);
         if (r < 0)