summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2008-11-19 08:22:22 -0800
committerAlan Coopersmith <alan.coopersmith@sun.com>2008-11-19 08:22:22 -0800
commit0821f3b4eae5428cf1af5c4c056240f8991758f6 (patch)
tree05d30fd52b33206956a1f60df9f83c25d36af908
parentccbfd4cf2a7d203344bd1ffcb9d0024536a0eefa (diff)
Don't open/gzopen pci.ids if we're not going to read it
-rw-r--r--src/common_device_name.c17
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;