Skip to contentSkip to conversation

ethdev: fix build with gcc 5.4.0

PATCH Applied Thomas Monjalon 1 participant 2 messages Jul 6, 2017 – Jul 13, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethdev: fix build with gcc 5.4.0

Seen on Ubuntu 16.04 with GCC 5.4.0:

lib/librte_ether/rte_ethdev.c: In function 'get_mac_addr_index':
lib/librte_ether/rte_ethdev.c:2369:26: error:
'dev_info.max_mac_addrs' may be used uninitialized in this function

Indeed, rte_eth_dev_info_get() do not write into dev_info if the port_id is not valid.
So we need to check the port_id and return in case of error.

This extra check should not be needed because the port_id is always checked before calling get_mac_addr_index().
However it does not hurt.

---
 lib/librte_ether/rte_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_ether/rte_ethdev.c +1 -0
index 957ae2a17..b038f281b 100644
@@ -2357,6 +2357,7 @@ get_mac_addr_index(uint8_t port_id, const struct ether_addr *addr)
 	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
 	unsigned i;
 
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	rte_eth_dev_info_get(port_id, &dev_info);
 
 	for (i = 0; i < dev_info.max_mac_addrs; i++)
Signature · 1 line
2.13.1
author Applied
#1 lore raw

06/07/2017 23:45, Thomas Monjalon:

Quoted 10 lines

Seen on Ubuntu 16.04 with GCC 5.4.0:

lib/librte_ether/rte_ethdev.c: In function 'get_mac_addr_index':
lib/librte_ether/rte_ethdev.c:2369:26: error:
'dev_info.max_mac_addrs' may be used uninitialized in this function

Indeed, rte_eth_dev_info_get() do not write into dev_info if the port_id is not valid.
So we need to check the port_id and return in case of error.

Quoted 7 lines

This extra check should not be needed because the port_id is always checked before calling get_mac_addr_index().
However it does not hurt.

Applied