Thread (19 messages) 19 messages, 4 authors, 2021-10-25

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

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2021-10-21 15:48:56

On Thu, 21 Oct 2021 11:51:30 +0300
Eli Britstein [off-list ref] wrote:
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 <redacted>
Acked-by: Olivier Matz <redacted>
After cast to void * the second cast is not necessary.

	nh = (void *)rte_pktmbuf_prepend(...)

Ideally rte_pktmbuf_prepend() should return void * but that is
an API change.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help