<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Hi Andre,</p>
<div class="moz-cite-prefix">On 20/11/2024 03:13, Andre Muezerie
wrote:<br>
</div>
<blockquote type="cite" cite="mid:1732072401-15962-22-git-send-email-andremue@linux.microsoft.com">
<pre wrap="" class="moz-quote-pre">MSVC does not support VLAs, replace VLAs with standard C arrays.
Signed-off-by: Andre Muezerie <a class="moz-txt-link-rfc2396E" href="mailto:andremue@linux.microsoft.com"><andremue@linux.microsoft.com></a>
---
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 <rte_thash.h>
#include <rte_log.h>
+#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;</pre>
</blockquote>
Since poly_coefficients is not a VLA anymore you can <span class="EzKURWReUAB5oZgtQNkl" data-src-align="62:16" style="white-space: pre-wrap;">initialize</span><span style="white-space: pre-wrap;"> </span>it with zeros and get rid of
the loop<br>
<blockquote type="cite" cite="mid:1732072401-15962-22-git-send-email-andremue@linux.microsoft.com">
<pre wrap="" class="moz-quote-pre">
@@ -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;
}
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Regards,
Vladimir</pre>
</body>
</html>