Skip to content

Commit

Permalink
linux-gen: pktio: add assert check for odp_pktio_max_index() return v…
Browse files Browse the repository at this point in the history
…alue

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 <matias.elo@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
  • Loading branch information
MatiasElo committed Oct 20, 2023
1 parent a66003a commit f8a524a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions platform/linux-generic/odp_packet_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <odp_posix_extensions.h>

#include <odp/api/buffer.h>
#include <odp/api/debug.h>
#include <odp/api/packet.h>
#include <odp/api/packet_io.h>
#include <odp/api/proto_stats.h>
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f8a524a

Please sign in to comment.