summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2008-05-21 13:44:38 -0400
committerAdam Jackson <ajax@redhat.com>2008-05-21 13:44:38 -0400
commit4586bb6766983d040bff38b43dc458c47e0ca21f (patch)
treedebb53331085d72771b06254dec37538972ea355
parent26400575a2a2d10b1014eaf0bfca6cfbf5d9b93b (diff)
Linux: Fail gracefully on machines without PCI.
-rw-r--r--src/common_iterator.c3
-rw-r--r--src/linux_sysfs.c7
2 files changed, 6 insertions, 4 deletions
diff --git a/src/common_iterator.c b/src/common_iterator.c
index 73d2755..83cade3 100644
--- a/src/common_iterator.c
+++ b/src/common_iterator.c
@@ -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 ) {
diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
index 5fa0ea1..9e53fac 100644
--- a/src/linux_sysfs.c
+++ b/src/linux_sysfs.c
@@ -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;
}