diff options
author | Martin Mares <mj@ucw.cz> | 2024-02-18 01:37:49 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2024-02-18 01:37:49 +0100 |
commit | 06f9ecf36e529695feea35038e15233dffe37bb7 (patch) | |
tree | f1367713c3b74c0acaa6ef7833506460a5743307 | |
parent | d314d0bf6d385ce840c9c0835bf723625b34db0c (diff) | |
download | pciutils-06f9ecf36e529695feea35038e15233dffe37bb7.tar.gz |
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.
-rw-r--r-- | lib/names-parse.c | 5 | ||||
-rw-r--r-- | lib/names.c | 2 | ||||
-rw-r--r-- | 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) @@ -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; |