From f8a524a0fadc1bc52377f5d46fdba5ddfe94a689 Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Mon, 28 Aug 2023 09:32:07 +0300 Subject: [PATCH] linux-gen: pktio: add assert check for odp_pktio_max_index() return value Add compile time check for odp_pktio_max_index() return value. Test that implementation internal ODP_CONFIG_PKTIO_ENTRIES define is smaller or equal than the new ODP_PKTIO_MAX_INDEX define. Signed-off-by: Matias Elo Reviewed-by: Tuomas Taipale Reviewed-by: Petri Savolainen --- platform/linux-generic/odp_packet_io.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 406916de25..38c1c2b033 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -1625,6 +1626,9 @@ int odp_pktio_capability(odp_pktio_t pktio, odp_pktio_capability_t *capa) return 0; } +ODP_STATIC_ASSERT(ODP_CONFIG_PKTIO_ENTRIES - 1 <= ODP_PKTIO_MAX_INDEX, + "ODP_CONFIG_PKTIO_ENTRIES larger than ODP_PKTIO_MAX_INDEX"); + unsigned int odp_pktio_max_index(void) { return ODP_CONFIG_PKTIO_ENTRIES - 1;