ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
87d178
From 462420bc7ea22a05bfc2d021d395aade2b8ee7dc Mon Sep 17 00:00:00 2001
87d178
From: =?UTF-8?q?Michal=20Sekleta=CC=81r?= <msekleta@redhat.com>
87d178
Date: Mon, 19 Oct 2020 10:56:11 +0200
87d178
Subject: [PATCH] udev/net_id: parse _SUN ACPI index as a signed integer
87d178
87d178
Negative value means there is no match between a PCI device and any of
87d178
the slots. In the following commit we will extend this and value of 0
87d178
will indicate that there is a match between some slot and PCI device,
87d178
but that device is a PCI bridge.
87d178
87d178
(cherry picked from commit 3e545ae5abcf258791eacbee60c829c100a33274)
87d178
87d178
Related: #1827462
87d178
---
87d178
 src/udev/udev-builtin-net_id.c | 11 ++++++-----
87d178
 1 file changed, 6 insertions(+), 5 deletions(-)
87d178
87d178
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
87d178
index aa553d5ade..ede24dee41 100644
87d178
--- a/src/udev/udev-builtin-net_id.c
87d178
+++ b/src/udev/udev-builtin-net_id.c
87d178
@@ -391,7 +391,8 @@ static bool is_pci_ari_enabled(struct udev_device *dev) {
87d178
 
87d178
 static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
87d178
         struct udev *udev = udev_device_get_udev(names->pcidev);
87d178
-        unsigned domain, bus, slot, func, dev_port = 0, hotplug_slot = 0;
87d178
+        unsigned domain, bus, slot, func, dev_port = 0;
87d178
+        int hotplug_slot = -1;
87d178
         size_t l;
87d178
         char *s;
87d178
         const char *attr, *port_name;
87d178
@@ -449,15 +450,15 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
87d178
         hotplug_slot_dev = names->pcidev;
87d178
         while (hotplug_slot_dev) {
87d178
                 FOREACH_DIRENT_ALL(dent, dir, break) {
87d178
-                        unsigned i;
87d178
-                        int r;
87d178
+                        int i, r;
87d178
                         char str[PATH_MAX];
87d178
                         _cleanup_free_ char *address = NULL;
87d178
 
87d178
                         if (dent->d_name[0] == '.')
87d178
                                 continue;
87d178
-                        r = safe_atou_full(dent->d_name, 10, &i);
87d178
-                        if (i < 1 || r < 0)
87d178
+
87d178
+                        r = safe_atoi(dent->d_name, &i);
87d178
+                        if (r < 0 || i <= 0)
87d178
                                 continue;
87d178
 
87d178
                         if (snprintf_ok(str, sizeof str, "%s/%s/address", slots, dent->d_name) &&