From df70f68c8e6bf2c8810c59a722812949460f1594 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 22 Jul 2002 21:37:16 +0000 Subject: - 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" --- ldetect.spec | 8 +++++++- pci.c | 6 ++++-- usb.c | 9 ++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ldetect.spec b/ldetect.spec index 32c5ca6..80cb31b 100644 --- a/ldetect.spec +++ b/ldetect.spec @@ -1,7 +1,7 @@ # !! DON'T MODIFY HERE, MODIFY IN THE CVS !! %define name ldetect %define version 0.4.2 -%define release 2mdk +%define release 3mdk Name: %{name} Version: %{version} @@ -53,6 +53,12 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/* %changelog +* Mon Jul 22 2002 Pixel 0.4.2-3mdk +- 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" + * Tue Jul 16 2002 Pixel 0.4.2-2mdk - pciusb.c: teach titi that !(a && !b) is not (!a && !b) but (!a || b) (the other solution is to teach him to *test*) 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]; diff --git a/usb.c b/usb.c index c41ca00..a92b871 100644 --- a/usb.c +++ b/usb.c @@ -19,8 +19,8 @@ extern struct pciusb_entries usb_probe(void) { struct pciusb_entry *e = NULL; if (access(proc_pci_path, R_OK) != 0) { - printf( "TOTO\n"); - exit(1); + r.nb = 0; r.entries = NULL; + return r; } if (!(f = fopen(proc_usb_path, "r"))) { @@ -30,13 +30,16 @@ extern struct pciusb_entries usb_probe(void) { "You may have passed a wrong argument to the \"-u\" option.\n" "fopen() sets errno to", proc_usb_path); perror(err_msg); + free(err_msg); } /*else { asprintf(&err_msg, "unable to open \"%s\"\n" "You should enable the usb service (as root, type 'service usb start'.\n" "fopen() sets errno to", proc_usb_path); perror(err_msg); + free(err_msg); } */ - exit(1); + r.nb = 0; r.entries = NULL; + return r; } for(r.nb = line = 0; fgets(buf, sizeof(buf) - 1, f) && r.nb < psizeof(t); line++) { -- cgit v1.2.1