DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org
Cc: "Morten Brørup" <mb@smartsharesystems.com>,
	"Akhil Goyal" <gakhil@marvell.com>,
	"Aman Singh" <aman.deep.singh@intel.com>,
	"Anatoly Burakov" <anatoly.burakov@intel.com>,
	"Andrew Rybchenko" <andrew.rybchenko@oktetlabs.ru>,
	"Bruce Richardson" <bruce.richardson@intel.com>,
	"Chengwen Feng" <fengchengwen@huawei.com>,
	"Dariusz Sosnowski" <dsosnowski@nvidia.com>,
	"Dmitry Kozlyuk" <dmitry.kozliuk@gmail.com>,
	"Fan Zhang" <fanzhang.oss@gmail.com>,
	"Ferruh Yigit" <ferruh.yigit@amd.com>,
	"Harman Kalra" <hkalra@marvell.com>,
	"Harry van Haaren" <harry.van.haaren@intel.com>,
	"Honnappa Nagarahalli" <honnappa.nagarahalli@arm.com>,
	"Jiayu Hu" <hujiayu.hu@foxmail.com>,
	"Jingjing Wu" <jingjing.wu@intel.com>,
	"Kevin Laatz" <kevin.laatz@intel.com>,
	"Konstantin Ananyev" <konstantin.v.ananyev@yandex.ru>,
	"Matan Azrad" <matan@nvidia.com>, "Ori Kam" <orika@nvidia.com>,
	"Pallavi Kadam" <pallavi.kadam@intel.com>,
	"Reshma Pattan" <reshma.pattan@intel.com>,
	"Sameh Gobriel" <sameh.gobriel@intel.com>,
	"Suanming Mou" <suanmingm@nvidia.com>,
	"Thomas Monjalon" <thomas@monjalon.net>,
	"Tyler Retzlaff" <roretzla@linux.microsoft.com>,
	"Viacheslav Ovsiienko" <viacheslavo@nvidia.com>,
	"Vladimir Medvedkin" <vladimir.medvedkin@intel.com>,
	"Volodymyr Fialko" <vfialko@marvell.com>,
	"Yipeng Wang" <yipeng1.wang@intel.com>
Subject: [PATCH v2 12/19] test: remove use of VLAs for Windows built code
Date: Thu, 18 Apr 2024 13:02:35 -0700	[thread overview]
Message-ID: <1713470562-17415-13-git-send-email-roretzla@linux.microsoft.com> (raw)
In-Reply-To: <1713470562-17415-1-git-send-email-roretzla@linux.microsoft.com>

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 <roretzla@linux.microsoft.com>
---
 app/test/test.c                       |  2 +-
 app/test/test_cmdline_string.c        |  2 +-
 app/test/test_cryptodev.c             | 32 +++++++++++------------
 app/test/test_cryptodev_blockcipher.c |  4 +--
 app/test/test_cryptodev_crosscheck.c  |  2 +-
 app/test/test_dmadev.c                |  9 ++++---
 app/test/test_hash.c                  |  8 +++---
 app/test/test_mempool.c               | 25 +++++++++---------
 app/test/test_reassembly_perf.c       |  4 +--
 app/test/test_reorder.c               | 48 +++++++++++++++++++----------------
 app/test/test_service_cores.c         |  9 +++----
 app/test/test_thash.c                 |  7 +++--
 12 files changed, 79 insertions(+), 73 deletions(-)

