Skip to content

Commit

Permalink
linux-gen: pktio: fix flexible array member error in pedantic compila…
Browse files Browse the repository at this point in the history
…tion

When compiling with GCC 13.1 and -Wpedantic, struct sset_info causes
the error "invalid use of structure with flexible array member
[-Werror=pedantic]". The flexible array member in this case is the
data member of struct ethtool_sset_info. In order to reserve space for
it, turn sset_info into a union, and make the next member in the union
the size of struct ethtool_sset_info and the data.

Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
  • Loading branch information
JereLeppanen committed Dec 21, 2023
1 parent 4e8212b commit 013b0f8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions platform/linux-generic/pktio/stats/ethtool_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@

static struct ethtool_gstrings *get_stringset(int fd, struct ifreq *ifr)
{
struct {
union {
struct ethtool_sset_info hdr;
uint32_t buf[1]; /* overlaps with hdr.data[] */
/* Reserve space for hdr.data. */
uint8_t buf[sizeof(struct ethtool_sset_info) +
sizeof(((struct ethtool_sset_info *)0)->data[0])];
} sset_info;
struct ethtool_drvinfo drvinfo;
uint32_t len;
Expand Down

0 comments on commit 013b0f8

Please sign in to comment.