From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stephen@networkplumber.org>
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 <dev@dpdk.org>; Thu,  6 Jul 2017 17:28:21 +0200 (CEST)
Received: by mail-pg0-f43.google.com with SMTP id k14so2696659pgr.0
 for <dev@dpdk.org>; Thu, 06 Jul 2017 08:28:21 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20150623.gappssmtp.com; s=20150623;
 h=from:to:cc:subject:date:message-id:in-reply-to:references;
 bh=camHFu/R0POZir6VX7Xs4ouKPjNaN4+A9g/dK5HuI6c=;
 b=omLjqzgWIGb7u0ubuLnGPb2hLLMt5zGJ1+GhqRe5ngVIf9b+RK1yCi2RBWvdiXkesR
 ZTXJUSpqfOgl04DSDAMTiEtL2FV5bEP6owjORXzSUw4NHp0UTAlk9tUwaT8vIt0tY+/5
 kZ4inPN7K0VR27Rmb5Gcqr+dcYzQYwZueR74GvfYPH3F7l4CGN1fasQdo/HQFAzXXBUd
 19085S/w6/6/sC0tjtx8x/CbY6WcCf3Z59GvHVVk8ibCUxs4bNvQInvFQhbKm89WHp29
 bmDExPXEBfLGlL5OL4Qa56sJbPU71vh7ciumqnR6qJ84SMddDuc8YZK8wjuxWAM65iyf
 P6iA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references;
 bh=camHFu/R0POZir6VX7Xs4ouKPjNaN4+A9g/dK5HuI6c=;
 b=K3v3ZwH1RcV7FLoWs6EpZtQOPs8f4+bEALi7VXFxHsnepZ3/ELG5nSprwGv+W5ikGn
 DyAd199pA9S9yLLYv4W5ovKfglEXUN9NdAfMB12hOQSbEfhMmtuuc8wae83g9bA6xf7l
 lrhivkk1bVfJrz2bMDgepIUK7yENDIS0MZgNXihqFQ1ht8+GQuvF9s93ZXYVkcYOCYk5
 r55dJSzjQlFTHjYO8CFAa2CIED9lR8C7+Uz6aBiC+KY1PLm4sHZU7H2rv1PBQ80jo60p
 W29WH8q8T0gwMeRByX5gPgQd0Al0Ba415Mj2iREQeR1J4IKCARaPRgpw4g0pH86WzwCp
 dvWA==
X-Gm-Message-State: AIVw110BxevPg3izVx1Mrvcp9J0bjVIpVLsj7QEAQn/rohbQp1GKpDdr
 vPDsaadj9aO3rA1cJqEPDQ==
X-Received: by 10.84.213.9 with SMTP id f9mr5475682pli.22.1499354900990;
 Thu, 06 Jul 2017 08:28:20 -0700 (PDT)
Received: from xeon-e3.wavecable.com (76-14-207-240.or.wavecable.com.
 [76.14.207.240])
 by smtp.gmail.com with ESMTPSA id v64sm1079224pfk.126.2017.07.06.08.28.19
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 06 Jul 2017 08:28:20 -0700 (PDT)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Date: Thu,  6 Jul 2017 08:28:10 -0700
Message-Id: <20170706152812.16072-2-stephen@networkplumber.org>
X-Mailer: git-send-email 2.11.0
In-Reply-To: <20170706152812.16072-1-stephen@networkplumber.org>
References: <20170706152812.16072-1-stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH 1/3] eal: simplify finding starting point
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 06 Jul 2017 15:28:22 -0000

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>
---
 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