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