From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 536AD45D48; Wed, 20 Nov 2024 01:39:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D94642EBF; Wed, 20 Nov 2024 01:38:10 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 740DC42E6D for ; Wed, 20 Nov 2024 01:37:47 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id E18E0205A747; Tue, 19 Nov 2024 16:37:45 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E18E0205A747 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1732063065; bh=VydG6qHLApKRP+u9+5xZXRP+80EZTUpdV8zRKePahm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BvtYdc6YIDyNQ3rItKwC5tksSv+X2qt3pOcvLE1VlgHJc0O6ySzk5phmGH2AzpwP8 ZNJOaoqzr3nd8Z6+rtlY9H2brYwWiILcvbhoiOtr9NC0/F+COco/TvIR2VnH3VQP6Y n9eSV4V60QnXPxoqwMW2hMSzit92cSLcJq0PDqMM= From: Andre Muezerie To: dev@dpdk.org Cc: Tyler Retzlaff Subject: [PATCH v8 12/21] app/testpmd: remove use of VLAs for Windows built Date: Tue, 19 Nov 2024 16:37:19 -0800 Message-Id: <1732063048-12298-13-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1732063048-12298-1-git-send-email-andremue@linux.microsoft.com> References: <1713397319-26135-1-git-send-email-roretzla@linux.microsoft.com> <1732063048-12298-1-git-send-email-andremue@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Tyler Retzlaff 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: Tyler Retzlaff --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 15 ++++++++++----- app/test-pmd/config.c | 16 +++++++++------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 7e0666e9f6..2897e44c34 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -13274,7 +13274,7 @@ cmd_set_port_ptypes_parsed( return; } - uint32_t ptypes[ret]; + uint32_t *ptypes = alloca(sizeof(uint32_t) * ret); ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); if (ret < 0) { diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 1e4f2ebc55..fb0c4f838d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -11707,8 +11707,7 @@ parse_hex(struct context *ctx, const struct token *token, char tmp[16]; /* Ought to be enough. */ int ret; unsigned int hexlen = len; - unsigned int length = 256; - uint8_t hex_tmp[length]; + uint8_t hex_tmp[256]; /* Arguments are expected. */ if (!arg_data) @@ -11735,7 +11734,7 @@ parse_hex(struct context *ctx, const struct token *token, str += 2; hexlen -= 2; } - if (hexlen > length) + if (hexlen > RTE_DIM(hex_tmp)) goto error; ret = parse_hex_string(str, hex_tmp, &hexlen); if (ret < 0) @@ -11868,10 +11867,13 @@ parse_ipv4_addr(struct context *ctx, const struct token *token, void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char str2[INET_ADDRSTRLEN]; struct in_addr tmp; int ret; + /* Length is longer than the max length an IPv4 address can have. */ + if (len >= INET_ADDRSTRLEN) + return -1; /* Argument is expected. */ if (!arg) return -1; @@ -11914,11 +11916,14 @@ parse_ipv6_addr(struct context *ctx, const struct token *token, void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char str2[INET6_ADDRSTRLEN]; struct rte_ipv6_addr tmp; int ret; (void)token; + /* Length is longer than the max length an IPv6 address can have. */ + if (len >= INET6_ADDRSTRLEN) + return -1; /* Argument is expected. */ if (!arg) return -1; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 88770b4dfc..9ff2b8817f 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1802,7 +1802,8 @@ port_flow_configure(portid_t port_id, { struct rte_port *port; struct rte_flow_error error; - const struct rte_flow_queue_attr *attr_list[nb_queue]; + const struct rte_flow_queue_attr **attr_list = + alloca(sizeof(struct rte_flow_queue_attr *) * nb_queue); int std_queue; if (port_id_is_invalid(port_id, ENABLED_WARN) || @@ -2616,10 +2617,10 @@ port_flow_template_table_create(portid_t port_id, uint32_t id, int ret; uint32_t i; struct rte_flow_error error; - struct rte_flow_pattern_template - *flow_pattern_templates[nb_pattern_templates]; - struct rte_flow_actions_template - *flow_actions_templates[nb_actions_templates]; + struct rte_flow_pattern_template **flow_pattern_templates = + alloca(sizeof(struct rte_flow_pattern_template *) * nb_pattern_templates); + struct rte_flow_actions_template **flow_actions_templates = + alloca(sizeof(struct rte_flow_actions_template *) * nb_actions_templates); if (port_id_is_invalid(port_id, ENABLED_WARN) || port_id == (portid_t)RTE_PORT_ALL) @@ -5529,7 +5530,7 @@ parse_port_list(const char *list, unsigned int *values, unsigned int maxsize) char *end = NULL; int min, max; int value, i; - unsigned int marked[maxsize]; + unsigned int *marked = alloca(sizeof(unsigned int) * maxsize); if (list == NULL || values == NULL) return 0; @@ -7270,7 +7271,8 @@ show_macs(portid_t port_id) if (eth_dev_info_get_print_err(port_id, &dev_info)) return; - struct rte_ether_addr addr[dev_info.max_mac_addrs]; + struct rte_ether_addr *addr = + alloca(sizeof(struct rte_ether_addr) * dev_info.max_mac_addrs); rc = rte_eth_macaddrs_get(port_id, addr, dev_info.max_mac_addrs); if (rc < 0) return; -- 2.47.0.vfs.0.3