diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2008-11-19 08:22:22 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2008-11-19 08:22:22 -0800 |
commit | 0821f3b4eae5428cf1af5c4c056240f8991758f6 (patch) | |
tree | 05d30fd52b33206956a1f60df9f83c25d36af908 /src/common_device_name.c | |
parent | ccbfd4cf2a7d203344bd1ffcb9d0024536a0eefa (diff) |
Don't open/gzopen pci.ids if we're not going to read it
Diffstat (limited to 'src/common_device_name.c')
-rw-r--r-- | src/common_device_name.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/common_device_name.c b/src/common_device_name.c index 877f218..be601ed 100644 --- a/src/common_device_name.c +++ b/src/common_device_name.c @@ -189,26 +189,25 @@ insert( uint16_t vendor ) static void populate_vendor( struct pci_id_leaf * vend, int fill_device_data ) { - pci_id_file * f = pci_id_file_open(); + pci_id_file * f; char buf[128]; unsigned vendor = PCI_MATCH_ANY; - /* If the pci.ids file could not be opened, there's nothing we can do. - */ - if (f == NULL) { - return; - } - - /* If the device tree for this vendor is already populated, don't do * anything. This avoids wasted processing and potential memory leaks. */ if (vend->num_devices != 0) { - pci_id_file_close( f ); return; } + f = pci_id_file_open(); + + /* If the pci.ids file could not be opened, there's nothing we can do. + */ + if (f == NULL) { + return; + } while( pci_id_file_gets( buf, sizeof( buf ), f ) != NULL ) { unsigned num_tabs; |