From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH v4 3/9] bus: add helper to find bus for a particular device Date: Wed, 21 Jun 2017 14:11:05 +0200 Message-ID: <2413014.VjuBF7ha8b@xps> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org, Jan Blunck To: Gaetan Rivet Return-path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 5B547532C for ; Wed, 21 Jun 2017 14:11:07 +0200 (CEST) In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 21/06/2017 01:29, Gaetan Rivet: > +static int > +cmp_rte_device(const struct rte_device *dev, const void *_dev2) Better to rename dev into dev1. > +{ > + const struct rte_device *dev2 = _dev2; > + > + return !(dev == dev2); simpler: return dev1 != dev2 [...] > +static int > +bus_find_device(const struct rte_bus *bus, const void *_dev) > +{ > + struct rte_device *dev; > + > + if (!bus->find_device) It is preferred to check pointers against NULL. > + return -1; > + dev = bus->find_device(cmp_rte_device, _dev); > + return !dev; Here also: return dev == NULL: > +} > + > +struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev) > +{ > + return rte_bus_find(bus_find_device, (const void *)dev, NULL); > +} Nice