From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH v6 09/11] pci: implement find_device bus operation Date: Tue, 27 Jun 2017 16:35:14 -0700 Message-ID: <20170627163514.2ed2ec6b@xeon-e3> References: <5fe2e5fb2759d1f6d3f86e5dfae5c3fc177299da.1498577192.git.gaetan.rivet@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: Gaetan Rivet Return-path: Received: from mail-pf0-f173.google.com (mail-pf0-f173.google.com [209.85.192.173]) by dpdk.org (Postfix) with ESMTP id E1359271 for ; Wed, 28 Jun 2017 01:35:22 +0200 (CEST) Received: by mail-pf0-f173.google.com with SMTP id s66so23838559pfs.1 for ; Tue, 27 Jun 2017 16:35:22 -0700 (PDT) In-Reply-To: <5fe2e5fb2759d1f6d3f86e5dfae5c3fc177299da.1498577192.git.gaetan.rivet@6wind.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, 27 Jun 2017 18:11:16 +0200 Gaetan Rivet wrote: > + int start_found = !!(start == NULL); > + > + FOREACH_DEVICE_ON_PCIBUS(dev) { > + if (!start_found) { > + if (&dev->device == start) > + start_found = 1; > + continue; > + } > + if (cmp(&dev->device, data) == 0) > + return &dev->device; > + } > + return NULL; > +} > + Why is start_found not a boolean? Do you really need start_found at all? Why not just reuse existing pointer? FOREACH_DEVICE_ON_PCIBUS(dev) { if (start) { if (&dev->device == start) start = NULL continue; } if (cmp(&dev->device, data) == 0) return &dev->device; } return NULL; }