From: Yu Watanabe Date: Wed, 28 Sep 2022 09:00:17 +0000 (+0900) Subject: udev-builtin-net_id: use sd_device_get_sysnum() to get index of netdevsim X-Git-Tag: v255-rc1~877^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc710857d182ab24030eb3dbe78a3b247c072b75;p=thirdparty%2Fsystemd.git udev-builtin-net_id: use sd_device_get_sysnum() to get index of netdevsim --- diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 31202567a2e..b214eb1348a 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -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)