bus: simplify finding starting point
authorStephen Hemminger <stephen@networkplumber.org>
Thu, 6 Jul 2017 15:28:10 +0000 (08:28 -0700)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 8 Jul 2017 17:28:58 +0000 (19:28 +0200)
A separate boolean variable is not necessary when searching for
starting point in find_device. Just use the passed argument
as its own flag value.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
drivers/bus/fslmc/fslmc_bus.c
lib/librte_eal/common/eal_common_bus.c
lib/librte_eal/common/eal_common_pci.c
lib/librte_eal/common/eal_common_vdev.c

index 1e3bbee..88b969c 100644 (file)
@@ -111,12 +111,10 @@ rte_fslmc_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
                      const void *data)
 {
        struct rte_dpaa2_device *dev;
-       bool start_found = !start;
 
        TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next) {
-               if (!start_found) {
-                       if (&dev->device == start)
-                               start_found = 1;
+               if (start && &dev->device == start)
+                       start = NULL;  /* starting point found */
                        continue;
                }
 
index 87b0c6e..997009d 100644 (file)
@@ -154,12 +154,10 @@ rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp,
             const void *data)
 {
        struct rte_bus *bus = NULL;
-       bool start_found = !start;
 
        TAILQ_FOREACH(bus, &rte_bus_list, next) {
-               if (!start_found) {
-                       if (bus == start)
-                               start_found = 1;
+               if (start && bus == start) {
+                       start = NULL; /* starting point found */
                        continue;
                }
                if (cmp(bus, data) == 0)
index 5ee100e..7ed259b 100644 (file)
@@ -491,12 +491,10 @@ pci_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
                const void *data)
 {
        struct rte_pci_device *dev;
-       bool start_found = !start;
 
        FOREACH_DEVICE_ON_PCIBUS(dev) {
-               if (!start_found) {
-                       if (&dev->device == start)
-                               start_found = 1;
+               if (start && &dev->device == start) {
+                       start = NULL; /* starting point found */
                        continue;
                }
                if (cmp(&dev->device, data) == 0)
index baf3c5b..9ec62f4 100644 (file)
@@ -342,12 +342,10 @@ vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,
                 const void *data)
 {
        struct rte_vdev_device *dev;
-       bool start_found = !start;
 
        TAILQ_FOREACH(dev, &vdev_device_list, next) {
-               if (start_found == 0) {
-                       if (&dev->device == start)
-                               start_found = 1;
+               if (start && &dev->device == start) {
+                       start = NULL;
                        continue;
                }
                if (cmp(&dev->device, data) == 0)