[PATCH v3 0/6] fix GCC warnings when building with LTO

Stephen Hemminger
2026-01-16T06:46:54Z

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(-)

--
2.51.0