From a35e34b7fa47a62df711c49832f46d6edf790381 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Tue, 1 Dec 2015 20:47:48 +0100 Subject: com32: Handle broken modules.alias When parsing the modules.alias, we shall report it as broken if we cannot find any valid line in it. This patch simply count the number of valid lines and report a missing modules.alias if no valid lines are found. --- com32/lib/pci/scan.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c index fe00fc25..20a3e2a6 100644 --- a/com32/lib/pci/scan.c +++ b/com32/lib/pci/scan.c @@ -603,6 +603,7 @@ int get_module_name_from_alias(struct pci_domain *domain, char *modules_alias_pa char sub_product_id[16]; FILE *f; struct pci_device *dev=NULL; + int valid_lines=0; /* Intializing the linux_kernel_module for each pci device to "unknown" */ /* adding a dev_info member if needed */ @@ -630,6 +631,7 @@ int get_module_name_from_alias(struct pci_domain *domain, char *modules_alias_pa if ((line[0] == '#') || (strstr(line,"alias pci:v")==NULL)) continue; + valid_lines++; /* Resetting temp buffer*/ memset(module_name,0,sizeof(module_name)); memset(vendor_id,0,sizeof(vendor_id)); @@ -725,5 +727,11 @@ int get_module_name_from_alias(struct pci_domain *domain, char *modules_alias_pa } } fclose(f); + /* If no valid line was found in the module.alias, + * we shall report it as broken/empty/non-existing */ + if (valid_lines == 0) { + return -ENOMODULESALIAS; + } + return 0; } -- cgit v1.2.1