From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE39FC433B4 for ; Wed, 7 Apr 2021 11:28:26 +0000 (UTC) Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by mail.kernel.org (Postfix) with ESMTP id 4BAE761130 for ; Wed, 7 Apr 2021 11:28:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BAE761130 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8630D4069F; Wed, 7 Apr 2021 13:28:25 +0200 (CEST) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id CC87E4013F for ; Wed, 7 Apr 2021 13:28:23 +0200 (CEST) Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FFhst6XTTzyNfc; Wed, 7 Apr 2021 19:26:10 +0800 (CST) Received: from [10.67.103.128] (10.67.103.128) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Wed, 7 Apr 2021 19:28:17 +0800 To: "dev@dpdk.org" , Ferruh Yigit , Andrew Rybchenko , Thomas Monjalon From: "Min Hu (Connor)" Message-ID: <6114bde2-423a-da82-ac4d-608141235e39@huawei.com> Date: Wed, 7 Apr 2021 19:28:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.103.128] X-CFilter-Loop: Reflected Subject: [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" 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. Thanks.