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 4B3E3A0562; Tue, 4 May 2021 11:36:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2F31D4014D; Tue, 4 May 2021 11:36:33 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 133A340141 for ; Tue, 4 May 2021 11:36:29 +0200 (CEST) IronPort-SDR: Fqmyb7vLYKYjFADuzdlTBODwEQ1iaTvd8xMJ+UF1BE9DSbifItA0szVbRJMRqU0QMRoe/kfRpv Jj01/FSXdSxA== X-IronPort-AV: E=McAfee;i="6200,9189,9973"; a="195887174" X-IronPort-AV: E=Sophos;i="5.82,272,1613462400"; d="scan'208";a="195887174" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2021 02:36:28 -0700 IronPort-SDR: aiGZ6WkP2AEk7OrIeExgSjco4r6/ztqp5EnwaTMnXMFfIy/pQNGvYwfkuQF75bjgejJKGtymhw +6ID0kxy1wcw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,272,1613462400"; d="scan'208";a="621469479" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga005.fm.intel.com with ESMTP; 04 May 2021 02:36:28 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 4 May 2021 02:36:27 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 4 May 2021 02:36:27 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Tue, 4 May 2021 02:36:27 -0700 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.168) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Tue, 4 May 2021 02:36:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VDSRcTEh+7XHnK94PhvdzXj4V7c+WwovT+GOrgBJZJDsnZO5lm2MaiE1bYRXuhvhEiT6rgN1w6eds2RzfTOsP5hFfI1MgEjEuBdIPCYrGmFNB55dyoe6i+DWFK4sS+Tz9+t8WBzFlVcQhgOzTmf99x3l1BqNjLwl48s+cy4KG7Ypiuco2A1y4eqHkmKpOFiUD73SulxCNeLf1WR86sajbjPYDXOqWDwn2VTiOQPF+Bg7pGrX4gy7D8UZJ4+SEByxxNQA83qRnLVLDzaLvv/riWM535K0AgPPEk3aeCnY2JJcZe8ISdVd1FWeJqwQ+fShc2Sf9JjJEA6Qp9IU4sjl2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Rdo9c8uIAuGYF9YOOJHj+A84xhgFeJp7x/ZODC9GNes=; b=RVk1BBN/lSIM3Zd6xZOce+2bKDXV3VoiqGXUL8+NLoIOximH14gK05R1FB7GBTKxi6iGnfI7DLrpqwwHxrAJ4yS++3LcAcGZyXM+upQD1mE0YAcR73h8iWVk9SuxdVOK0XADE72D7s8BtXSDg8DBBy/dG+VkZi5FhCzFeqX/T1y2lkWwAMBab6dHGTRUDayj0Jvj+0gD2yyN+sSwndhFMhKduCqBYmdO9wKfyv6E7nGX283TZOOtXx48Ryqnpo/cf2n6Vm7IKtBhL82577BpleutHuw/2O75wZCTTD5uyYGH6cFdfCupeyPn7gzqoOPiS3Zm6tqeXab+Kzcn7MpaRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Rdo9c8uIAuGYF9YOOJHj+A84xhgFeJp7x/ZODC9GNes=; b=pWr9tTJgk3IVOqQOS/kGyLaqyKLGriSH2FuCZ7TdYKKns0tbLxCbJ0czJ9IvUeNxyIwa4uFc/vMlNthQD10YNZE1H3exB3XHyPEB9RPwMK49/DI2yWByux0lQMShHNUWb5nCMMWAC7KmiaU1g4JLIQCrMqlKA/YUfkX2fqRfOVo= Received: from DM6PR11MB4491.namprd11.prod.outlook.com (2603:10b6:5:204::19) by DM6PR11MB2843.namprd11.prod.outlook.com (2603:10b6:5:c7::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.42; Tue, 4 May 2021 09:36:25 +0000 Received: from DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::15ed:b4f4:540e:ea0c]) by DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::15ed:b4f4:540e:ea0c%7]) with mapi id 15.20.4087.044; Tue, 4 May 2021 09:36:25 +0000 From: "Ananyev, Konstantin" To: Dmitry Kozlyuk , Tyler Retzlaff CC: "Yigit, Ferruh" , "hemant.agrawal@nxp.com" , Ajit Khaparde , "Jerin Jacob" , Thomas Monjalon , "Andrew Rybchenko" , "Min Hu (Connor)" , "dev@dpdk.org" , "olivier.matz@6wind.com" , "david.marchand@redhat.com" , "jerinj@marvell.com" , "Richardson, Bruce" Thread-Topic: [dpdk-dev] Questions about API with no parameter check Thread-Index: AQHXK6E3xJikooZ6YEaOvbZgfuEAp6qo7l8AgAAC9HCAABjHgIAAFpcAgAAMkgCAAAxmAIAilS2AgAAqpgCAB0AxkA== Date: Tue, 4 May 2021 09:36:24 +0000 Message-ID: References: <6114bde2-423a-da82-ac4d-608141235e39@huawei.com> <1672555.D3d3fyF7jD@thomas> <39bb5d09-9e95-db2d-929f-b0b3e922d921@oss.nxp.com> <68bb19fb-2d1a-677d-05f2-e2029d5095a5@intel.com> <20210429161645.GB21799@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> <20210429214924.308a636b@sovereign> In-Reply-To: <20210429214924.308a636b@sovereign> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [109.255.184.192] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fa743825-624c-4268-026f-08d90ee015d6 x-ms-traffictypediagnostic: DM6PR11MB2843: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 5bLY6t+AWIeImfySyumN469uqusQw8z/qvNDEPnfarlbimL9LPpG1X7es4Ab+qyg96LZn86glpAFybRSApFFCXdURJwrHCBfp/fxmn4NGnRjSCEYX1E5FLSjl4GKocBUcqbuiS6eqrV5QzN3CYEdXbiK6rE4NTbV6AYXAT6EQQDBDkrCsRxUvstk2akLcIWQ+UNtIQ3sZXbQ23GdMcAynbdUb9MdBUYDu9JP+iBIKoIOqfDfVoHBax+K8CWKngnOYit3OdK7sqUUVhmjWE7UDHz886Hx6jijxPItYbz6F04d+cDRPvpIDUHdhnZKzoU5L1iTz+fFteZwBdgyfU+Ko2aeY+nWKXcHHH+FYNFC6mIDLcpSYDwoLO3OAjOiXXORnIh862eotElzfPYdzME+seFaj7lrJsmOoxYwEX8X3cw+x2vbBs1cONUGLeewyzvQSZNXXmsEquzx6GwHRUpY3JzC7BePXJm8huHXpP8pRLvrmMx4hLVnGqi7GAEJWUKD5ztzBkb4aDhOosXlkWi0KQ9ajd+aM3uk7+HfGt8opEB/rtmuEtNWz0UviO/Xbp8+pghqOL7chHgazv2Oy4+zMPNUS+lOsyxeNKEAJ54rIA4= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4491.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(376002)(396003)(366004)(136003)(39860400002)(110136005)(33656002)(7696005)(54906003)(2906002)(86362001)(83380400001)(9686003)(8676002)(55016002)(316002)(8936002)(76116006)(478600001)(71200400001)(107886003)(66946007)(186003)(7416002)(52536014)(5660300002)(53546011)(55236004)(26005)(122000001)(66476007)(64756008)(66446008)(4326008)(66556008)(38100700002)(6506007); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?1edpxzITfy9uGo5OpBHIFc+GIkkmxJI8+IZu6ZuLtxIGwVYmmjxKg8gjcbPH?= =?us-ascii?Q?Thqjck0qtUC8+dGSX32v4sLU9uBQNAZeLqp2zsmqdp4E5f6gSwtA/RrJQuoG?= =?us-ascii?Q?Oh2yVQXVkB5t5FZoXaVhtyy9X8lhJ5ndhzSzO0mMThiNMi6k/0fYKSRb3mLP?= =?us-ascii?Q?hHUMPTqG1xBGezbH/sWi7xEh+IMEK56/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?= =?us-ascii?Q?ych//u1e4BUmKapQg8Wwd+Cc6IOkIJlv3q37xzaO2bYgHDlYTzYoc8qOZ3uc?= =?us-ascii?Q?7Ho7P//NJahZsM828FRTFumrIJ7xnDWmvDo/kMnXTJ5aSOcA3EStQb3Fasfq?= =?us-ascii?Q?i0h6SRRI4qwNcODQ0LnzWXcOXoNTgPSvyDWvGj1Gmq7UfKs2YaclcYDlDjiL?= =?us-ascii?Q?Z4fzr6I2u2bnyzrm1wkUTw+rex6JgrFvxp27KGiXuFnXF06zNfJhC8zKRoKk?= =?us-ascii?Q?OS5w0XNuEWJTbIijNZDKCA29?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4491.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa743825-624c-4268-026f-08d90ee015d6 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 May 2021 09:36:25.0046 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: E8/Xn3GSA8Ze5wPQp1VnTt4U3H+ZP6O8v/LXnbibSwvQsZwpQK2/dUpZHxKKEUcGRf27oIHmN1Yn+M96y+j0JrIeYo1dB1lW5cu/o0FJBv4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2843 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] Questions about API with no parameter check 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 Sender: "dev" >=20 > 2021-04-29 09:16 (UTC-0700), Tyler Retzlaff: > > On Wed, Apr 07, 2021 at 05:10:00PM +0100, Ferruh Yigit wrote: > > > On 4/7/2021 4:25 PM, Hemant Agrawal wrote: > > > >>+1 > > > >>But are we going to check all parameters? > > > > > > > >+1 > > > > > > > >It may be better to limit the number of checks. > > > > > > > > > > +1 to verify input for APIs. > > > > > > Why not do all, what is the downside of checking all input for contro= l path APIs? > > > > why not assert them then, what is the purpose of returning an error to = a > > caller for a api contract violation like a `parameter shall not be NULL= ` > > > > * assert.h/cassert can be compiled away for those pundits who don't wan= t > > to see extra branches in their code > > > > * when not compiled away it gives you an immediate stack trace or dump = to operate > > on immediately identifying the problem instead of having to troll > > through hoaky inconsistently formatted logging. > > > > * it catches callers who don't bother to check for error from return of > > the function (debug builds) instead of some arbitrary failure at some > > unrelated part of the code where the corrupted program state is relie= d > > upon. > > > > we aren't running in kernel, we can crash. >=20 > As library developers we can't assume stability requirements at call site= . > There may be temporary files to clean up, for example, > or other threads in the middle of their work. >=20 > As an application developer I'd hate to get a crash inside a library and > having to debug it. Usually installed are release versions with assertion= s > compiled away. I agree with Dmitry summary above. Asserting inside the library calls is bad programming practice, please keep it away from the project.=20 >=20 > Log formatting is the only point I agree with, but it's another huge topi= c.