From 934e7e36f9cd6f4bd39f9666a4f4d0ad1b0c91eb Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 10 Sep 2006 17:34:45 +0200 Subject: Errors when reading standard config header are no longer fatal. --- ChangeLog | 6 ++++++ lspci.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00bafa4..9423be3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-09-10 Martin Mares + + * 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 * Released as 2.2.4. diff --git a/lspci.c b/lspci.c index cbefe5b..1f3b037 100644 --- 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); } -- cgit v1.2.1