From: Martin Mares Date: Sun, 10 Nov 2013 11:39:19 +0000 (+0100) Subject: sysfs: Do not warn on incomplete slot addresses X-Git-Tag: v3.2.1~3 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=4134538ae5df2adfa9a9befd49d1de4418b04780;p=pciutils.git sysfs: Do not warn on incomplete slot addresses Based on a patch by Zheng Huai Cheng . --- diff --git a/lib/sysfs.c b/lib/sysfs.c index fb1b521..5a48c0d 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -226,6 +226,7 @@ sysfs_fill_slots(struct pci_access *a) char namebuf[OBJNAMELEN], buf[16]; FILE *file; unsigned int dom, bus, dev; + int res = 0; struct pci_dev *d; /* ".", ".." or a special non-device perhaps */ @@ -244,8 +245,16 @@ sysfs_fill_slots(struct pci_access *a) if (!file) continue; - if (!fgets(buf, sizeof(buf), file) || sscanf(buf, "%x:%x:%x", &dom, &bus, &dev) < 3) - a->warning("sysfs_fill_slots: Couldn't parse entry address %s", buf); + if (!fgets(buf, sizeof(buf), file) || (res = sscanf(buf, "%x:%x:%x", &dom, &bus, &dev)) < 3) + { + /* + * In some cases, the slot is not tied to a specific device before + * a card gets inserted. This happens for example on IBM pSeries + * and we need not warn about it. + */ + if (res != 2) + a->warning("sysfs_fill_slots: Couldn't parse entry address %s", buf); + } else { for (d = a->devices; d; d = d->next)