From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: [PATCH 1/3] eal: simplify finding starting point Date: Thu, 6 Jul 2017 08:28:10 -0700 Message-ID: <20170706152812.16072-2-stephen@networkplumber.org> References: <20170706152812.16072-1-stephen@networkplumber.org> Cc: Stephen Hemminger To: dev@dpdk.org Return-path: Received: from mail-pg0-f43.google.com (mail-pg0-f43.google.com [74.125.83.43]) by dpdk.org (Postfix) with ESMTP id 200A51094 for ; Thu, 6 Jul 2017 17:28:21 +0200 (CEST) Received: by mail-pg0-f43.google.com with SMTP id k14so2696659pgr.0 for ; Thu, 06 Jul 2017 08:28:21 -0700 (PDT) In-Reply-To: <20170706152812.16072-1-stephen@networkplumber.org> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- lib/librte_eal/common/eal_common_bus.c | 6 ++---- lib/librte_eal/common/eal_common_pci.c | 6 ++---- lib/librte_eal/common/eal_common_vdev.c | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 87b0c6e6fa03..997009d2b8d0 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -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) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 5ee100e67374..7ed259b09cd0 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -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) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index baf3c5bfa23f..9ec62f4d4dea 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -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) -- 2.11.0