From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AB2CEA04B5; Tue, 27 Oct 2020 14:41:37 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AAAA14C89; Tue, 27 Oct 2020 14:41:34 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 64D1737B4; Tue, 27 Oct 2020 14:41:32 +0100 (CET) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CLCXs3M3tzLqJw; Tue, 27 Oct 2020 21:41:33 +0800 (CST) Received: from localhost (10.174.187.156) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Tue, 27 Oct 2020 21:41:23 +0800 From: wangyunjian To: CC: , , , , , Yunjian Wang , Date: Tue, 27 Oct 2020 21:41:22 +0800 Message-ID: <1603806082-21484-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.187.156] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v2] ethdev: fix data type for port id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" From: Yunjian Wang The ethdev port id should be 16 bits now. This patch fixes the data type of the variable for 'pid', changing from uint32_t to uint16_t. We also need use RTE_BUILD_BUG_ON() to ensure that RTE_MAX_ETHPORTS is less or equal to UINT16_MAX. Fixes: 5b7ba31148a8 ("ethdev: add port ownership") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang --- v2: add RTE_BUILD_BUG_ON() check for RTE_MAX_ETHPORTS validity --- lib/librte_ethdev/rte_ethdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index b12bb3854d..ecaca5c600 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -816,7 +816,7 @@ rte_eth_dev_get_name_by_port(uint16_t port_id, char *name) int rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id) { - uint32_t pid; + uint16_t pid; if (name == NULL) { RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n"); @@ -4292,6 +4292,8 @@ RTE_INIT(eth_dev_init_cb_lists) { int i; + RTE_BUILD_BUG_ON(RTE_MAX_ETHPORTS > UINT16_MAX); + for (i = 0; i < RTE_MAX_ETHPORTS; i++) TAILQ_INIT(&rte_eth_devices[i].link_intr_cbs); } -- 2.23.0