From: Yu Watanabe Date: Tue, 27 Sep 2022 07:32:22 +0000 (+0900) Subject: udev-builtin-net_id: make names_vio() self-contained X-Git-Tag: v255-rc1~877^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=07e1841eb97e6608e64f6864e527121a161fb373;p=thirdparty%2Fsystemd.git udev-builtin-net_id: make names_vio() self-contained It is not necessary to store its partial result in NetNames. No functional changes, just refactoring. --- diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index a1e6af9df50..aeb7bceaa57 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -48,7 +48,6 @@ typedef enum NetNameType { NET_PCI, NET_USB, NET_BCMA, - NET_VIO, NET_XENVIF, NET_PLATFORM, NET_NETDEVSIM, @@ -65,7 +64,6 @@ typedef struct NetNames { char usb_ports[ALTIFNAMSIZ]; char bcma_core[ALTIFNAMSIZ]; - char vio_slot[ALTIFNAMSIZ]; char xen_slot[ALTIFNAMSIZ]; char platform_path[ALTIFNAMSIZ]; char netdevsim_path[ALTIFNAMSIZ]; @@ -502,12 +500,17 @@ static int dev_pci_slot(sd_device *dev, const LinkInfo *info, NetNames *names) { return 0; } -static int names_vio(sd_device *dev, NetNames *names) { +static int names_vio(sd_device *dev, const char *prefix, bool test) { sd_device *parent; unsigned busid, slotid, ethid; const char *syspath, *subsystem; int r; + assert(dev); + assert(prefix); + + /* get ibmveth/ibmvnic slot-based names. */ + /* check if our direct parent is a VIO device with no other bus in-between */ r = sd_device_get_parent(dev, &parent); if (r < 0) @@ -534,10 +537,11 @@ static int names_vio(sd_device *dev, NetNames *names) { if (r != 3) return -EINVAL; - xsprintf(names->vio_slot, "v%u", slotid); - names->type = NET_VIO; + char str[ALTIFNAMSIZ]; + if (snprintf_ok(str, sizeof str, "%sv%u", prefix, slotid)) + udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str); log_device_debug(dev, "Vio slot identifier: slotid=%u %s %s", - slotid, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), names->vio_slot); + slotid, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), str + strlen(prefix)); return 0; } @@ -1192,15 +1196,7 @@ static int builtin_net_id(UdevEvent *event, int argc, char *argv[], bool test) { (void) names_mac(dev, prefix, test); (void) names_devicetree(dev, prefix, test); (void) names_ccw(dev, prefix, test); - - /* get ibmveth/ibmvnic slot-based names. */ - if (names_vio(dev, &names) >= 0 && names.type == NET_VIO) { - char str[ALTIFNAMSIZ]; - - if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.vio_slot)) - udev_builtin_add_property(dev, test, "ID_NET_NAME_SLOT", str); - return 0; - } + (void) names_vio(dev, prefix, test); /* get ACPI path names for ARM64 platform devices */ if (names_platform(dev, &names, test) >= 0 && names.type == NET_PLATFORM) {