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 C6C7AA0548; Thu, 2 Dec 2021 14:56:12 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 56FAC41223; Thu, 2 Dec 2021 14:56:12 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 4C8D140692; Thu, 2 Dec 2021 14:56:11 +0100 (CET) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH v1] gpudev: return EINVAL if invalid input pointer for free and unregister Date: Thu, 2 Dec 2021 14:56:08 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D86D34@smartserver.smartshare.dk> In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v1] gpudev: return EINVAL if invalid input pointer for free and unregister Thread-Index: AQHX3G4EdhDcLThKtEqIWzyJTUtRGqwJulSAgADeAwCAAAZHAIAIWNsAgAALPgCACzvMgIAAolgAgABYBICAAAcRYIAACsVQ References: <20211118192802.23955-1-eagostini@nvidia.com> <20211201213749.GA5097@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> <3625450.hdfAi7Kttb@thomas> <98CBD80474FA8B44BF855DF32C47DC35D86D33@smartserver.smartshare.dk> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Ananyev, Konstantin" , "Thomas Monjalon" , "Tyler Retzlaff" , "Richardson, Bruce" Cc: , , "Andrew Rybchenko" , "David Marchand" , "Yigit, Ferruh" 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 > From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com] > Sent: Thursday, 2 December 2021 14.01 >=20 > > > From: Thomas Monjalon [mailto:thomas@monjalon.net] > > > Sent: Thursday, 2 December 2021 08.19 > > > > > > 01/12/2021 22:37, Tyler Retzlaff: > > > > On Wed, Nov 24, 2021 at 06:04:56PM +0000, Bruce Richardson = wrote: > > > > > if (ret < 0 && rte_errno =3D=3D EAGAIN) > > > > > > > > i only urge that this be explicit as opposed to a range i.e. ret > =3D=3D - > > > 1 > > > > preferred over ret < 0 > > > > > > I don't understand why you think it is important to limit return > value > > > to -1. > > > Why "if (ret =3D=3D -1)" is better than "if (ret < 0)" ? > > > > Speaking for myself: > > > > For clarity. It leaves no doubt that "it failed" is represented by > the return value -1, and that the function does not return errno = values > such as > > -EINVAL. > > >=20 > But why '< 0' gives you less clarity? > Negative value means failure - seems perfectly clear to me. I disagree: Negative value does not mean failure. Only -1 means failure. There is no -2 return value. There is no -EINVAL return value. Testing for (ret < 0) might confuse someone to think that other values = than -1 could be returned as indication of failure, which is not the = case when following the convention where the functions set errno and = return -1 in case of failure. It would be different if following a convention where the functions = return -errno in case of failure. In this case, testing (ret < 0) would = be appropriate. So explicitly testing (ret =3D=3D -1) clarifies which of the two = conventions are relevant.