From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: Re: [PATCH v7 06/15] bus: add helper to find which bus holds a device Date: Fri, 30 Jun 2017 22:24:41 +0100 Message-ID: <20170630212440.GA19236@bricha3-MOBL3.ger.corp.intel.com> References: <2216663.aYTdufOMPG@xps> <1635095.dVgJJgmtZI@xps> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jan Blunck , dev@dpdk.org, =?iso-8859-1?Q?Ga=EBtan?= Rivet , Shreyansh Jain To: Thomas Monjalon Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id A531E37A0 for ; Fri, 30 Jun 2017 23:24:45 +0200 (CEST) Content-Disposition: inline In-Reply-To: <1635095.dVgJJgmtZI@xps> 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 Fri, Jun 30, 2017 at 08:29:06PM +0200, Thomas Monjalon wrote: > 30/06/2017 18:46, Jan Blunck: > > On Fri, Jun 30, 2017 at 11:16 AM, Thomas Monjalon wrote: > > > 29/06/2017 20:21, Jan Blunck: > > >> +static int > > >> +bus_find_device(const struct rte_bus *bus, const void *_dev) > > >> +{ > > >> + struct rte_device *dev; > > >> + > > >> + dev = bus->find_device(NULL, cmp_rte_device, _dev); > > >> + return !dev; > > >> +} > > > > > > The preferred code style is to make explicit the NULL comparisons: > > > return dev == NULL; > > > > Oh, interesting ... not a lot of C++ programmers around here I guess. > > > > Does this mean you also want me to make integer tests explicit again 0? > > Good question, I don't know. > I know only this part of the coding rules: > http://dpdk.org/doc/guides/contributing/coding_style.html#null-pointers > Yes, I noticed that gap the other day. IMHO for consistency the integers should similarly be compared to 0/non-zero explicitly rather than using "!" operator. The exception I would allow is where a function is named in such a way that is clearly returns a boolean value as int e.g. a function "int is_computer_on()". /Bruce