teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0479-udev-net_id-parse-_SUN-ACPI-index-as-a-signed-intege.patch

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