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

Thomas Monjalon thomas.monjalon at 6wind.com
Thu Dec 11 01:54:21 CET 2014


> > 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