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 668614605F; Fri, 10 Jan 2025 21:25:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 03A6042DBD; Fri, 10 Jan 2025 21:24:28 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 5E3C9427C3 for ; Fri, 10 Jan 2025 21:24:01 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id DF67E203D606; Fri, 10 Jan 2025 12:23:59 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DF67E203D606 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1736540639; bh=O/CydglOyTfgPLEZikr1idMMLAG8iY/HaWD3asPuYK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P0L/fPQtnoVvYapNC3Ws9a3EwydvwnbzROd9xu6uOenQi87/bYWodfBxUtRrUjHn7 JUi5s1zRlT6NvdfXaGqPy3b3hRoet2VID5LhJ61OPAZG72qt5IR6h7wPEntOam41jN s1f3cMs5u7ji6XxMtAjyevAXyR//JwtA/WQQ9bEQ= From: Andre Muezerie To: dev@dpdk.org Cc: konstantin.ananyev@huawei.com, homas@monjalon.net, david.marchand@redhat.com, Andre Muezerie Subject: [PATCH v14 21/81] hash: remove use of VLAs by using standard arrays Date: Fri, 10 Jan 2025 12:22:40 -0800 Message-Id: <1736540620-21764-22-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1736540620-21764-1-git-send-email-andremue@linux.microsoft.com> References: <1713397319-26135-1-git-send-email-roretzla@linux.microsoft.com> <1736540620-21764-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 MSVC does not support VLAs, replace VLAs with standard C arrays. Signed-off-by: Andre Muezerie --- lib/hash/meson.build | 8 ++++++++ lib/hash/rte_thash_gf2_poly_math.c | 9 ++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/hash/meson.build b/lib/hash/meson.build index 7ce504ee8b..289c6a3543 100644 --- a/lib/hash/meson.build +++ b/lib/hash/meson.build @@ -29,3 +29,11 @@ sources = files( deps += ['net'] deps += ['ring'] deps += ['rcu'] + +warning_flags = ['-Wvla'] + +foreach arg: warning_flags + if cc.has_argument(arg) + cflags += arg + endif +endforeach diff --git a/lib/hash/rte_thash_gf2_poly_math.c b/lib/hash/rte_thash_gf2_poly_math.c index 1c62974e71..825da4382f 100644 --- a/lib/hash/rte_thash_gf2_poly_math.c +++ b/lib/hash/rte_thash_gf2_poly_math.c @@ -8,6 +8,7 @@ #include #include +#define MAX_POLY_DEGREE 32 #define MAX_TOEPLITZ_KEY_LENGTH 64 RTE_LOG_REGISTER_SUFFIX(thash_poly_logtype, thash_poly, INFO); #define RTE_LOGTYPE_HASH thash_poly_logtype @@ -149,7 +150,7 @@ gf2_pow(uint32_t a, uint32_t pow, uint32_t r, int degree) static uint32_t __thash_get_rand_poly(int poly_degree) { - uint32_t roots[poly_degree]; + uint32_t roots[MAX_POLY_DEGREE]; uint32_t rnd; uint32_t ret_poly = 0; int i, j; @@ -194,9 +195,7 @@ __thash_get_rand_poly(int poly_degree) * Get coefficients of the polynomial for * (x - roots[0])(x - roots[1])...(x - roots[n]) */ - uint32_t poly_coefficients[poly_degree + 1]; - for (i = 0; i <= poly_degree; i++) - poly_coefficients[i] = 0; + uint32_t poly_coefficients[MAX_POLY_DEGREE + 1] = {0}; poly_coefficients[0] = 1; /* highest degree term coefficient in the end */ for (i = 0; i < (int)poly_degree; i++) { @@ -247,7 +246,7 @@ thash_get_rand_poly(uint32_t poly_degree) { uint32_t ret_poly; - if (poly_degree > 32) { + if (poly_degree > MAX_POLY_DEGREE) { HASH_LOG(ERR, "Wrong polynomial degree %d, must be in range [1, 32]", poly_degree); return 0; } -- 2.47.0.vfs.0.3