On Thu, 13 Nov 2025 08:33:01 -0800
Stephen Hemminger <[email protected]> wrote:
> Gcc-16 detects use of uninitialized variable.
> ./drivers/net/mlx5/linux/mlx5_ethdev_os.c: In function ‘mlx5_link_update’:
> ../drivers/net/mlx5/linux/mlx5_ethdev_os.c:539:15: warning: ‘*(long unsigned
> int *)((char *)&dev_link + offsetof(struct rte_eth_link, <U38c0>))’ may be
> used uninitialized [-Wmaybe-uninitialized]
> 539 | ret = !!memcmp(&dev->data->dev_link, &dev_link,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 540 | sizeof(struct rte_eth_link));
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../drivers/net/mlx5/linux/mlx5_ethdev_os.c:515:29: note: ‘*(long unsigned int
> *)((char *)&dev_link + offsetof(struct rte_eth_link, <U38c0>))’ was declared
> here
> 515 | struct rte_eth_link dev_link;
> |
>
> If the retry loop exits the code would do memcmp against unintialized
> stack value. Resolve by intializing to zero.
>
> Fixes: 1256805dd54d ("net/mlx5: move Linux-specific functions")
> Cc: [email protected]
>
> Signed-off-by: Stephen Hemminger <[email protected]>
> ---
The build fails with clang because of the (annoying) use of pedantic in this
driver.
I will let mlx5 maintainers fix it then.
../drivers/net/mlx5/linux/mlx5_ethdev_os.c:515:33: error: use of GNU empty
initializer extension [-Werror,-Wgnu-empty-initializer]
struct rte_eth_link dev_link = { };