diff options
author | Jere Leppänen <jere.leppanen@nokia.com> | 2024-03-28 16:37:08 +0200 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2024-04-16 16:49:46 +0300 |
commit | 3918b637a9e91f99d26bb6d0d1aa5ff7ca67ac7d (patch) | |
tree | 42a52b9f48891fd99c3e350022d65d9c1897f267 | |
parent | a511101ed0d42342bc0b1225bd9c7f2203031dec (diff) |
test: packet_gen: use static array size
In open_pktios(), if the number of rx or tx threads is zero, the
pktin[] or pktout[] arrays end up being zero size, which is undefined
behavior. Fix by using a static array size. Also, move the arrays into
a smaller scope.
Fixes GCC undefined sanitizer error:
odp_packet_gen.c:790:20: runtime error: variable length array bound evaluates to non-positive value 0
Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
-rw-r--r-- | test/performance/odp_packet_gen.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/performance/odp_packet_gen.c b/test/performance/odp_packet_gen.c index 413ceaf81..c7b3eb747 100644 --- a/test/performance/odp_packet_gen.c +++ b/test/performance/odp_packet_gen.c @@ -810,8 +810,6 @@ static int open_pktios(test_global_t *global) uint32_t num_pkt = test_options->num_pkt; uint32_t pkt_len = test_options->use_rand_pkt_len ? test_options->rand_pkt_len_max : test_options->pkt_len; - odp_pktout_queue_t pktout[num_tx]; - odp_pktin_queue_t pktin[num_rx]; printf("\nODP packet generator\n"); printf(" quit test after %" PRIu64 " rounds\n", @@ -1062,6 +1060,8 @@ static int open_pktios(test_global_t *global) } if (num_tx > 0) { + odp_pktout_queue_t pktout[MAX_THREADS]; + if (odp_pktout_queue(pktio, pktout, num_tx) != num_tx) { ODPH_ERR("Error (%s): Pktout queue request failed.\n", name); return -1; @@ -1072,6 +1072,8 @@ static int open_pktios(test_global_t *global) } if (num_rx > 0 && test_options->direct_rx) { + odp_pktin_queue_t pktin[MAX_THREADS]; + if (odp_pktin_queue(pktio, pktin, num_rx) != num_rx) { ODPH_ERR("Error (%s): Pktin queue request failed.\n", name); return -1; |