From: Yu Watanabe Date: Fri, 23 Aug 2024 00:54:00 +0000 (+0900) Subject: udev/net_id: move naming scheme check X-Git-Tag: v257-rc1~640^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8c6f4845957c179f39093d3c61d8ab249776aca5;p=thirdparty%2Fsystemd.git udev/net_id: move naming scheme check We usually do not set r = -1 when a functionality is disabled or not supported. Even though the error code is not used, let's set a negative errno in such case. No functional change, just refactoring. Follow-up for 0a4ecc54cb9f2d3418b970c51bfadb69c34ae9eb. --- diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index f88fa0f71dd..934d8acddc9 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -589,12 +589,15 @@ static int get_device_firmware_node_sun(sd_device *dev, uint32_t *ret) { } static int pci_get_slot_from_firmware_node_sun(sd_device *dev, uint32_t *ret) { - int r; sd_device *slot_dev; + int r; assert(dev); assert(ret); + if (!naming_scheme_has(NAMING_FIRMWARE_NODE_SUN)) + return -EOPNOTSUPP; + /* Try getting the ACPI _SUN for the device */ if (get_device_firmware_node_sun(dev, ret) >= 0) return 0; @@ -690,12 +693,8 @@ static int names_pci_slot(sd_device *dev, sd_device *pci_dev, const char *prefix strna(domain), bus_and_slot, strna(func), strna(port), special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), empty_to_na(str)); - if (naming_scheme_has(NAMING_FIRMWARE_NODE_SUN)) - r = pci_get_slot_from_firmware_node_sun(pci_dev, &slot); - else - r = -1; - /* If we don't find a slot using firmware_node/sun, fallback to hotplug_slot */ - if (r < 0) { + if (pci_get_slot_from_firmware_node_sun(pci_dev, &slot) < 0) { + /* If we don't find a slot using firmware_node/sun, fallback to hotplug_slot */ r = pci_get_hotplug_slot(pci_dev, &slot); if (r < 0) return r;