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 E207AA0C3F; Thu, 15 Apr 2021 17:45:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C96EB16238E; Thu, 15 Apr 2021 17:45:43 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id DE12716237B for ; Thu, 15 Apr 2021 17:45:41 +0200 (CEST) IronPort-SDR: 257VoUsO3oDnz1mD4BNluhY18eabThvFP4BGpoz21AQJanevD6KCjotV1VSBj8iCBwV1BCEbaM R9Hod5sMSTnQ== X-IronPort-AV: E=McAfee;i="6200,9189,9955"; a="194988471" X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="194988471" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 08:45:40 -0700 IronPort-SDR: inTDVopm8ENPI+wSa/ET0B65xVlT5g7CWo8divZvPG6bUeVPqq7iFNOCBQGrsoCj6wXSJUa38n mKhcF53mqBbg== X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="399608956" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.238.144]) ([10.213.238.144]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 08:45:39 -0700 To: "Min Hu (Connor)" , thomas@monjalon.net, andrew.rybchenko@oktetlabs.ru Cc: dev@dpdk.org References: <1618046334-39857-1-git-send-email-humin29@huawei.com> <1618484959-4360-1-git-send-email-humin29@huawei.com> From: Ferruh Yigit X-User: ferruhy Message-ID: Date: Thu, 15 Apr 2021 16:45:36 +0100 MIME-Version: 1.0 In-Reply-To: <1618484959-4360-1-git-send-email-humin29@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v5] ethdev: add sanity checks in control APIs 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" On 4/15/2021 12:09 PM, Min Hu (Connor) wrote: > This patch adds more sanity checks in control path APIs. > > Fixes: 214ed1acd125 ("ethdev: add iterator to match devargs input") > Fixes: 3d98f921fbe9 ("ethdev: unify prefix for static functions and variables") > Fixes: 0366137722a0 ("ethdev: check for invalid device name") > Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") > Fixes: 5b7ba31148a8 ("ethdev: add port ownership") > Fixes: f8244c6399d9 ("ethdev: increase port id range") > Cc: stable@dpdk.org > > Signed-off-by: Min Hu (Connor) > Reviewed-by: Andrew Rybchenko <...> > @@ -2684,8 +2767,14 @@ rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats) > struct rte_eth_dev *dev; > > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > - > dev = &rte_eth_devices[port_id]; > + > + if (stats == NULL) { > + RTE_ETHDEV_LOG(ERR, "Failed to get ethdev port %u stats by NULL\n", > + port_id); > + return -EINVAL; > + } > + > memset(stats, 0, sizeof(*stats)); > > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP); Not exactly related to this patch, but related to the API input, some input that is filled by API is memset first before passing it to the PMD, which makes sense. And for this we have two different ordering with dev_ops check: 1. memset(input) check dev_ops, return error if not supported call dev_ops 2. check dev_ops, return error if not supported memset(input) call dev_ops Connor, Thomas, Andrew, Do you think does it have any benifit to unify it, and is one better than other?