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 09C09A0A02; Wed, 7 Apr 2021 13:40:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 842874069F; Wed, 7 Apr 2021 13:40:41 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by mails.dpdk.org (Postfix) with ESMTP id 9AD684013F for ; Wed, 7 Apr 2021 13:40:39 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 0E2085C0140; Wed, 7 Apr 2021 07:40:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 07 Apr 2021 07:40:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm3; bh= qcs3NmPcQHC/aNZuiBh3Ajd+qFkVrHCh8dNA1+62wp8=; b=trR1OK78/mkHE+ZH BVpTqI7fX1rv53lVqlR0uwQMiAlNBFJbxfpGtyt3UhEH6SB/9PbpKgwGY4KXMKzO JAXG/q7vIbBK/zrjwwAhjbKXMkukXwMeKuFyZUHEHPNlTgeqqq0OkaenQEKSOxau LJ/lGrPhu81khUkRQTOyT5+5ZLFt3qP8zHJTuAsnazymFzsdPbKoyxVk8qIeJqvn Ch1Z1yrhLzxmkcVXp6vJpFUX5fOF2xH/SpnaTiJJ2W5tPc/2oSwzvfeECDIR4Zn1 i40PhJ5g380lwDh/HIdySAxNwe+SZm3i2TQKfllPAURIW6gNSRPGO8OJGfuVmOV1 7+NuXw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=qcs3NmPcQHC/aNZuiBh3Ajd+qFkVrHCh8dNA1+62w p8=; b=RZgInbvh/Qv6eQg6RFa4IV5WJn0PgRAmnwK7IRBxNq3JUm1nI04eUt3pF pJp195db7VPFGOF3Rzm6t2RtbXX8aKAqL+2XKWg8dl+uAwgGDgXkQgD1ajC4o/U3 2X5ZrEoaFI5WB9/X4gxHSAUDrI5zu8BshHc6UUSjGRxsMkyaUZ82Bm8pZVJsPrhp Lae1AluRT6QlyeQm0GYfxn+IjJ1u7XSEImSyZB2EYTq3YPt7OYHNnAbOSu1aLrNY GOVu0IZghh82C9LqikmY4kTCTGXS7BBb8G2tk7pViGne5jFTJLtudg1YI0DgvZWW rgNn6g1AwCtD1fhGSi4nUhDZzZSnA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudejjedggedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepudeggfdvfeduffdtfeeglefghfeukefgfffhueejtdetuedtjeeu ieeivdffgeehnecukfhppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghl ohhnrdhnvght X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id BB35B1080063; Wed, 7 Apr 2021 07:40:36 -0400 (EDT) From: Thomas Monjalon To: Ferruh Yigit , 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, bruce.richardson@intel.com Date: Wed, 07 Apr 2021 13:40:32 +0200 Message-ID: <1672555.D3d3fyF7jD@thomas> In-Reply-To: <6114bde2-423a-da82-ac4d-608141235e39@huawei.com> References: <6114bde2-423a-da82-ac4d-608141235e39@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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_info) > > 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 == NULL) > return -EINVAL; > ... > } > > Or, that is redundant, the parameter correctness should be guaranteed by > the APP? > > What's your opinion? Hope for your reply. 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. I don't have a strong opinion. What is your opinion? Others?