From patchwork Mon May 6 18:18:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 139950 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7E96A43F5C; Mon, 6 May 2024 20:19:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 73AB440EDB; Mon, 6 May 2024 20:19:09 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 98EEC4068E for ; Mon, 6 May 2024 20:18:54 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 7224C20B2C95; Mon, 6 May 2024 11:18:53 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7224C20B2C95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1715019533; bh=4szHBJf0Z+fUSKIMOwGmNFUrf4ZSbotJcyUzr5oyLbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kXnfTzCkcyfjBMcRS9VMcV13bDiGc/OSQZbLScHNjP0bxTEolxfE8kQ1oxjS+OoUK VvLOJIHNXxmhEJeQVn/u9jra1zj2zZqs0bp89AjraRKAcSmz/CRS2nRnT8IWkZhAUP LMV0biZvMlmvP14+pNW3AP7mtqIWJ3ggNTYyagJs= From: Tyler Retzlaff To: dev@dpdk.org Cc: =?utf-8?q?Morten_Br=C3=B8rup?= , Akhil Goyal , Aman Singh , Anatoly Burakov , Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Dariusz Sosnowski , Dmitry Kozlyuk , Fan Zhang , Ferruh Yigit , Harman Kalra , Harry van Haaren , Honnappa Nagarahalli , Jiayu Hu , Jingjing Wu , Kevin Laatz , Konstantin Ananyev , Matan Azrad , Ori Kam , Pallavi Kadam , Reshma Pattan , Sameh Gobriel , Suanming Mou , Thomas Monjalon , Tyler Retzlaff , Viacheslav Ovsiienko , Vladimir Medvedkin , Volodymyr Fialko , Yipeng Wang Subject: [PATCH v3 12/19] test: remove use of VLAs for Windows built code Date: Mon, 6 May 2024 11:18:44 -0700 Message-Id: <1715019531-22796-13-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1715019531-22796-1-git-send-email-roretzla@linux.microsoft.com> References: <1713397319-26135-1-git-send-email-roretzla@linux.microsoft.com> <1715019531-22796-1-git-send-email-roretzla@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 or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff --- 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");