[PATCH dpdk v2] mbuf: fix strict aliasing error in allocator
Stephen Hemminger
stephen at networkplumber.org
Wed Sep 25 17:47:41 CEST 2024
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>
More information about the dev
mailing list