]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev/net_id: move naming scheme check
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 23 Aug 2024 00:54:00 +0000 (09:54 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 23 Aug 2024 01:20:56 +0000 (10:20 +0900)
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.

src/udev/udev-builtin-net_id.c

index f88fa0f71dd974cd6de199f367740c3dab619aec..934d8acddc97a2bcae3517de352abd0e2f07188f 100644 (file)
@@ -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;