[v14,20/81] app/testpmd: remove use of VLAs for Windows built code in shared_rxq_fwd

Message ID 1736540620-21764-21-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:22 p.m. UTC
MSVC does not support VLAs, replace VLAs with standard C arrays
or alloca(). alloca() is available for all toolchain/platform
combinations officially supported by DPDK.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/meson.build      | 10 +++++++++-
 app/test-pmd/shared_rxq_fwd.c |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)
  

Patch

diff --git a/app/test-pmd/meson.build b/app/test-pmd/meson.build
index f1c36529b4..efd1eab0b0 100644
--- a/app/test-pmd/meson.build
+++ b/app/test-pmd/meson.build
@@ -3,7 +3,15 @@ 
 
 # override default name to drop the hyphen
 name = 'testpmd'
-cflags += '-Wno-deprecated-declarations'
+
+warning_flags = ['-Wno-deprecated-declarations', '-Wvla']
+
+foreach arg: warning_flags
+    if cc.has_argument(arg)
+        cflags += arg
+    endif
+endforeach
+
 sources = files(
         '5tswap.c',
         'cmdline.c',
diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c
index 623d62da88..b85830b90e 100644
--- a/app/test-pmd/shared_rxq_fwd.c
+++ b/app/test-pmd/shared_rxq_fwd.c
@@ -92,7 +92,7 @@  forward_shared_rxq(struct fwd_stream *fs, uint16_t nb_rx,
 static bool
 shared_rxq_fwd(struct fwd_stream *fs)
 {
-	struct rte_mbuf *pkts_burst[nb_pkt_per_burst];
+	struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
 	uint16_t nb_rx;
 
 	nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);