[dpdk-stable] [PATCH V2 1/3] net: avoid cast-align warning in VLAN insert function

Eli Britstein elibr at nvidia.com
Thu Oct 21 10:51:30 CEST 2021


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 at dpdk.org

Signed-off-by: Eli Britstein <elibr at nvidia.com>
Acked-by: Olivier Matz <olivier.matz at 6wind.com>
---
 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 b83e0d3fce..9febb60300 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.28.0.2311.g225365fb51



More information about the stable mailing list