[PATCH dpdk v2] mbuf: fix strict aliasing error in allocator
Thomas Monjalon
thomas at monjalon.net
Thu Oct 17 21:44:44 CEST 2024
25/09/2024 17:47, Stephen Hemminger:
> On Wed, 25 Sep 2024 11:40:54 -0400
> Robin Jarry <rjarry at redhat.com> wrote:
>
> > From: Robin Jarry <rjarry at redhat.com>
> > To: dev at dpdk.org
> > Subject: [PATCH dpdk v2] mbuf: fix strict aliasing error in allocator
> > Date: Wed, 25 Sep 2024 11:40:54 -0400
> >
> > When building an application with -fstrict-aliasing -Wstrict-aliasing=2,
> > we get errors triggered by rte_mbuf_raw_alloc() which is called inline
> > from rte_pktmbuf_alloc().
> >
> > ../dpdk/lib/mbuf/rte_mbuf.h: In function ‘rte_mbuf_raw_alloc’:
> > ../dpdk/lib/mbuf/rte_mbuf.h:600:42: error: dereferencing type-punned
> > pointer might break strict-aliasing rules [-Werror=strict-aliasing]
> > 600 | if (rte_mempool_get(mp, (void **)&m) < 0)
> > | ^~
> >
> > Avoid incorrect casting by using an inline union variable.
> >
> > Signed-off-by: Robin Jarry <rjarry at redhat.com>
>
> Thanks, union is safer than cast.
>
> Reviewed-by: Stephen Hemminger <stephen at networkplumber.org>
Applied, thanks.
More information about the dev
mailing list