Don't open/gzopen pci.ids if we're not going to read it
authorAlan Coopersmith <alan.coopersmith@sun.com>
Wed, 19 Nov 2008 16:22:22 +0000 (08:22 -0800)
committerAlan Coopersmith <alan.coopersmith@sun.com>
Wed, 19 Nov 2008 16:22:22 +0000 (08:22 -0800)
src/common_device_name.c

index 877f218..be601ed 100644 (file)
@@ -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;