From 06f9ecf36e529695feea35038e15233dffe37bb7 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 18 Feb 2024 01:37:49 +0100 Subject: Names: Fixed a rare bug in loading of pci.ids If the pci.ids file was empty, it was never considered loaded, so the loading function was called repeatedly and it always flushed the name cache. --- lib/names-parse.c | 5 ++--- lib/names.c | 2 +- lib/pci.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/names-parse.c b/lib/names-parse.c index f50b8ec..1f8925a 100644 --- a/lib/names-parse.c +++ b/lib/names-parse.c @@ -223,7 +223,7 @@ pci_load_name_list(struct pci_access *a) const char *err; pci_free_name_list(a); - a->id_load_failed = 1; + a->id_load_attempted = 1; if (!(f = pci_open(a))) return 0; err = id_parse_list(a, f, &lino); @@ -231,7 +231,6 @@ pci_load_name_list(struct pci_access *a) pci_close(f); if (err) a->error("%s at %s, line %d\n", err, a->id_file_name, lino); - a->id_load_failed = 0; return 1; } @@ -241,7 +240,7 @@ pci_free_name_list(struct pci_access *a) pci_id_cache_flush(a); pci_id_hash_free(a); pci_id_hwdb_free(a); - a->id_load_failed = 0; + a->id_load_attempted = 0; } void diff --git a/lib/names.c b/lib/names.c index f8d3997..a287cb0 100644 --- a/lib/names.c +++ b/lib/names.c @@ -143,7 +143,7 @@ pci_lookup_name(struct pci_access *a, char *buf, int size, int flags, ...) if (flags & PCI_LOOKUP_MIXED) flags &= ~PCI_LOOKUP_NUMERIC; - if (!a->id_hash && !(flags & (PCI_LOOKUP_NUMERIC | PCI_LOOKUP_SKIP_LOCAL)) && !a->id_load_failed) + if (!a->id_load_attempted && !(flags & (PCI_LOOKUP_NUMERIC | PCI_LOOKUP_SKIP_LOCAL))) pci_load_name_list(a); switch (flags & 0xffff) diff --git a/lib/pci.h b/lib/pci.h index 03b4c41..b3386d7 100644 --- a/lib/pci.h +++ b/lib/pci.h @@ -81,7 +81,7 @@ struct pci_access { struct pci_param *params; struct id_entry **id_hash; /* names.c */ struct id_bucket *current_id_bucket; - int id_load_failed; + int id_load_attempted; int id_cache_status; /* 0=not read, 1=read, 2=dirty */ struct udev *id_udev; /* names-hwdb.c */ struct udev_hwdb *id_udev_hwdb; -- cgit 1.2.3-korg