fix GCC warnings when building with LTO
Get series with b4
b4 am [email protected]Versions newest first
- v3 Latest6 patches 12 repliesIn review
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | test/soring: fix buffer overflow warnings with LTOapp/ | +22 | 12 replies | |
| 2/6 | common/cnxk: replace variable length state arraydrivers/ | +2 | 0 replies | |
| 3/6 | common/cnxk: replace variable length arraydrivers/ | +2 | 0 replies | |
| 4/6 | common/cnxk: re-enable vla warningsdrivers/ | +0 | 0 replies | |
| 5/6 | common/cnxk: fix buffer overflow in reassembly SA setupdrivers/ | +1 | 0 replies | |
| 6/6 | net/mlx5/hws: fix LTO false positive stringop-overflow warningdrivers/ | +14 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH v3 0/6] fix GCC warnings when building with LTO
This series fixes all warnings produced by GCC when building DPDK with Link Time Optimization (LTO) enabled. LTO performs aggressive cross- compilation-unit inlining and interprocedural analysis, which exposes issues that are not visible during normal compilation.
The problems were diagnosed using AI but the fixes all look very reasonable and consistent with other code.
The fixes fall into three categories:
1. Buffer sizing for static analysis (patches 1, 6)
When LTO inlines functions across compilation units, GCC's static analyzer gains visibility into buffer sizes and all code paths. This causes warnings when the analyzer cannot prove that runtime- selected code paths stay within buffer bounds. The fixes provide either larger buffers or explicit bounds checks to satisfy the analyzer.
2. Variable Length Array (VLA) elimination (patches 2, 3, 4)
VLAs cause -Wvla-larger-than warnings with LTO because the compiler cannot determine array bounds at compile time. These patches replace VLAs with fixed-size arrays using existing defines, then remove the warning suppression flag that was masking the issue.
3. Genuine bug fix (patch 5)
The LTO analysis uncovered an actual buffer overflow bug where a 1-byte allocation was being used for an 808-byte structure. This is a real memory corruption issue, not just a false positive.
The patches have been tested with GCC 14 using -flto=auto and produce a clean build with no warnings.
v3 - add all the other stuff necessary to fix all the LTO warnings
Stephen Hemminger (6):
test/soring: fix buffer overflow warnings with LTO common/cnxk: replace variable length state array common/cnxk: replace variable length array common/cnxk: re-enable vla warnings
common/cnxk: fix buffer overflow in reassembly SA setup net/mlx5/hws: fix LTO false positive stringop-overflow warning
app/test/test_soring.c | 29 +++++++++++++++++++++------- drivers/common/cnxk/meson.build | 2 -- drivers/common/cnxk/roc_aes.c | 3 ++- drivers/common/cnxk/roc_nix_inl.c | 2 +- drivers/common/cnxk/roc_platform.c | 4 ++-- drivers/net/mlx5/hws/mlx5dr_action.c | 14 ++++++++++++++ 6 files changed, 41 insertions(+), 13 deletions(-)
Signature · 1 line
2.51.0