diff --git a/app/test/test.c b/app/test/test.c
index 680351f..fd653cb 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -105,7 +105,7 @@
 main(int argc, char **argv)
 {
 	struct cmdline *cl;
-	char *tests[argc]; /* store an array of tests to run */
+	char **tests = alloca(sizeof(char *) * argc); /* store an array of tests to run */
 	int test_count = 0;
 	int i;
 	char *extra_args;
diff --git a/app/test/test_cmdline_string.c b/app/test/test_cmdline_string.c
index 97516c9..e1cf860 100644
--- a/app/test/test_cmdline_string.c
+++ b/app/test/test_cmdline_string.c
@@ -40,7 +40,7 @@ struct string_elt_str string_elt_strs[] = {
 #if (CMDLINE_TEST_BUFSIZE < STR_TOKEN_SIZE) \
 || (CMDLINE_TEST_BUFSIZE < STR_MULTI_TOKEN_SIZE)
 #undef CMDLINE_TEST_BUFSIZE
-#define CMDLINE_TEST_BUFSIZE RTE_MAX(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE)
+#define CMDLINE_TEST_BUFSIZE RTE_MAX_T(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE, size_t)
 #endif
 
 struct string_nb_str {
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 1703ebc..fead21b 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -2686,7 +2686,7 @@ struct crypto_unittest_params {
 	enum rte_crypto_auth_operation op,
 	enum rte_crypto_auth_algorithm algo)
 {
-	uint8_t hash_key[key_len];
+	uint8_t *hash_key = alloca(key_len);
 
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -2722,7 +2722,7 @@ struct crypto_unittest_params {
 			const uint8_t *key, const uint8_t key_len,
 			uint8_t iv_len)
 {
-	uint8_t cipher_key[key_len];
+	uint8_t *cipher_key = alloca(key_len);
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
 
@@ -2874,7 +2874,7 @@ struct crypto_unittest_params {
 		const struct wireless_test_data *tdata)
 {
 	const uint8_t key_len = tdata->key.len;
-	uint8_t cipher_auth_key[key_len];
+	uint8_t *cipher_auth_key = alloca(key_len);
 
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -8878,7 +8878,7 @@ static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
 		const uint16_t aad_len, const uint8_t auth_len,
 		uint8_t iv_len)
 {
-	uint8_t aead_key[key_len];
+	uint8_t *aead_key = alloca(key_len);
 
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -12849,7 +12849,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
 {
 	struct aead_test_data tdata;
-	uint8_t aad[gcm_test_case_7.aad.len];
+	uint8_t *aad = alloca(gcm_test_case_7.aad.len);
 	int res;
 
 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
@@ -13238,7 +13238,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
 {
 	struct aead_test_data tdata;
-	uint8_t aad[gcm_test_case_7.aad.len];
+	uint8_t *aad = alloca(gcm_test_case_7.aad.len);
 	int res;
 
 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
@@ -13490,7 +13490,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
 	int retval;
 	uint8_t *ciphertext, *auth_tag;
 	uint16_t plaintext_pad_len;
-	uint8_t key[tdata->key.len + 1];
+	uint8_t *key = alloca(tdata->key.len + 1);
 	struct rte_cryptodev_info dev_info;
 
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
@@ -13592,7 +13592,7 @@ static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
 
 	int retval;
 	uint8_t *plaintext;
-	uint8_t key[tdata->key.len + 1];
+	uint8_t *key = alloca(tdata->key.len + 1);
 	struct rte_cryptodev_info dev_info;
 
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
@@ -14895,7 +14895,7 @@ static int create_gmac_session(uint8_t dev_id,
 		const struct gmac_test_data *tdata,
 		enum rte_crypto_auth_operation auth_op)
 {
-	uint8_t auth_key[tdata->key.len];
+	uint8_t *auth_key = alloca(tdata->key.len);
 
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct crypto_unittest_params *ut_params = &unittest_params;
@@ -15552,7 +15552,7 @@ struct test_crypto_vector {
 		enum rte_crypto_auth_operation auth_op)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
-	uint8_t auth_key[reference->auth_key.len + 1];
+	uint8_t *auth_key = alloca(reference->auth_key.len + 1);
 
 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
 
@@ -15583,8 +15583,8 @@ struct test_crypto_vector {
 		enum rte_crypto_cipher_operation cipher_op)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
-	uint8_t cipher_key[reference->cipher_key.len + 1];
-	uint8_t auth_key[reference->auth_key.len + 1];
+	uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
+	uint8_t *auth_key = alloca(reference->auth_key.len + 1);
 
 	memcpy(cipher_key, reference->cipher_key.data,
 			reference->cipher_key.len);
@@ -16084,8 +16084,8 @@ struct test_crypto_vector {
 
 	uint8_t *authciphertext, *plaintext, *auth_tag;
 	uint16_t plaintext_pad_len;
-	uint8_t cipher_key[reference->cipher_key.len + 1];
-	uint8_t auth_key[reference->auth_key.len + 1];
+	uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
+	uint8_t *auth_key = alloca(reference->auth_key.len + 1);
 	struct rte_cryptodev_info dev_info;
 
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
@@ -16216,8 +16216,8 @@ struct test_crypto_vector {
 	int retval;
 
 	uint8_t *ciphertext;
-	uint8_t cipher_key[reference->cipher_key.len + 1];
-	uint8_t auth_key[reference->auth_key.len + 1];
+	uint8_t *cipher_key = alloca(reference->cipher_key.len + 1);
+	uint8_t *auth_key = alloca(reference->auth_key.len + 1);
 	struct rte_cryptodev_info dev_info;
 
 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c
index 87a321f..da7bf2c 100644
--- a/app/test/test_cryptodev_blockcipher.c
+++ b/app/test/test_cryptodev_blockcipher.c
@@ -85,8 +85,8 @@
 
 	int status = TEST_SUCCESS;
 	const struct blockcipher_test_data *tdata = t->test_data;
-	uint8_t cipher_key[tdata->cipher_key.len];
-	uint8_t auth_key[tdata->auth_key.len];
+	uint8_t *cipher_key = alloca(tdata->cipher_key.len);
+	uint8_t *auth_key = alloca(tdata->auth_key.len);
 	uint32_t buf_len = tdata->ciphertext.len;
 	uint32_t digest_len = tdata->digest.len;
 	char *buf_p = NULL;
diff --git a/app/test/test_cryptodev_crosscheck.c b/app/test/test_cryptodev_crosscheck.c
index c29b19c..b9a53a4 100644
--- a/app/test/test_cryptodev_crosscheck.c
+++ b/app/test/test_cryptodev_crosscheck.c
@@ -894,7 +894,7 @@ struct crosscheck_testsuite_params {
 crosscheck_with_profile_run(const struct crosscheck_test_profile *profile)
 {
 	struct crosscheck_testsuite_params *ts_params = &testsuite_params;
-	uint8_t input_text[profile->input_buf_len];
+	uint8_t *input_text = alloca(profile->input_buf_len);
 	uint16_t output_len, encrypted_len;
 	uint8_t encrypted_text[MBUF_SIZE];
 	uint8_t output_text[MBUF_SIZE];
diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c
index 143e1bc..9cbb9a6 100644
--- a/app/test/test_dmadev.c
+++ b/app/test/test_dmadev.c
@@ -417,9 +417,12 @@ struct runtest_param {
 			dst_len = len / n_dst;
 			src_len = len / n_src;
 
-			struct rte_dma_sge sg_src[n_sge], sg_dst[n_sge];
-			struct rte_mbuf *src[n_sge], *dst[n_sge];
-			char *src_data[n_sge], *dst_data[n_sge];
+			struct rte_dma_sge *sg_src = alloca(sizeof(struct rte_dma_sge) * n_sge);
+			struct rte_dma_sge *sg_dst = alloca(sizeof(struct rte_dma_sge) * n_sge);
+			struct rte_mbuf **src = alloca(sizeof(struct rte_mbuf *) * n_sge);
+			struct rte_mbuf **dst = alloca(sizeof(struct rte_mbuf *) * n_sge);
+			char **src_data = alloca(sizeof(char *) * n_sge);
+			char **dst_data = alloca(sizeof(char *) * n_sge);
 
 			for (i = 0 ; i < len; i++)
 				orig_src[i] = rte_rand() & 0xFF;
diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index d586878..65fd9e6 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -1930,8 +1930,8 @@ static int test_hash_iteration(uint32_t ext_table)
 		.socket_id = 0,
 		.extra_flag = hash_extra_flag,
 	};
-	int pos[total_entries];
-	int expected_pos[total_entries];
+	int *pos = alloca(sizeof(int) * total_entries);
+	int *expected_pos = alloca(sizeof(int) * total_entries);
 	unsigned int i;
 	size_t sz;
 	int32_t status;
@@ -2100,8 +2100,8 @@ static int test_hash_iteration(uint32_t ext_table)
 		.socket_id = 0,
 		.extra_flag = hash_extra_flag,
 	};
-	int pos[total_entries];
-	int expected_pos[total_entries];
+	int *pos = alloca(sizeof(int) * total_entries);
+	int *expected_pos = alloca(sizeof(int) * total_entries);
 	unsigned int i;
 	size_t sz;
 	int32_t status;
diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index ad7ebd6..4672795 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -515,19 +515,20 @@ struct test_mempool_events_data {
 #undef RTE_TEST_TRACE_FAILURE
 #define RTE_TEST_TRACE_FAILURE(...) do { goto fail; } while (0)
 
-	static const size_t callback_num = 3;
-	static const size_t mempool_num = 2;
+#define CALLBACK_NUM 3u
+#define MEMPOOL_NUM 2u
+
 	static const unsigned int mempool_elt_size = 64;
 	static const unsigned int mempool_size = 64;
 
-	struct test_mempool_events_data data[callback_num];
-	struct rte_mempool *mp[mempool_num], *freed;
+	struct test_mempool_events_data data[CALLBACK_NUM];
+	struct rte_mempool *mp[MEMPOOL_NUM], *freed;
 	char name[RTE_MEMPOOL_NAMESIZE];
 	size_t i, j;
 	int ret;
 
 	memset(mp, 0, sizeof(mp));
-	for (i = 0; i < callback_num; i++) {
+	for (i = 0; i < CALLBACK_NUM; i++) {
 		ret = rte_mempool_event_callback_register
 				(test_mempool_events_cb, &data[i]);
 		RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to register the callback %zu: %s",
@@ -548,7 +549,7 @@ struct test_mempool_events_data {
 					 SOCKET_ID_ANY, 0);
 	RTE_TEST_ASSERT_NOT_NULL(mp[0], "Cannot create mempool %s: %s",
 				 name, rte_strerror(rte_errno));
-	for (j = 0; j < callback_num; j++)
+	for (j = 0; j < CALLBACK_NUM; j++)
 		RTE_TEST_ASSERT_EQUAL(data[j].invoked, false,
 				      "Callback %zu invoked on %s mempool creation",
 				      j, name);
@@ -557,7 +558,7 @@ struct test_mempool_events_data {
 	ret = populate(mp[0]);
 	RTE_TEST_ASSERT_EQUAL(ret, (int)mp[0]->size, "Failed to populate mempool %s: %s",
 			      name, rte_strerror(-ret));
-	for (j = 0; j < callback_num; j++) {
+	for (j = 0; j < CALLBACK_NUM; j++) {
 		RTE_TEST_ASSERT_EQUAL(data[j].invoked, true,
 					"Callback %zu not invoked on mempool %s population",
 					j, name);
@@ -589,7 +590,7 @@ struct test_mempool_events_data {
 			      "Unregistered callback 0 invoked on %s mempool populaton",
 			      name);
 
-	for (i = 0; i < mempool_num; i++) {
+	for (i = 0; i < MEMPOOL_NUM; i++) {
 		memset(&data, 0, sizeof(data));
 		sprintf(name, "empty%zu", i);
 		rte_mempool_free(mp[i]);
@@ -599,7 +600,7 @@ struct test_mempool_events_data {
 		 */
 		freed = mp[i];
 		mp[i] = NULL;
-		for (j = 1; j < callback_num; j++) {
+		for (j = 1; j < CALLBACK_NUM; j++) {
 			RTE_TEST_ASSERT_EQUAL(data[j].invoked, true,
 					      "Callback %zu not invoked on mempool %s destruction",
 					      j, name);
@@ -615,7 +616,7 @@ struct test_mempool_events_data {
 				      name);
 	}
 
-	for (j = 1; j < callback_num; j++) {
+	for (j = 1; j < CALLBACK_NUM; j++) {
 		ret = rte_mempool_event_callback_unregister
 					(test_mempool_events_cb, &data[j]);
 		RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to unregister the callback %zu: %s",
@@ -624,10 +625,10 @@ struct test_mempool_events_data {
 	return TEST_SUCCESS;
 
 fail:
-	for (j = 0; j < callback_num; j++)
+	for (j = 0; j < CALLBACK_NUM; j++)
 		rte_mempool_event_callback_unregister
 					(test_mempool_events_cb, &data[j]);
-	for (i = 0; i < mempool_num; i++)
+	for (i = 0; i < MEMPOOL_NUM; i++)
 		rte_mempool_free(mp[i]);
 	return TEST_FAILED;
 
diff --git a/app/test/test_reassembly_perf.c b/app/test/test_reassembly_perf.c
index 3912179..7f4ed31 100644
--- a/app/test/test_reassembly_perf.c
+++ b/app/test/test_reassembly_perf.c
@@ -604,7 +604,7 @@
 		for (j = 0; j < 4; j++)
 			nb_frags += frag_per_flow[i + j];
 
-		struct rte_mbuf *buf_arr[nb_frags];
+		struct rte_mbuf **buf_arr = alloca(sizeof(struct rte_mbuf *) * nb_frags);
 		for (j = 0; j < 4; j++) {
 			join_array(buf_arr, mbufs[i + j], prev,
 				   frag_per_flow[i + j]);
@@ -815,7 +815,7 @@
 		for (j = 0; j < 4; j++)
 			nb_frags += frag_per_flow[i + j];
 
-		struct rte_mbuf *buf_arr[nb_frags];
+		struct rte_mbuf **buf_arr = alloca(sizeof(struct rte_mbuf *) * nb_frags);
 		for (j = 0; j < 4; j++) {
 			join_array(buf_arr, mbufs[i + j], prev,
 				   frag_per_flow[i + j]);
diff --git a/app/test/test_reorder.c b/app/test/test_reorder.c
index 501780c..aaa2c57 100644
--- a/app/test/test_reorder.c
+++ b/app/test/test_reorder.c
@@ -130,11 +130,12 @@ struct reorder_unittest_params {
 static int
 test_reorder_insert(void)
 {
+#define INSERT_NUM_BUFS 7u
+
 	struct rte_reorder_buffer *b = NULL;
 	struct rte_mempool *p = test_params->p;
 	const unsigned int size = 4;
-	const unsigned int num_bufs = 7;
-	struct rte_mbuf *bufs[num_bufs];
+	struct rte_mbuf *bufs[INSERT_NUM_BUFS];
 	int ret = 0;
 	unsigned i;
 
@@ -146,7 +147,7 @@ struct reorder_unittest_params {
 	b = rte_reorder_create("test_insert", rte_socket_id(), size);
 	TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer");
 
-	for (i = 0; i < num_bufs; i++) {
+	for (i = 0; i < INSERT_NUM_BUFS; i++) {
 		bufs[i] = rte_pktmbuf_alloc(p);
 		TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
 		*rte_reorder_seqn(bufs[i]) = i;
@@ -207,26 +208,27 @@ struct reorder_unittest_params {
 	ret = 0;
 exit:
 	rte_reorder_free(b);
-	for (i = 0; i < num_bufs; i++) {
+	for (i = 0; i < INSERT_NUM_BUFS; i++)
 		rte_pktmbuf_free(bufs[i]);
-	}
+
 	return ret;
 }
 
 static int
 test_reorder_drain(void)
 {
+#define DRAIN_NUM_BUFS 8u
+
 	struct rte_reorder_buffer *b = NULL;
 	struct rte_mempool *p = test_params->p;
 	const unsigned int size = 4;
-	const unsigned int num_bufs = 8;
-	struct rte_mbuf *bufs[num_bufs];
-	struct rte_mbuf *robufs[num_bufs];
+	struct rte_mbuf *bufs[DRAIN_NUM_BUFS];
+	struct rte_mbuf *robufs[DRAIN_NUM_BUFS];
 	int ret = 0;
 	unsigned i, cnt;
 
 	/* initialize all robufs to NULL */
-	for (i = 0; i < num_bufs; i++)
+	for (i = 0; i < DRAIN_NUM_BUFS; i++)
 		robufs[i] = NULL;
 
 	/* This would create a reorder buffer instance consisting of:
@@ -246,7 +248,7 @@ struct reorder_unittest_params {
 		goto exit;
 	}
 
-	for (i = 0; i < num_bufs; i++) {
+	for (i = 0; i < DRAIN_NUM_BUFS; i++) {
 		bufs[i] = rte_pktmbuf_alloc(p);
 		TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
 		*rte_reorder_seqn(bufs[i]) = i;
@@ -320,7 +322,7 @@ struct reorder_unittest_params {
 	ret = 0;
 exit:
 	rte_reorder_free(b);
-	for (i = 0; i < num_bufs; i++) {
+	for (i = 0; i < DRAIN_NUM_BUFS; i++) {
 		rte_pktmbuf_free(bufs[i]);
 		rte_pktmbuf_free(robufs[i]);
 	}
@@ -337,15 +339,16 @@ struct reorder_unittest_params {
 static int
 test_reorder_drain_up_to_seqn(void)
 {
+#define DRAIN_TO_NUM_BUFS 10u
+
 	struct rte_mempool *p = test_params->p;
 	struct rte_reorder_buffer *b = NULL;
-	const unsigned int num_bufs = 10;
 	const unsigned int size = 4;
 	unsigned int i, cnt;
 	int ret = 0;
 
-	struct rte_mbuf *bufs[num_bufs];
-	struct rte_mbuf *robufs[num_bufs];
+	struct rte_mbuf *bufs[DRAIN_TO_NUM_BUFS];
+	struct rte_mbuf *robufs[DRAIN_TO_NUM_BUFS];
 
 	/* initialize all robufs to NULL */
 	memset(robufs, 0, sizeof(robufs));
@@ -358,7 +361,7 @@ struct reorder_unittest_params {
 	b = rte_reorder_create("test_drain_up_to_seqn", rte_socket_id(), size);
 	TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer");
 
-	for (i = 0; i < num_bufs; i++) {
+	for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) {
 		bufs[i] = rte_pktmbuf_alloc(p);
 		TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
 		*rte_reorder_seqn(bufs[i]) = i;
@@ -372,7 +375,7 @@ struct reorder_unittest_params {
 	buffer_to_reorder_move(&bufs[2], b);
 	buffer_to_reorder_move(&bufs[3], b);
 	/* Draining 1, 2 */
-	cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 3);
+	cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 3);
 	if (cnt != 2) {
 		printf("%s:%d:%d: number of expected packets not drained\n",
 				__func__, __LINE__, cnt);
@@ -396,7 +399,7 @@ struct reorder_unittest_params {
 	buffer_to_reorder_move(&bufs[8], b);
 
 	/* Drain 3 and 5 */
-	cnt = rte_reorder_drain_up_to_seqn(b, robufs, num_bufs, 6);
+	cnt = rte_reorder_drain_up_to_seqn(b, robufs, DRAIN_TO_NUM_BUFS, 6);
 	if (cnt != 2) {
 		printf("%s:%d:%d: number of expected packets not drained\n",
 				__func__, __LINE__, cnt);
@@ -410,7 +413,7 @@ struct reorder_unittest_params {
 	ret = 0;
 exit:
 	rte_reorder_free(b);
-	for (i = 0; i < num_bufs; i++) {
+	for (i = 0; i < DRAIN_TO_NUM_BUFS; i++) {
 		rte_pktmbuf_free(bufs[i]);
 		rte_pktmbuf_free(robufs[i]);
 	}
@@ -420,14 +423,15 @@ struct reorder_unittest_params {
 static int
 test_reorder_set_seqn(void)
 {
+#define SET_SEQN_NUM_BUFS 7u
+
 	struct rte_mempool *p = test_params->p;
 	struct rte_reorder_buffer *b = NULL;
-	const unsigned int num_bufs = 7;
 	const unsigned int size = 4;
 	unsigned int i;
 	int ret = 0;
 
-	struct rte_mbuf *bufs[num_bufs];
+	struct rte_mbuf *bufs[SET_SEQN_NUM_BUFS];
 
 	/* This would create a reorder buffer instance consisting of:
 	 * reorder_seq = 0
@@ -437,7 +441,7 @@ struct reorder_unittest_params {
 	b = rte_reorder_create("test_min_seqn_set", rte_socket_id(), size);
 	TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer");
 
-	for (i = 0; i < num_bufs; i++) {
+	for (i = 0; i < SET_SEQN_NUM_BUFS; i++) {
 		bufs[i] = rte_pktmbuf_alloc(p);
 		if (bufs[i] == NULL) {
 			printf("Packet allocation failed\n");
@@ -479,7 +483,7 @@ struct reorder_unittest_params {
 	ret = 0;
 exit:
 	rte_reorder_free(b);
-	for (i = 0; i < num_bufs; i++)
+	for (i = 0; i < SET_SEQN_NUM_BUFS; i++)
 		rte_pktmbuf_free(bufs[i]);
 
 	return ret;
diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c
index c12d52d..7c45733 100644
--- a/app/test/test_service_cores.c
+++ b/app/test/test_service_cores.c
@@ -561,9 +561,8 @@ static int32_t dummy_mt_safe_cb(void *args)
 			"Service core count not equal to one");
 
 	/* retrieve core list, checking lcore ids */
-	const uint32_t size = 4;
-	uint32_t service_core_ids[size];
-	int32_t n = rte_service_lcore_list(service_core_ids, size);
+	uint32_t service_core_ids[4];
+	int32_t n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids));
 	TEST_ASSERT_EQUAL(1, n, "Service core list return should equal 1");
 	TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0],
 				"Service core list lcore must equal slcore_id");
@@ -589,7 +588,7 @@ static int32_t dummy_mt_safe_cb(void *args)
 			cores_at_this_point);
 
 	/* check longer service core list */
-	n = rte_service_lcore_list(service_core_ids, size);
+	n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids));
 	TEST_ASSERT_EQUAL(3, n, "Service core list return should equal 3");
 	TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0],
 				"Service core list[0] lcore must equal 1");
@@ -607,7 +606,7 @@ static int32_t dummy_mt_safe_cb(void *args)
 			"Service core add did not return zero");
 	TEST_ASSERT_EQUAL(1, rte_service_lcore_count(),
 			"Service core count not equal to one");
-	n = rte_service_lcore_list(service_core_ids, size);
+	n = rte_service_lcore_list(service_core_ids, RTE_DIM(service_core_ids));
 	TEST_ASSERT_EQUAL(1, n, "Service core list return should equal one");
 	TEST_ASSERT_EQUAL(slcore_id, service_core_ids[0],
 				"Service core list[0] lcore must equal %d",
diff --git a/app/test/test_thash.c b/app/test/test_thash.c
index 65d42fd..80d4106 100644
--- a/app/test/test_thash.c
+++ b/app/test/test_thash.c
@@ -576,9 +576,8 @@ enum {
 {
 	struct rte_thash_ctx *ctx;
 	struct rte_thash_subtuple_helper *h;
-	const int key_len = 40;
 	int reta_sz = 6;
-	uint8_t initial_key[key_len];
+	uint8_t initial_key[40];
 	const uint8_t *new_key;
 	int ret;
 	union rte_thash_tuple tuple;
@@ -586,9 +585,9 @@ enum {
 	unsigned int desired_value = 27 & HASH_MSK(reta_sz);
 	uint16_t port_value = 22;
 
-	memset(initial_key, 0, key_len);
+	memset(initial_key, 0, RTE_DIM(initial_key));
 
-	ctx = rte_thash_init_ctx("test", key_len, reta_sz, initial_key,
+	ctx = rte_thash_init_ctx("test", RTE_DIM(initial_key), reta_sz, initial_key,
 		RTE_THASH_MINIMAL_SEQ);
 	RTE_TEST_ASSERT(ctx != NULL, "can not create thash ctx\n");
 
-- 
1.8.3.1


  parent reply	other threads:[~2024-04-18 20:04 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17 23:41 [PATCH 00/16] " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 01/16] eal: include header required for alloca Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 02/16] hash: remove use of VLAs for Windows built code Tyler Retzlaff
2024-04-18  6:45   ` Morten Brørup
2024-04-17 23:41 ` [PATCH 03/16] ethdev: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 04/16] gro: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 05/16] latencystats: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 06/16] lpm: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 07/16] rcu: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 08/16] app/testpmd: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 09/16] test: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 10/16] common/idpf: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 11/16] net/i40e: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 12/16] net/ice: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 13/16] net/ixgbe: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 14/16] common/mlx5: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 15/16] net/mlx5: " Tyler Retzlaff
2024-04-17 23:41 ` [PATCH 16/16] build: enable vla warnings on " Tyler Retzlaff
2024-04-18  6:48   ` Morten Brørup
2024-04-18 15:12     ` Tyler Retzlaff
2024-04-18 15:23       ` Bruce Richardson
2024-04-18 19:22         ` Morten Brørup
2024-04-18  6:49 ` [PATCH 00/16] remove use of VLAs for " Morten Brørup
2024-04-18 12:11 ` Konstantin Ananyev
2024-04-18 15:15   ` Tyler Retzlaff
2024-04-18 15:35     ` Konstantin Ananyev
2024-04-18 20:02 ` [PATCH v2 00/19] remove use of VLAs for Windows Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 01/19] eal: include header required for alloca Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 02/19] eal/linux: remove use of VLAs Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 03/19] eal/common: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 04/19] ethdev: remove use of VLAs for Windows built code Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 05/19] hash: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 06/19] hash/thash: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 07/19] rcu: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 08/19] gro: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 09/19] latencystats: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 10/19] lpm: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 11/19] app/testpmd: " Tyler Retzlaff
2024-04-18 20:02   ` Tyler Retzlaff [this message]
2024-04-18 20:02   ` [PATCH v2 13/19] common/idpf: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 14/19] net/i40e: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 15/19] net/ice: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 16/19] net/ixgbe: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 17/19] common/mlx5: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 18/19] net/mlx5: " Tyler Retzlaff
2024-04-18 20:02   ` [PATCH v2 19/19] build: enable vla warnings on " Tyler Retzlaff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1713470562-17415-13-git-send-email-roretzla@linux.microsoft.com \
    --to=roretzla@linux.microsoft.com \
    --cc=aman.deep.singh@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=dsosnowski@nvidia.com \
    --cc=fanzhang.oss@gmail.com \
    --cc=fengchengwen@huawei.com \
    --cc=ferruh.yigit@amd.com \
    --cc=gakhil@marvell.com \
    --cc=harry.van.haaren@intel.com \
    --cc=hkalra@marvell.com \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=hujiayu.hu@foxmail.com \
    --cc=jingjing.wu@intel.com \
    --cc=kevin.laatz@intel.com \
    --cc=konstantin.v.ananyev@yandex.ru \
    --cc=matan@nvidia.com \
    --cc=mb@smartsharesystems.com \
    --cc=orika@nvidia.com \
    --cc=pallavi.kadam@intel.com \
    --cc=reshma.pattan@intel.com \
    --cc=sameh.gobriel@intel.com \
    --cc=suanmingm@nvidia.com \
    --cc=thomas@monjalon.net \
    --cc=vfialko@marvell.com \
    --cc=viacheslavo@nvidia.com \
    --cc=vladimir.medvedkin@intel.com \
    --cc=yipeng1.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).