Skip to content

Commit

Permalink
helper: ip: avoid using a VLA in a header because of C++ apps
Browse files Browse the repository at this point in the history
Variable length arrays are not allowed in C++, so do not use one in
a header file that may be included by a C++ application. Clang++-18
complains about it, breaking the build.

Signed-off-by: Janne Peltonen <[email protected]>
Reviewed-by: Tuomas Taipale <[email protected]>
  • Loading branch information
JannePeltonen authored and MatiasElo committed Sep 27, 2024
1 parent cefac52 commit bd490f1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion helper/include/odp/helper/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ static inline int odph_ipv4_csum(odp_packet_t pkt,
odp_u16sum_t *chksum)
{
uint32_t nleft = (uint32_t)(ODPH_IPV4HDR_IHL(ip->ver_ihl) * 4);
uint16_t buf[nleft / 2];
const int max_ip_header_len = 15 * 4;
uint16_t buf[max_ip_header_len];
int res;

if (odp_unlikely(nleft < sizeof(*ip)))
Expand Down

0 comments on commit bd490f1

Please sign in to comment.