[v16,34/60] drivers/common: add compile warning about use of VLAs

Message ID 1736821958-3295-35-git-send-email-andremue@linux.microsoft.com (mailing list archive)
State Changes Requested
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. 14, 2025, 2:32 a.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/nfp/meson.build     | 8 ++++++++
 drivers/common/nitrox/meson.build  | 8 ++++++++
 drivers/common/sfc_efx/meson.build | 1 +
 3 files changed, 17 insertions(+)
  

Patch

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