From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [dpdk-dev,1/2] ethdev: remove useless null checks Date: Fri, 22 Jan 2016 10:11:47 +0100 Message-ID: <14115211.gcWZQ474Ox@xps13> References: <1453377431-25850-2-git-send-email-david.marchand@6wind.com> <20160121200225.60cffcfd@pcviktorin.fit.vutbr.cz> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org To: Jan Viktorin Return-path: Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id C1F928EA1 for ; Fri, 22 Jan 2016 10:12:48 +0100 (CET) Received: by mail-wm0-f49.google.com with SMTP id l65so252449326wmf.1 for ; Fri, 22 Jan 2016 01:12:48 -0800 (PST) In-Reply-To: <20160121200225.60cffcfd@pcviktorin.fit.vutbr.cz> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 2016-01-21 20:02, Jan Viktorin: > On Thu, 21 Jan 2016 12:57:10 +0100 > David Marchand wrote: > > - if ((name == NULL) || (pci_dev == NULL)) > > - return -EINVAL; > > Do you use a kind of assert in DPDK? The patch looks OK, however, I > would prefer something like > > assert_not_null(name); > assert_not_null(pci_dev); > > Usually, if some outer code is broken by mistake, the assert catches > such an issue. At the same time, it documents the code by telling > "this must never be NULL here". I agree, that returning -EINVAL for > this kind of check is incorrect. > > Same for other changes... For this patch, I agree to remove useless checks. For the other checks, EINVAL seems to be the right error code. And yes you are right, we could replace most of EINVAL returns by a kind of assert. RTE_VERIFY would be appropriate.