[dpdk-dev] [PATCH v3] test-pmd: Fix pointer aliasing error

r k rkerur at gmail.com
Thu Dec 11 18:51:44 CET 2014


Thomas, Michael,

Wouldn't it cause unaligned memory access (new changes as well as the
previous code)? Wondering if get_unaligned/put_unaligned macros similar to
the ones used in kernel be ported to user-space?

Thanks,
Ravi

On Wed, Dec 10, 2014 at 4:54 PM, Thomas Monjalon <thomas.monjalon at 6wind.com>
wrote:
>
> > > app/test-pmd/csumonly.c: In function 'get_psd_sum':
> > > build/include/rte_ip.h:161: error: dereferencing pointer 'u16'
> > >         does break strict-aliasing rules
> > > build/include/rte_ip.h:157: note: initialized from here
> > >         ...
> > >
> > > The root cause is that, compile enable strict aliasing by default,
> > > while in function rte_raw_cksum() try to convert 'const char *'
> > > to 'const uint16_t *'.
> > >
> > > This patch is one workaround fix.
> > >
> > > Signed-off-by: Michael Qiu <michael.qiu at intel.com>
> > > ---
> > > v3 --> v2:
> > >     use uintptr_t instead of unsigned long to
> > >     save pointer.
> > >
> > > v2 --> v1:
> > >     Workaround solution instead of shut off the
> > >     gcc params.
> >
> > This workaround is to solve the compile issue of GCC strict-aliasing(Two
> > different type pointers should not be point to the same memory address).
> >
> > For GCC 4.4.7 it will definitely occurs if  flags "-fstrict-aliasing"
> > and "-Wall" used.
>
> Acked-by: Thomas Monjalon <thomas.monjalon at 6wind.com>>
>
> Applied with a comment in the code.
>
> Thanks
> --
> Thomas
>


More information about the dev mailing list