[v2,13/14] net/octeon_ep: avoid warning on uninitialized variable
Checks
Commit Message
In the next commit, a (unrelated) change will be done on the logging
macros in this driver.
After this change, compilation with O3 fails with the following warning:
../drivers/net/octeon_ep/otx_ep_ethdev.c: In function
‘otx_ep_dev_mtu_set’:
../drivers/net/octeon_ep/otx_ep_ethdev.c:200:12: error: ‘devinfo.max_mtu’
may be used uninitialized [-Werror=maybe-uninitialized]
200 | if (mtu > devinfo.max_mtu) {
| ^
../drivers/net/octeon_ep/otx_ep_ethdev.c:186:33: note: ‘devinfo.max_mtu’
was declared here
186 | struct rte_eth_dev_info devinfo;
| ^~~~~~~
cc1: all warnings being treated as errors
The devinfo object is passed through otx_ep_dev_info_get() which
initializes devinfo.max_mtu and returns 0.
This return code is checked at line 189 and so devinfo.max_mtu is
supposed to be initialized at this point.
This seems like a compiler optimisation bug, but we will have to live
with it.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
drivers/net/octeon_ep/otx_ep_ethdev.c | 1 +
1 file changed, 1 insertion(+)
@@ -186,6 +186,7 @@ otx_ep_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
struct rte_eth_dev_info devinfo;
int32_t ret = 0;
+ memset(&devinfo, 0, sizeof(devinfo));
if (otx_ep_dev_info_get(eth_dev, &devinfo)) {
otx_ep_err("Cannot set MTU to %u: failed to get device info", mtu);
return -EPERM;