From a3f8d05871887d257703f6f073da002b6c568519 Mon Sep 17 00:00:00 2001 From: Eli Britstein Date: Thu, 21 Oct 2021 11:51:30 +0300 Subject: [PATCH 1/1] net: avoid cast-align warning in VLAN insert function In rte_vlan_insert there is a casting of rte_pktmbuf_prepend returned value to (struct rte_ether_hdr *), which causes cast-align warning when using strict cast align flag with supporting gcc: gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 CFLAGS="-Wcast-align=strict" make V=1 -C examples/l2fwd clean static In file included from main.c:35: /dpdk/build/include/rte_ether.h:370:7: warning: cast increases required alignment of target type [-Wcast-align] 370 | nh = (struct rte_ether_hdr *) | ^ As the code assumes correct alignment, add first a (void *) casting, to avoid the warning. Fixes: c974021a5949 ("ether: add soft vlan encap/decap") Cc: stable@dpdk.org Signed-off-by: Eli Britstein Acked-by: Olivier Matz --- lib/net/rte_ether.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/net/rte_ether.h b/lib/net/rte_ether.h index 2c7da55b6b..1a0dbf0d60 100644 --- a/lib/net/rte_ether.h +++ b/lib/net/rte_ether.h @@ -367,7 +367,7 @@ static inline int rte_vlan_insert(struct rte_mbuf **m) return -EINVAL; oh = rte_pktmbuf_mtod(*m, struct rte_ether_hdr *); - nh = (struct rte_ether_hdr *) + nh = (struct rte_ether_hdr *)(void *) rte_pktmbuf_prepend(*m, sizeof(struct rte_vlan_hdr)); if (nh == NULL) return -ENOSPC; -- 2.20.1