OSDN Git Service

Linux: Fail gracefully on machines without PCI.
authorAdam Jackson <ajax@redhat.com>
Wed, 21 May 2008 17:44:38 +0000 (13:44 -0400)
committerAdam Jackson <ajax@redhat.com>
Wed, 21 May 2008 17:44:38 +0000 (13:44 -0400)
src/common_iterator.c
src/linux_sysfs.c

index 73d2755..83cade3 100644 (file)
@@ -158,6 +158,9 @@ pci_device_next( struct pci_device_iterator * iter )
 {
     struct pci_device_private * d = NULL;
 
+    if (!iter)
+       return NULL;
+
     switch( iter->mode ) {
     case match_any:
        if ( iter->next_index < pci_sys->num_devices ) {
index 5fa0ea1..9e53fac 100644 (file)
@@ -114,6 +114,9 @@ pci_system_linux_sysfs_create( void )
        pci_sys = calloc( 1, sizeof( struct pci_system ) );
        if ( pci_sys != NULL ) {
            pci_sys->methods = & linux_sysfs_methods;
+#ifdef HAVE_MTRR
+           pci_sys->mtrr_fd = open("/proc/mtrr", O_WRONLY);
+#endif
            err = populate_entries(pci_sys);
        }
        else {
@@ -124,10 +127,6 @@ pci_system_linux_sysfs_create( void )
        err = errno;
     }
 
-#ifdef HAVE_MTRR
-    pci_sys->mtrr_fd = open("/proc/mtrr", O_WRONLY);
-#endif
-
     return err;
 }