[v14,73/81] drivers/common: add compile warning about use of VLAs

Message ID 1736540620-21764-74-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series remove use of VLAs for Windows |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andre Muezerie Jan. 10, 2025, 8:23 p.m. UTC
MSVC does not support VLAs, so we want to prevent VLAs from being
introduced under this path.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 drivers/common/mlx5/meson.build    | 1 +
 drivers/common/nfp/meson.build     | 8 ++++++++
 drivers/common/nitrox/meson.build  | 8 ++++++++
 drivers/common/qat/meson.build     | 8 ++++++++
 drivers/common/sfc_efx/meson.build | 1 +
 5 files changed, 26 insertions(+)
  

Patch

diff --git a/drivers/common/mlx5/meson.build b/drivers/common/mlx5/meson.build
index 1eefc02f06..a6a67fbb85 100644
--- a/drivers/common/mlx5/meson.build
+++ b/drivers/common/mlx5/meson.build
@@ -26,6 +26,7 @@  sources += files(
 
 cflags_options = [
         '-std=c11',
+        '-Wvla',
         '-Wno-strict-prototypes',
         '-D_BSD_SOURCE',
         '-D_DEFAULT_SOURCE',
diff --git a/drivers/common/nfp/meson.build b/drivers/common/nfp/meson.build
index a09d1e25e2..165be4a868 100644
--- a/drivers/common/nfp/meson.build
+++ b/drivers/common/nfp/meson.build
@@ -14,3 +14,11 @@  sources = files(
 )
 
 deps += ['bus_pci', 'net']
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
diff --git a/drivers/common/nitrox/meson.build b/drivers/common/nitrox/meson.build
index f3cb42f006..46cd8ba65c 100644
--- a/drivers/common/nitrox/meson.build
+++ b/drivers/common/nitrox/meson.build
@@ -17,3 +17,11 @@  sources += files(
 
 includes += include_directories('../../crypto/nitrox')
 includes += include_directories('../../compress/nitrox')
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
diff --git a/drivers/common/qat/meson.build b/drivers/common/qat/meson.build
index 5a8de16fe0..8dd38e9abd 100644
--- a/drivers/common/qat/meson.build
+++ b/drivers/common/qat/meson.build
@@ -119,3 +119,11 @@  if qat_crypto
     deps += ['security']
     cflags += ['-DBUILD_QAT_SYM', '-DBUILD_QAT_ASYM']
 endif
+
+extra_flags = ['-Wvla']
+
+foreach arg: extra_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
diff --git a/drivers/common/sfc_efx/meson.build b/drivers/common/sfc_efx/meson.build
index 0cf0a23bf8..e3b90f670a 100644
--- a/drivers/common/sfc_efx/meson.build
+++ b/drivers/common/sfc_efx/meson.build
@@ -26,6 +26,7 @@  extra_flags += [
 extra_flags += [
         '-Waggregate-return',
         '-Wbad-function-cast',
+        '-Wvla',
 ]
 
 foreach flag: extra_flags