Skip to content

Commit 6f0f106

Browse files
net/octeon_ep: avoid warning on uninitialized variable
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 <[email protected]>
1 parent 1af8b0b commit 6f0f106

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/octeon_ep/otx_ep_ethdev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ otx_ep_dev_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
186186
struct rte_eth_dev_info devinfo;
187187
int32_t ret = 0;
188188

189+
/* Avoid what looks like a GCC optimisation bug on devinfo.max_mtu initialisation */
190+
memset(&devinfo, 0, sizeof(devinfo));
189191
if (otx_ep_dev_info_get(eth_dev, &devinfo)) {
190192
otx_ep_err("Cannot set MTU to %u: failed to get device info", mtu);
191193
return -EPERM;

0 commit comments

Comments
 (0)