[PATCH] net/mlx5: fix uninitialized warning
Stephen Hemminger
stephen at networkplumber.org
Thu Nov 13 18:50:49 CET 2025
On Thu, 13 Nov 2025 08:33:01 -0800
Stephen Hemminger <stephen at networkplumber.org> 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: stable at dpdk.org
>
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
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 = { };
More information about the dev
mailing list