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 42A94A0A0E; Wed, 7 Apr 2021 17:25:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2385A140FC7; Wed, 7 Apr 2021 17:25:48 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2089.outbound.protection.outlook.com [40.107.21.89]) by mails.dpdk.org (Postfix) with ESMTP id E7C38406A3 for ; Wed, 7 Apr 2021 17:25:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HgLm9QqiFGPW2ijvB41TczVfsOxR+pmeK1KP9T8wyNkxSrfqQPt/m2qhIfeFBxSrmMPEy47ac14RdSOjKgfc4XLrrtiCXbSE1wgm6bDcSfV1q9kJ6tLuu4O8unVj0acmCKD+p/31AYU3fcNFj0K2eXdp4QRcPEjY5bN8bLyIUcbcJnClvulmZ7EtW3S/FUUTD+UP+S4UB0CFpjI6Ew/FaIL5r2wi27HzXWIshRuMLy9DUvSyzpjX4pjM0xkP0En16HcYWtmJ+M+gY5qtFaVSt7rno+cbmrE3IGMNJIuQ+D242gWEAzULIxbrXPCZkGKwzHeWgFUC7qK8ZG+C6fmJJQ== 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=zj7mFgC9AuSS0NPcbxfpz3mvBbUgJ/VrugyIivT8kwU=; b=fSKCa5ubBgOWTl2usOXT1kPjeWC5JiO+UxndWnIzUqkWlpu1Qx0ExRWes6/fSKruive6CXJ8L6zEYeaRW2kFrDwleiNT9lPBiDwUc5WPWCCSd0pqBx1phiCHzO99xoGrfv5vR/MHt7J5MgO03QrUt4zq3+BeyE0wo0bRUd9HbfMlFYYaqApXKTcV7keA2+sFAXLSIbq0sBd+nnMPVqfVG655SiBD44TaxSi/NaAth/m6k1jZRkrDEbnmEkrs0XnrCRoDbZw5G5uFONDkANXAqzRUdSJmXz+57LUc5QmHB/SALOph+lygDsT0bYBv+BlRVAGv2cznIEP0IVFpYpnByQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zj7mFgC9AuSS0NPcbxfpz3mvBbUgJ/VrugyIivT8kwU=; b=gbsmWSTXfeahHPC+j8stv/5yJkDkQeykh5yc9PcChIe6afLdVdSHZMxxMvcEFA8HpwoQxEqUwMi1Lvabf2ohN+iZU+xZvh73hWvozKccjLWL+j+M6VRUeXN7oUAprk67BYb6yo0IPp/jCAJwDj+GFe5q1wA8e7VLNNJskvsamzU= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB4456.eurprd04.prod.outlook.com (2603:10a6:20b:22::25) by AM7PR04MB6872.eurprd04.prod.outlook.com (2603:10a6:20b:106::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.27; Wed, 7 Apr 2021 15:25:45 +0000 Received: from AM6PR04MB4456.eurprd04.prod.outlook.com ([fe80::ad9e:a38e:e84e:bf55]) by AM6PR04MB4456.eurprd04.prod.outlook.com ([fe80::ad9e:a38e:e84e:bf55%6]) with mapi id 15.20.3999.032; Wed, 7 Apr 2021 15:25:45 +0000 To: Ajit Khaparde , Jerin Jacob Cc: "Ananyev, Konstantin" , Thomas Monjalon , "Yigit, Ferruh" , Andrew Rybchenko , "Min Hu (Connor)" , "dev@dpdk.org" , "olivier.matz@6wind.com" , "david.marchand@redhat.com" , "jerinj@marvell.com" , "hemant.agrawal@nxp.com" , "Richardson, Bruce" References: <6114bde2-423a-da82-ac4d-608141235e39@huawei.com> <1672555.D3d3fyF7jD@thomas> From: Hemant Agrawal Message-ID: <39bb5d09-9e95-db2d-929f-b0b3e922d921@oss.nxp.com> Date: Wed, 7 Apr 2021 20:55:38 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [223.178.219.73] X-ClientProxiedBy: BM1PR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00::22) To AM6PR04MB4456.eurprd04.prod.outlook.com (2603:10a6:20b:22::25) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.2] (223.178.219.73) by BM1PR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Wed, 7 Apr 2021 15:25:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d358f29a-bd47-4128-ad6b-08d8f9d969da X-MS-TrafficTypeDiagnostic: AM7PR04MB6872: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True 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: mkWn103XUOaQiX+LZzifR59Pr4XaeL/LociAy3y0gRwOFjHyNfxHKZr3OwwUkskxUZxeEdv2GB1PJU67+MKo7N2IJMfnlLg5cCYqOavW6A4A+jFj8WTDvynbWMgM8ONcBbF0iBDTbMIP8vw/mi05FYc6b9lywasu1NnwF2yDZ8X9YRODNHbo1+Ieq8oS3quuKxOcFQz2cEMddHiG7WAjZT0VyUwGnk9Cxm/QvjfZp8vBbvIJco48JNRHQdoEQk2WHgQTcY5NkSYa2CW7K8OifHKuxzGivDqDX683PV7P/G22QrkDVOkl97yDsuAPRwfctDc18Kvm/eOOY51F5Uzn33uqQJWHDn3xnBxseye0FFgIqLoe5U9bi8chKl3B2jvbkXeInZ7SUpjIbzRmGfpcEgfkOgFKnMseD7Mk7hJ/3+epBLnKN8vVW9otpfitfHS1N+9gxnSe5TatXB+XpMoORIXwWqTq2493Ni3Ans4jagGClvH9cduLK3y5mufZukaRE6SSzo3mY83KYoxI7ApEb2IuonrBzbVejcgo/1APTwWI3/FM8igmPt3138b7LgLV2rS0VNq8Q6dou1fXdqIz1mtoU4pq3Tnktq3M54ckG9t9h5acBKbgZC88v3OjqXibVukKaqRet+UKeDtN7jgvjXKxL0k2QxKmqIfxF60PnJMh3JWWjju3ABA6ozc9y+GWbK/AI7SdbqnbawaoJb39M5z65M9uH2LAc3nhB10kpTJeeP14yqxPVdpluDZ60nHt X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB4456.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(396003)(346002)(136003)(39860400002)(7416002)(66946007)(38100700001)(44832011)(8676002)(2616005)(956004)(8936002)(5660300002)(38350700001)(186003)(16526019)(83380400001)(6666004)(86362001)(6486002)(31696002)(4326008)(26005)(478600001)(52116002)(31686004)(2906002)(54906003)(110136005)(16576012)(316002)(53546011)(66476007)(66556008)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?emMvV0lMVTYzaUtMY1Z2UVFrVmdPb0tBUTF1d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nNNMXk1dXdsOFpqdz09?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d358f29a-bd47-4128-ad6b-08d8f9d969da X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4456.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2021 15:25:45.3722 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zSTzCdgEUzFhvjjdG1O2jYCLu1CfMd/4FYUoeIKg2U9i9hn0m/6NdAQHnjQqkhD3wIzF2HmRskaWDPdYz3I5kA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6872 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: , Reply-To: hemant.agrawal@nxp.com Errors-To: dev-bounces@dpdk.org Sender: "dev" On 4/7/2021 8:10 PM, Ajit Khaparde wrote: > On Wed, Apr 7, 2021 at 6:20 AM Jerin Jacob wrote: >> On Wed, Apr 7, 2021 at 5:23 PM Ananyev, Konstantin >> wrote: >>> >>> >>>> 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? >>> As I can see these are control path functions. >>> So some extra formal parameters check wouldn't hurt. >>> +1 from me to add them. >> +1 to add more sanity checks in control path APIs > +1 > But are we going to check all parameters? +1 It may be better to limit the number of checks. >> >>> Konstantin >>> >>>