[PATCH v3 5/5] eal: replace out of bounds VLA with static_assert

Stephen Hemminger stephen at networkplumber.org
Wed Jan 17 18:12:35 CET 2024


On Wed, 17 Jan 2024 10:52:40 +0300
Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru> wrote:

> On 1/16/24 21:41, Stephen Hemminger wrote:
> > Both Gcc, clang and MSVC have better way to do compile time
> > assertions rather than using out of bounds array access.
> > The old method would fail if -Wvla is enabled because compiler
> > can't determine size in that code.  Also, the use of new
> > _Static_assert will catch broken code that is passing non-constant
> > expression to RTE_BUILD_BUG_ON().
> > 
> > Need to add brackets {} around the static_assert() to workaround
> > a bug in clang. Clang was not handling static_assert() in
> > a switch case properly.
> > 
> > Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> > Acked-by: Morten Brørup <mb at smartsharesystems.com>
> > Acked-by: Tyler Retzlaff <roretzla at linux.microsoft.com>  
> 
> Acked-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
> 
> Does it imply any limitations on Gcc / Clang versions to
> be used? Is it documented somewhere in DPDK?

No new language versions problems.  There are already direct
usages of static_assert() in some drivers.


More information about the dev mailing list