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 B7C6FA0C41; Thu, 18 Nov 2021 21:19:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D18340687; Thu, 18 Nov 2021 21:19:34 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id B083C40395 for ; Thu, 18 Nov 2021 21:19:32 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 0159F20ABAED; Thu, 18 Nov 2021 12:19:32 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0159F20ABAED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1637266772; bh=2Fi0IuHpvCns/KBNQQZ/rzoIqD3YRUZSIU7W/1YBrq8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZXci1cO1DCAZe71WDu50SmQyP2mBTRQmmQko6lD9Scn0HcPcy+85ghPQ4ZYZyK7fk 5+yYIpe4aDveYQs9ytowwxMBVC0ONSaR20OysyKMZpol2ApggyDzqRH9BEdULDQvUF 9SpNSHAUDPlCLrkXzOFIHB+XHpjPo7eemVgPS8kk= Date: Thu, 18 Nov 2021 12:19:31 -0800 From: Tyler Retzlaff To: eagostini@nvidia.com Cc: dev@dpdk.org Subject: Re: [PATCH v1] gpudev: return EINVAL if invalid input pointer for free and unregister Message-ID: <20211118201931.GA6492@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <20211118192802.23955-1-eagostini@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211118192802.23955-1-eagostini@nvidia.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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 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 isn't isiolated to only this change but since additions and context in this patch highlight it maybe it's a good time to bring it up. it's frustrating to have to carefully read the implementation every time you want to make a function call to make sure you're handling the flavor of error reporting for a particular function. if this is new code could we please clearly identify the current best practice and follow it as a standard going forward for all new public apis. thanks!