From 9f2530aadf482020a9a9453e35953a1a8c6a907e Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 5 Nov 2002 15:12:13 +0000 Subject: no error message when -p is not used and there is neither pci nor usb bus --- pci.c | 19 +++++++++++-------- usb.c | 13 +++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pci.c b/pci.c index a2f86fb..82f862c 100644 --- a/pci.c +++ b/pci.c @@ -7,7 +7,8 @@ #include "libldetect-private.h" #include "common.h" -char *proc_pci_path = "/proc/bus/pci/devices"; +char *proc_pci_path_default = "/proc/bus/pci/devices"; +char *proc_pci_path = NULL; extern struct pciusb_entries pci_probe(int probe_type) { FILE *f, *devf; @@ -19,13 +20,15 @@ extern struct pciusb_entries pci_probe(int probe_type) { char file[25]; r.nb = 0; - if (!(f = fopen(proc_pci_path, "r"))) { - char *err_msg; - asprintf(&err_msg, "unable to open \"%s\"\n" - "You may have passed a wrong argument to the \"-p\" option.\n" - "fopen() sets errno to", proc_pci_path); - perror(err_msg); - free(err_msg); + if (!(f = fopen(proc_pci_path ? proc_pci_path : proc_pci_path_default, "r"))) { + if (proc_pci_path) { + char *err_msg; + asprintf(&err_msg, "unable to open \"%s\"\n" + "You may have passed a wrong argument to the \"-p\" option.\n" + "fopen() sets errno to", proc_pci_path); + perror(err_msg); + free(err_msg); + } r.entries = NULL; return r; } diff --git a/usb.c b/usb.c index e667a5d..0ac6496 100644 --- a/usb.c +++ b/usb.c @@ -7,7 +7,8 @@ #include "libldetect-private.h" #include "common.h" -char *proc_usb_path = "/proc/bus/usb/devices"; +char *proc_usb_path_default = "/proc/bus/usb/devices"; +char *proc_usb_path = NULL; extern struct pciusb_entries usb_probe(void) { @@ -17,14 +18,10 @@ extern struct pciusb_entries usb_probe(void) { struct pciusb_entries r; struct pciusb_entry *e = NULL; r.nb = 0; - if (access(proc_usb_path, R_OK) != 0) { - r.entries = NULL; - return r; - } - if (!(f = fopen(proc_usb_path, "r"))) { - char *err_msg; - if (proc_usb_path==NULL || strcmp(proc_usb_path, "/proc/bus/usb/devices")) { + if (!(f = fopen(proc_usb_path ? proc_usb_path : proc_usb_path_default, "r"))) { + if (proc_usb_path) { + char *err_msg; asprintf(&err_msg, "unable to open \"%s\"\n" "You may have passed a wrong argument to the \"-u\" option.\n" "fopen() sets errno to", proc_usb_path); -- cgit v1.2.1