[PATCH v15 34/60] drivers/common: add compile warning about use of VLAs

Andre Muezerie andremue at linux.microsoft.com
Tue Jan 14 02:22:46 CET 2025


MSVC does not support VLAs, so we want to prevent VLAs from being
introduced under this path.

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

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/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
-- 
2.47.0.vfs.0.3



More information about the dev mailing list