ethdev: fix build with gcc 5.4.0
authorThomas Monjalon <thomas@monjalon.net>
Thu, 6 Jul 2017 21:45:32 +0000 (23:45 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 13 Jul 2017 09:36:57 +0000 (11:36 +0200)
commit722de4c3e7b11d20f7b0c6e68e1b0ecb91fe6c43
treeba52c383da528cdcc2d58964bc99ca7cf342f097
parent5713ade697769adec2a9070aa1e17a045a05231f
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.

Reported-by: Matan Azrad <matan@mellanox.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Tested-by: Matan Azrad <matan@mellanox.com>
lib/librte_ether/rte_ethdev.c