Skip to content

Commit

Permalink
linux-gen: pktio: quell array bounds warning in pedantic compilation
Browse files Browse the repository at this point in the history
Quell "array subscript 0 is outside array bounds of ‘__u32[]’" warning
when compiling with GCC 13.1.1 and -Wpedantic.

Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
  • Loading branch information
JereLeppanen committed Jun 9, 2023
1 parent 652979f commit cebd2cb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions platform/linux-generic/pktio/stats/ethtool_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ static struct ethtool_gstrings *get_stringset(int fd, struct ifreq *ifr)
hdr.sset_mask = 1ULL << ETH_SS_STATS;
ifr->ifr_data = (void *)&hdr;
if (ioctl(fd, SIOCETHTOOL, ifr) == 0) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
len = hdr.sset_mask ? hdr.data[0] : 0;
#pragma GCC diagnostic pop
} else if (errno == EOPNOTSUPP && drvinfo_offset != 0) {
/* Fallback for old kernel versions */
drvinfo.cmd = ETHTOOL_GDRVINFO;
Expand Down

0 comments on commit cebd2cb

Please sign in to comment.