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 8622545D55; Thu, 21 Nov 2024 18:51:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77C0840A81; Thu, 21 Nov 2024 18:51:01 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 0383E40A6B for ; Thu, 21 Nov 2024 18:51:00 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 23901205A777; Thu, 21 Nov 2024 09:50:59 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 23901205A777 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1732211459; bh=R/E8PsnvTgmFo1y9+sDSu+Om4Uj1d4+s7epcckuJYxg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=on+cUvpyOk5ljM0PmYYh/0Ph1i+C1dGcthdyHXcvNn1LuDDnWbkdZ3VekPbwtUkTv uzpwsotg2lqp2ENH1wb+z7wS2kpifuvp46hFcEWSLFY2d9Bxux8seHfcAGhONxO/oP vZkVtEBIV85N7wOWmLY0XaG5c+AYUdVv4r4AtzOI= Date: Thu, 21 Nov 2024 09:50:59 -0800 From: Andre Muezerie To: "Medvedkin, Vladimir" Cc: dev@dpdk.org Subject: Re: [PATCH v10 21/21] hash: remove use of VLAs by using standard arrays Message-ID: <20241121175059.GB22492@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1713397319-26135-1-git-send-email-roretzla@linux.microsoft.com> <1732072401-15962-1-git-send-email-andremue@linux.microsoft.com> <1732072401-15962-22-git-send-email-andremue@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Wed, Nov 20, 2024 at 10:51:26AM +0000, Medvedkin, Vladimir wrote: > Hi Andre, > > On 20/11/2024 03:13, Andre Muezerie wrote: > >MSVC does not support VLAs, replace VLAs with standard C arrays. > > > >Signed-off-by: Andre Muezerie > >--- > > lib/hash/rte_thash_gf2_poly_math.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > >diff --git a/lib/hash/rte_thash_gf2_poly_math.c b/lib/hash/rte_thash_gf2_poly_math.c > >index 1c62974e71..cf7c7d396c 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,7 +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]; > >+ uint32_t poly_coefficients[MAX_POLY_DEGREE + 1]; > > for (i = 0; i <= poly_degree; i++) > > poly_coefficients[i] = 0; > Since poly_coefficients is not a VLA anymore you can initializeit > with zeros and get rid of the loop Good observation. I'll update this. Regards, Andre > >@@ -247,7 +248,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; > > } > > -- > Regards, > Vladimir