From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ilya Maximets Subject: [PATCH] ethdev: keep port_id unchanged if obtaining by name failed Date: Thu, 18 May 2017 15:19:40 +0300 Message-ID: <1495109980-3236-1-git-send-email-i.maximets@samsung.com> References: Cc: Heetae Ahn , Ravi Kerur , Ilya Maximets To: dev@dpdk.org, Thomas Monjalon Return-path: Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id CAFD1324C for ; Thu, 18 May 2017 14:19:58 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OQ500EX7E98TH30@mailout1.w1.samsung.com> for dev@dpdk.org; Thu, 18 May 2017 13:19:56 +0100 (BST) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently, 'rte_eth_dev_get_port_by_name' changes transmitted 'port_id' unconditionally. This is undocumented and misleading behaviour as user may expect unchanged value in case of error. Otherwise, there is no sense having both return value and a pointer in the function. Fixes: 9c5b8d8b9feb ("ethdev: clean port id retrieval when attaching") Signed-off-by: Ilya Maximets --- lib/librte_ether/rte_ethdev.c | 1 - lib/librte_ether/rte_ethdev.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 83898a8..64aefdd 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -339,7 +339,6 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id) if (!nb_ports) return -ENODEV; - *port_id = RTE_MAX_ETHPORTS; RTE_ETH_FOREACH_DEV(i) { if (!strncmp(name, rte_eth_dev_data[i].name, strlen(name))) { diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 0f38b45..9a19974 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -4587,7 +4587,7 @@ rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id, * @param port_id * pointer to port identifier of the device * @return -* - (0) if successful. +* - (0) if successful and port_id is filled. * - (-ENODEV or -EINVAL) on failure. */ int -- 2.7.4