mlx5: unitialized warning
Building current main branch with gcc (Debian 10.2.1-6) 10.2.1 20210110
[1843/3131] Compiling C object drivers/libtmp_rte_net_mlx5.a.p/net_mlx5_mlx5_flow_meter.c.o ../drivers/net/mlx5/mlx5_flow_meter.c: In function ‘mlx5_flow_meter_create’:../drivers/net/mlx5/mlx5_flow_meter.c:1170:33: warning: ‘legacy_fm’ may be used uninitialized in this function [-Wmaybe-uninitialized]
1170 | struct mlx5_legacy_flow_meter *legacy_fm;
| ^~~~~~~~~
Quoted 11 lines
Building current main branch with gcc (Debian 10.2.1-6) 10.2.1 20210110
[1843/3131] Compiling C object
drivers/libtmp_rte_net_mlx5.a.p/net_mlx5_mlx5_flow_meter.c.o../drivers/net/mlx5/mlx5_flow_meter.c: In function ‘mlx5_flow_meter_create’:../drivers/net/mlx5/mlx5_flow_meter.c:1170:33: warning: ‘legacy_fm’ may be used uninitialized in this function [-Wmaybe-uninitialized]
1170 | structmlx5_legacy_flow_meter*legacy_fm;
| ^~~~~~~~~
Hi Stephen,
I don't see this warning with gcc 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.04). Firstly, I believe it's a false positive:legacy_fm is initialized and used only when priv->sh->meter_aso_en == false:
1237 if (priv->sh->meter_aso_en) {
...
1245 } else {
legacy_fm = ...
if (legacy_fm == NULL)
return ...;
...
}
...
1276 if (!priv->sh->meter_aso_en)
TAILQ_INSERT_TAIL(fms, legacy_fm, next);However, even if it's fixed in GCC between 10.2.1 and 10.3.0, I've seen it with x86_64-w64-mingw32-gcc (GCC) 9.3-win32 20200320 while working on enabling drivers/*/mlx5 build with GCC, so a workaround will probably still be needed.
Quoted 30 lines · On Fri, 17 Dec 2021 19:01:31 +0000 Dmitry Kozlyuk <[email protected]> wrote:
Quoted 11 lines
Building current main branch with gcc (Debian 10.2.1-6) 10.2.1 20210110
[1843/3131] Compiling C object
drivers/libtmp_rte_net_mlx5.a.p/net_mlx5_mlx5_flow_meter.c.o../drivers/net/mlx5/mlx5_flow_meter.c: In function ‘mlx5_flow_meter_create’:../drivers/net/mlx5/mlx5_flow_meter.c:1170:33: warning: ‘legacy_fm’ may be used uninitialized in this function [-Wmaybe-uninitialized]
1170 | structmlx5_legacy_flow_meter*legacy_fm;
| ^~~~~~~~~Hi Stephen,
I don't see this warning with gcc 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.04). Firstly, I believe it's a false positive:
legacy_fmis initialized and used only whenpriv->sh->meter_aso_en== false:1237 if (priv->sh->meter_aso_en) { ... 1245 } else { legacy_fm = ... if (legacy_fm == NULL) return ...; ... } ... 1276 if (!priv->sh->meter_aso_en) TAILQ_INSERT_TAIL(fms, legacy_fm, next);
Quoted 4 lines
However, even if it's fixed in GCC between 10.2.1 and 10.3.0, I've seen it with x86_64-w64-mingw32-gcc (GCC) 9.3-win32 20200320 while working on enabling
drivers/*/mlx5build with GCC, so a workaround will probably still be needed.
It maybe because I was testing with thread santizer enabled and compiler was doing different optimizations.
Quoted 1 line
Quoted 1 line
I don't see this warning with gcc 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.04).
[...]
Quoted 3 lines
It maybe because I was testing with thread santizer enabled and compiler was doing different optimizations.
Reproduced with -Dc_args=-fsanitize=thread, thanks!
Quoted 7 lines · On Fri, 17 Dec 2021 19:28:26 +0000 Dmitry Kozlyuk <[email protected]> wrote:
Quoted 1 line
Quoted 1 line
I don't see this warning with gcc 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.04).
[...]
Quoted 3 lines
It maybe because I was testing with thread santizer enabled and compiler was doing different optimizations.
Reproduced with -Dc_args=-fsanitize=thread, thanks!
I was using
-Db_sanitize=thread
which is the meson way to do it