diff --git a/hwloc/topology-linux.c b/hwloc/topology-linux.c index 0d89cf4b58..a3c165173b 100644 --- a/hwloc/topology-linux.c +++ b/hwloc/topology-linux.c @@ -5890,7 +5890,7 @@ hwloc_look_linuxfs_io(struct hwloc_backend *backend) enum hwloc_type_filter_e pfilter, bfilter, ofilter, mfilter; int root_fd = -1; #ifdef HWLOC_HAVE_LINUXPCI - struct hwloc_obj *tmp; + struct hwloc_obj *child; int needpcidiscovery; #endif @@ -5928,10 +5928,12 @@ hwloc_look_linuxfs_io(struct hwloc_backend *backend) * (they are attached to root until later in the core discovery) */ needpcidiscovery = 1; - for_each_io_child(tmp, hwloc_get_root_obj(topology)) { - if (tmp->type == HWLOC_OBJ_PCI_DEVICE - || (tmp->type == HWLOC_OBJ_BRIDGE && tmp->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI)) { - hwloc_debug("%s", "PCI objects already added, ignoring linuxio PCI discovery.\n"); + for_each_io_child(child, hwloc_get_root_obj(topology)) { + if (child->type == HWLOC_OBJ_PCI_DEVICE + || (child->type == HWLOC_OBJ_BRIDGE && + (child->attr->bridge.upstream_type == HWLOC_OBJ_BRIDGE_PCI + || child->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI))) { + hwloc_debug("%s", "Topology already contains PCI objects, skipping linuxio PCI discovery.\n"); needpcidiscovery = 0; break; } diff --git a/hwloc/topology-pci.c b/hwloc/topology-pci.c index 3195797d52..ef5840a150 100644 --- a/hwloc/topology-pci.c +++ b/hwloc/topology-pci.c @@ -92,7 +92,7 @@ hwloc_look_pci(struct hwloc_backend *backend) { struct hwloc_topology *topology = backend->topology; enum hwloc_type_filter_e pfilter, bfilter; - struct hwloc_obj *tree = NULL, *tmp; + struct hwloc_obj *tree = NULL, *child; int ret; struct pci_device_iterator *iter; struct pci_device *pcidev; @@ -106,14 +106,14 @@ hwloc_look_pci(struct hwloc_backend *backend) /* don't do anything if another backend attached PCI already * (they are attached to root until later in the core discovery) */ - tmp = hwloc_get_root_obj(topology)->io_first_child; - while (tmp) { - if (tmp->type == HWLOC_OBJ_PCI_DEVICE - || (tmp->type == HWLOC_OBJ_BRIDGE && tmp->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI)) { - hwloc_debug("%s", "PCI objects already added, ignoring linuxpci backend.\n"); + for_each_io_child(child, hwloc_get_root_obj(topology)) { + if (child->type == HWLOC_OBJ_PCI_DEVICE + || (child->type == HWLOC_OBJ_BRIDGE && + (child->attr->bridge.upstream_type == HWLOC_OBJ_BRIDGE_PCI + || child->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI))) { + hwloc_debug("%s", "Topology already contains PCI objects, skipping PCI backend.\n"); return 0; } - tmp = tmp->next_sibling; } hwloc_debug("%s", "\nScanning PCI buses...\n");