DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Eli Britstein <elibr@nvidia.com>
Cc: <dev@dpdk.org>, Matan Azrad <matan@nvidia.com>,
	Asaf Penso <asafp@nvidia.com>,
	Slava Ovsiienko <viacheslavo@nvidia.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	<bruce.richardson@intel.com>, <konstantin.ananyev@intel.com>,
	<olivier.matz@6wind.com>, <stable@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH V2 1/3] net: avoid cast-align warning in VLAN insert function
Date: Thu, 21 Oct 2021 09:22:29 -0700	[thread overview]
Message-ID: <20211021092229.6fcf55b0@hermes.local> (raw)
In-Reply-To: <1ce86c5c-6255-398b-de8a-8c79c6c747cd@nvidia.com>

On Thu, 21 Oct 2021 19:16:19 +0300
Eli Britstein <elibr@nvidia.com> wrote:

> On 10/21/2021 6:48 PM, Stephen Hemminger wrote:
> > External email: Use caution opening links or attachments
> >
> >
> > On Thu, 21 Oct 2021 11:51:30 +0300
> > Eli Britstein <elibr@nvidia.com> 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 <elibr@nvidia.com>
> >> Acked-by: Olivier Matz <olivier.matz@6wind.com>  
> > 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.  
> 
> Removing the second cast, it is silently done anyway, as 'nh' is of type 
> 'struct rte_ether_hdr *'.
> 
> Going with this approach (I can also do it for patch 3/3), we can change 
> rte_pktmbuf_prepend to return (void *), and let the applications using 
> it do the silent cast.
> 
> What do you think?

Changing return type is an API change so it would need the whole
multistep process.

I overstated a little, it turns out the cast is necessary when header
is included by C++ code. C++ is pickier and doesn't allow void * to be
converted to other type by assignment.

Probably best to stick with what you originally proposed.
Gcc does have a bunch of alignment attribute types that could also fix this
but that gets even messier.
 


      reply	other threads:[~2021-10-21 16:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13  6:49 [dpdk-dev] [PATCH 0/3] Avoid cast-align warnings Eli Britstein
2021-07-13  6:49 ` [dpdk-dev] [PATCH 1/3] net: avoid cast-align warning in VLAN insert function Eli Britstein
2021-07-30 10:57   ` Olivier Matz
2021-07-13  6:49 ` [dpdk-dev] [PATCH 2/3] mbuf: avoid cast-align warning in pktmbuf mtod offset macro Eli Britstein
2021-07-13  7:43   ` Thomas Monjalon
2021-07-28 15:28   ` Olivier Matz
2021-07-29  7:13     ` Eli Britstein
2021-07-30 11:10       ` Olivier Matz
2021-08-01  8:06         ` Eli Britstein
2021-10-19  6:41           ` Eli Britstein
2021-10-19  9:47             ` Olivier Matz
2021-07-13  6:49 ` [dpdk-dev] [PATCH 3/3] eal/x86: avoid cast-align warning in x86 memcpy functions Eli Britstein
2021-10-21  8:51 ` [dpdk-dev] [PATCH V2 1/3] net: avoid cast-align warning in VLAN insert function Eli Britstein
2021-10-21  8:51   ` [dpdk-dev] [PATCH V2 2/3] mbuf: avoid cast-align warning in pktmbuf mtod offset macro Eli Britstein
2021-10-21  8:51   ` [dpdk-dev] [PATCH V2 3/3] eal/x86: avoid cast-align warning in x86 memcpy functions Eli Britstein
2021-10-25 15:29     ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2021-10-21 15:48   ` [dpdk-dev] [PATCH V2 1/3] net: avoid cast-align warning in VLAN insert function Stephen Hemminger
2021-10-21 16:16     ` Eli Britstein
2021-10-21 16:22       ` Stephen Hemminger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211021092229.6fcf55b0@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=asafp@nvidia.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=elibr@nvidia.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=matan@nvidia.com \
    --cc=olivier.matz@6wind.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).