From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0D41CA0C4B; Fri, 19 Nov 2021 11:15:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A1DB40143; Fri, 19 Nov 2021 11:15:41 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 8B43140140; Fri, 19 Nov 2021 11:15:39 +0100 (CET) X-IronPort-AV: E=McAfee;i="6200,9189,10172"; a="234628774" X-IronPort-AV: E=Sophos;i="5.87,247,1631602800"; d="scan'208";a="234628774" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2021 02:15:38 -0800 X-IronPort-AV: E=Sophos;i="5.87,247,1631602800"; d="scan'208";a="495812651" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.21.229]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 19 Nov 2021 02:15:36 -0800 Date: Fri, 19 Nov 2021 10:15:32 +0000 From: Bruce Richardson To: Ferruh Yigit Cc: Tyler Retzlaff , eagostini@nvidia.com, dev@dpdk.org, "techboard@dpdk.org" , Andrew Rybchenko , David Marchand Subject: Re: [PATCH v1] gpudev: return EINVAL if invalid input pointer for free and unregister Message-ID: References: <20211118192802.23955-1-eagostini@nvidia.com> <20211118201931.GA6492@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, Nov 19, 2021 at 09:34:08AM +0000, Ferruh Yigit wrote: > On 11/18/2021 8:19 PM, Tyler Retzlaff wrote: > > On Thu, Nov 18, 2021 at 07:28:02PM +0000, eagostini@nvidia.com wrote: > > > From: Elena Agostini > > > > > > Signed-off-by: Elena Agostini > > > --- > > > lib/gpudev/gpudev.c | 10 ++++++++++ > > > lib/gpudev/rte_gpudev.h | 2 ++ > > > 2 files changed, 12 insertions(+) > > > > > > diff --git a/lib/gpudev/gpudev.c b/lib/gpudev/gpudev.c > > > index 2b174d8bd5..97575ed979 100644 > > > --- a/lib/gpudev/gpudev.c > > > +++ b/lib/gpudev/gpudev.c > > > @@ -576,6 +576,11 @@ rte_gpu_mem_free(int16_t dev_id, void *ptr) > > > return -rte_errno; > > > } > > > + if (ptr == NULL) { > > > + rte_errno = EINVAL; > > > + return -rte_errno; > > > + } > > > > in general dpdk has real problems with how it indicates that an error > > occurred and what error occurred consistently. > > > > some api's return 0 on success > > and maybe return -errno if ! 0 > > and maybe return errno if ! 0 > > and maybe set rte_errno if ! 0 > > > > some api's return -1 on failure > > and set rte_errno if -1 > > > > some api's return < 0 on failure > > and maybe set rte_errno > > and maybe return -errno > > and maybe set rte_errno and return -rte_errno > > > > This is a generic comment, cc'ed a few more folks to make the comment more > visible. > Yes, it's inconsistent. However, this only applies to functions which return integer values. Other functions which return pointer values are hopefully standardized to return NULL on error. [Which means any error code must be in rte_errno.] /Bruce