]> mj.ucw.cz Git - pciutils.git/commitdiff
Errors when reading standard config header are no longer fatal.
authorMartin Mares <mj@ucw.cz>
Sun, 10 Sep 2006 15:34:45 +0000 (17:34 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 10 Sep 2006 15:34:45 +0000 (17:34 +0200)
ChangeLog
lspci.c

index 00bafa4b5bc601459395fa41049eed3fd06cef8e..9423be398638dfdf4a4e8f69fd46b8010ff77336 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-09-10  Martin Mares  <mj@ucw.cz>
+
+       * lspci.c (scan_device): If an error occurs when reading the standard config
+       header of a device, report it and ignore the device and return with exit
+       code 2 at the end.
+
 2006-09-09  Martin Mares  <mj@ucw.cz>
 
        * Released as 2.2.4.
diff --git a/lspci.c b/lspci.c
index cbefe5b468a489de8b35ce62848853aaea80eb5a..1f3b03715e7be0ffa168935569324e7612669dd7 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -75,6 +75,7 @@ struct device {
 };
 
 static struct device *first_dev;
+static int seen_errors;
 
 static int
 config_fetch(struct device *d, unsigned int pos, unsigned int len)
@@ -121,7 +122,12 @@ scan_device(struct pci_dev *p)
   d->present = xmalloc(64);
   memset(d->present, 1, 64);
   if (!pci_read_block(p, 0, d->config, 64))
-    die("Unable to read the standard configuration space header");
+    {
+      fprintf(stderr, "lspci: Unable to read the standard configuration space header of device %04x:%02x:%02x.%d\n",
+             p->domain, p->bus, p->dev, p->func);
+      seen_errors++;
+      return NULL;
+    }
   if ((d->config[PCI_HEADER_TYPE] & 0x7f) == PCI_HEADER_TYPE_CARDBUS)
     {
       /* For cardbus bridges, we need to fetch 64 bytes more to get the
@@ -2401,5 +2407,5 @@ main(int argc, char **argv)
     }
   pci_cleanup(pacc);
 
-  return 0;
+  return (seen_errors ? 2 : 0);
 }