summaryrefslogtreecommitdiffstats
path: root/pci.c
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-07-22 21:37:16 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-07-22 21:37:16 +0000
commitdf70f68c8e6bf2c8810c59a722812949460f1594 (patch)
tree536ca95d38f335ca378bff97ce3738c384d44c0c /pci.c
parent4ee281db510d8fe469b21925280ca6495f48c410 (diff)
downloadldetect-df70f68c8e6bf2c8810c59a722812949460f1594.tar
ldetect-df70f68c8e6bf2c8810c59a722812949460f1594.tar.gz
ldetect-df70f68c8e6bf2c8810c59a722812949460f1594.tar.bz2
ldetect-df70f68c8e6bf2c8810c59a722812949460f1594.tar.xz
ldetect-df70f68c8e6bf2c8810c59a722812949460f1594.zip
- don't die when missing /proc/bus/pci/devices (resp. /proc/bus/usb/devices),
since on some boxes, this is *normal*! - free error messages obtained via asprintf - remove debugging message "TOTO"
Diffstat (limited to 'pci.c')
-rw-r--r--pci.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/pci.c b/pci.c
index e31a862..77b8b5a 100644
--- a/pci.c
+++ b/pci.c
@@ -15,7 +15,6 @@ extern struct pciusb_entries pci_probe(int probe_type) {
unsigned short devbusfn;
unsigned int id;
struct pciusb_entries r;
- r.entries = malloc(sizeof(struct pciusb_entry) * MAX_DEVICES);
if (!(f = fopen(proc_pci_path, "r"))) {
char *err_msg;
@@ -23,8 +22,11 @@ extern struct pciusb_entries pci_probe(int probe_type) {
"You may have passed a wrong argument to the \"-p\" option.\n"
"fopen() sets errno to", proc_pci_path);
perror(err_msg);
- exit(1);
+ free(err_msg);
+ r.nb = 0; r.entries = NULL;
+ return r;
}
+ r.entries = malloc(sizeof(struct pciusb_entry) * MAX_DEVICES);
for (r.nb = 0; fgets(buf, sizeof(buf) - 1, f) && r.nb < MAX_DEVICES; r.nb++) {
struct pciusb_entry *e = &r.entries[r.nb];