From: Alan Coopersmith Date: Wed, 19 Nov 2008 16:22:22 +0000 (-0800) Subject: Don't open/gzopen pci.ids if we're not going to read it X-Git-Tag: android-x86-6.0-r1~153 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0821f3b4eae5428cf1af5c4c056240f8991758f6;p=android-x86%2Fexternal-libpciaccess.git Don't open/gzopen pci.ids if we're not going to read it --- 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;