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 4B9D9A0A0C; Wed, 7 Apr 2021 13:53:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2FD61406A3; Wed, 7 Apr 2021 13:53:17 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 55E3F4013F for ; Wed, 7 Apr 2021 13:53:15 +0200 (CEST) IronPort-SDR: WJ5yfb09UyCgLB2XGmmwWegogbsKKPc5xpLYrzT3V2glMIhpYTJfHxnAJ6pvKxpGgf50oLOTPN mCXltztcY8DA== X-IronPort-AV: E=McAfee;i="6000,8403,9946"; a="180419969" X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="180419969" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2021 04:53:14 -0700 IronPort-SDR: WYvVFhFtGoX0n4sLDmsWHDoUJEtyo1uJlxNPJTRKF35ufNmBDaNkmMQdNJpIqhDDrOKG5Dl2AY wS3TrSk6Cu3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="415237267" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga008.fm.intel.com with ESMTP; 07 Apr 2021 04:53:13 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 7 Apr 2021 04:53:13 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) 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 via Frontend Transport; Wed, 7 Apr 2021 04:53:13 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.107) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Wed, 7 Apr 2021 04:53:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TJmLBlTrEBS1ILcCFcqe3T2fGViw/kiH+3qbz+vQRcFQTgH46KGkDHmOF+6zjhr7MwGqTWUVx5eRzqBTYAH7mzCYNxSs6IdOfKjkbsJAH4zz5vrkmDoa6InD6b8sq+fKM49fvHRxayF5kz8N4LNTIbLNY3jlwJoLhpgnrdhCmyV3Mp343vuJjiC/BvbT85O+z+qKxS+C2MX7RldkOmYAYEEp7lymKfiFltM1M9hb5v7Sl9os3T7FnstIyUpdeYL8u0MKkofZvuCqeRPlZwmB35ls3jDEK76THClA/r8azDOiygwKIJnf9Fwp24JE/Nx3tWgAY5JSXFQw/4b+2EyTOw== 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=N2QxWCyKNoE+A4edUNz+VrgF+1Fiaelsrj16JvO3/6w=; b=D3NDhHzTQzQ3c9bFJX6ZBDSNRlkleFZe8sNvBgkX98uiK+cpMq5qO/UQsQDEtwCJVJ3ltulGCVDdXb9RRZJVyF5VD0PVqFLPf2Tu3lFs7d4bZ2jkgp3I6DnO1RTN6eIzS51djYV0yWNDFBkxEp/BjoehyY5ozBC8VPDpR2u/jHzO4fVDzl5Xlt8aGtvhnspY4hI/dFucVm0287SNJJkHC15bFj1Eb2l3NbnZuUVoi5FmfidRKNoGk6eCpzn83x1DagHSTxSH2rKSqOb1QLcNj/Y/p4PDcwZBgez+S1IKDbJC4pJ6fH0Fu1C1sqdC9BApq9djP6PCuTZcqXcVmj0/GA== 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=N2QxWCyKNoE+A4edUNz+VrgF+1Fiaelsrj16JvO3/6w=; b=Bqgg/bhhBn92IGKT/7TeuPW03BTc97zzlWb4SdxcI2lTQod+PdViMtxI62t4AWFmSiz7UNhxDjn75uxdUMxznBBVNSNkzQvVfepNBvfjvSBIWuXy0T040z352VdJGLSR7YkTrbmeGajC1ifqqVaTtewnH3pTzvipaJFf2ktDpZY= Received: from DM6PR11MB4491.namprd11.prod.outlook.com (2603:10b6:5:204::19) by DM6PR11MB3769.namprd11.prod.outlook.com (2603:10b6:5:142::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Wed, 7 Apr 2021 11:53:10 +0000 Received: from DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::3182:6da2:8c64:f07a]) by DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::3182:6da2:8c64:f07a%3]) with mapi id 15.20.3999.032; Wed, 7 Apr 2021 11:53:10 +0000 From: "Ananyev, Konstantin" To: Thomas Monjalon , "Yigit, Ferruh" , Andrew Rybchenko , "Min Hu (Connor)" CC: "dev@dpdk.org" , "olivier.matz@6wind.com" , "david.marchand@redhat.com" , "jerinj@marvell.com" , "ajit.khaparde@broadcom.com" , "hemant.agrawal@nxp.com" , "Richardson, Bruce" Thread-Topic: [dpdk-dev] Questions about API with no parameter check Thread-Index: AQHXK6E3xJikooZ6YEaOvbZgfuEAp6qo7l8AgAAC9HA= Date: Wed, 7 Apr 2021 11:53:10 +0000 Message-ID: References: <6114bde2-423a-da82-ac4d-608141235e39@huawei.com> <1672555.D3d3fyF7jD@thomas> In-Reply-To: <1672555.D3d3fyF7jD@thomas> 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: monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; 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: 1b3d6624-8557-42dd-a824-08d8f9bbb7a1 x-ms-traffictypediagnostic: DM6PR11MB3769: 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:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2p9AziPt01wPPn1wcOJhiWjjh3ivb6yGPKWgqbQz+Aml7LIWanvfdG1w369QgbfAMsIP9sWRUigioJhBd44SL3BiAPJ3jV0MuYtqU3dHFt6Shnnyr62cRLK0m9bldKvKoCHlJASTHZRHGNlfOA6GvphcpamVED9oBCQ/kQ1CkolMOdO6N3QgqfwRqzqPu7a3SiNulLdc8aN3ttyaMXGQJse7lH+aru7gyqtr8C6HElKUVT/bqp9GVnJPLF0kcWO2XrTaNNrPXDwmJhoTOUIvbOYRmUP3JHHfCtLxOr4GQrfVVUE3CfPJxKikpswSq4y3Nmb367FTU45fMxCEfTyM/N2+X6uQIYeditZhYNNSX2DHMw57XuYjBrKO6zQ4jeRjMExsOqcZCoILfrBeuEfD6Bkg5QpVP49iSY1WuZMR+hKZbTvLCDiSn8iD4cRXGbBZSsK4ihSXaoFIRic77me/xeuEXnpa23qzb6Ifq3J2Y15uqpRb5YxlS55XtlWF/iNg+UsckoVz8IiLu0tskZNBsz87UsEeAFVJMWjK5Q0kDrRrfuCRzN6wVyNdPbk2RIkVT2EoCkLTuQ7xZHfyudnFVpAIac6Y4148BYshfzV7EiR5bXslOis9guew+2MXbVwKbRAKveeXeRIi4HCw2xnIOwEy//+Nsp6El1yU0tKH1Ro= 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:(136003)(376002)(366004)(396003)(39860400002)(346002)(2906002)(110136005)(8936002)(4326008)(316002)(26005)(52536014)(8676002)(186003)(107886003)(7696005)(66446008)(64756008)(66556008)(55236004)(6506007)(5660300002)(55016002)(33656002)(71200400001)(9686003)(478600001)(54906003)(66946007)(76116006)(66476007)(38100700001)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?A4SNw9tVHUmhEJe6xYn6p78ykmfQl3Mvw5ZQG/s6IsX337x3TYPmlkHLVaL5?= =?us-ascii?Q?01ORfqfCmNH5UfNPM4SoSMnK+3DfJH9jcRwDu1PR6vChUa3atHDRhT5+zRKf?= =?us-ascii?Q?Y72OkEagA46ntRWmYatULbHNU/1ACaHb4S4OkcbwCE4Adt9MmwZgLlUGjgFa?= =?us-ascii?Q?PH8T0mUiQkGnlJ0zDiYdkadQN13qA/USNpuHesqG3+LKlhnZdZ66kDpc4cTm?= =?us-ascii?Q?D6W/hovSC2I4IXiLeIo9ZVtd0bmUIni3PBX4JRxuun1RGgbGUbjJyjppS+O5?= =?us-ascii?Q?e4dReQw37xlB8VYpnae8fvPDPnOl4s9jFgHbO+KA7dhsP3u6OcwEKky+k2jU?= =?us-ascii?Q?OMgdvVT5wkezrtUVEymYG0tNAUuwhDrrnwFKYO5CBGztuufPm5ZJRUAVa2ge?= =?us-ascii?Q?xxQf3d3ekInFk5sKI6fRT9L1BdfHddZb5J/y9mZbkj/iXJWJT6fJ/yNjK0z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/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: 1b3d6624-8557-42dd-a824-08d8f9bbb7a1 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Apr 2021 11:53:10.6451 (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: 5ZzCjuccHLZKeQIBFUIOXyp7PpCAe2BqWlvNIXjKjLxZMJLt+Z6tQB6SnWboG9vhylTd7wwqZC64eq7FG6ubyv93U13veAjd3oghxj2EGMw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3769 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" > 07/04/2021 13:28, Min Hu (Connor): > > Hi, all, > > Many APIs in DPDK does not check if the pointer parameter is > > NULL or not. For example, in 'rte_ethdev.c': > > int > > rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, > > uint16_t nb_rx_desc, unsigned int socket_id, > > const struct rte_eth_rxconf *rx_conf, > > struct rte_mempool *mp) > > > > int > > rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link) > > > > int > > rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats) > > > > int > > rte_eth_dev_info_get(uint16_t port_id, struct rte_eth_dev_info *dev_inf= o) > > > > As these APIs could be used by any APPs, if the APP give NULL as > > the pointer parameter, segmetation default will occur. > > > > So, my question is, should we add check in the API? like that, > > int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats) > > { > > if (stats =3D=3D NULL) > > return -EINVAL; > > ... > > } > > > > Or, that is redundant, the parameter correctness should be guaranteed b= y > > the APP? > > > > What's your opinion? Hope for your reply. >=20 > I remember it has been discussed in the past (many years ago), > and the opinion was to not clutter the code for something that > is a basic fault from the app. >=20 > I don't have a strong opinion. > What is your opinion? Others? As I can see these are control path functions. So some extra formal parameters check wouldn't hurt. +1 from me to add them. Konstantin