[dpdk-dev] [PATCH 2/3] crypto: fix pedentic compilation errors

Nelio Laranjeiro nelio.laranjeiro at 6wind.com
Wed Nov 22 11:35:55 CET 2017


Hi Pablo,

On Wed, Nov 22, 2017 at 09:48:47AM +0000, De Lara Guarch, Pablo wrote:
> Hi Nelio,
> 
> > -----Original Message-----
> > From: Nelio Laranjeiro [mailto:nelio.laranjeiro at 6wind.com]
> > Sent: Wednesday, November 22, 2017 8:10 AM
> > To: Akhil Goyal <akhil.goyal at nxp.com>; Doherty, Declan
> > <declan.doherty at intel.com>
> > Cc: dev at dpdk.org; De Lara Guarch, Pablo
> > <pablo.de.lara.guarch at intel.com>; stable at dpdk.org
> > Subject: [PATCH 2/3] crypto: fix pedentic compilation errors
> > 
> >  /root/dpdk/x86_64-native-linuxapp-gcc/include/rte_crypto.h:126:28:
> > error: ISO C forbids zero-size array ‘sym’ [-Werror=pedantic]
> >    struct rte_crypto_sym_op sym[0];
> >                             ^~~
> > 
> > Fixes: d2a4223c4c6d ("cryptodev: do not store pointer to op specific
> > params")
> > Cc: pablo.de.lara.guarch at intel.com
> > Cc: stable at dpdk.org
> > 
> > Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro at 6wind.com>
> > ---
> >  lib/librte_cryptodev/rte_crypto.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/lib/librte_cryptodev/rte_crypto.h
> > b/lib/librte_cryptodev/rte_crypto.h
> > index 3d672fe7d..dc6e91d1d 100644
> > --- a/lib/librte_cryptodev/rte_crypto.h
> > +++ b/lib/librte_cryptodev/rte_crypto.h
> > @@ -123,7 +123,7 @@ struct rte_crypto_op {
> > 
> >  	RTE_STD_C11
> >  	union {
> > -		struct rte_crypto_sym_op sym[0];
> > +		struct rte_crypto_sym_op *sym;
> 
> This would add extra 64 bits that are not necessary,
> as the rte_crypto_sym_op structure is always placed after rte_crypto_op
> (this is just a marker).
> 
> Is there any other way to fix this error?

Indeed it is not the correct solution, the point here is RTE_STD_C11 is
wrongly used because even in C11 arrays with size of 0 are not
allowed.  If it was the last attribute of the structure it could have
been replaced with empty brackets but as it is inside an union, it
cannot.  The correct solution is to replace the RTE_STD_C11 by
__extension__.

> Which compiler are you using?

It occurs with any compiler when you enable the pedantic flag under C11.
All DPDK headers have been fix to avoid such issue [1].

Thanks,

[1] http://dpdk.org/ml/archives/dev/2016-April/037051.html

-- 
Nélio Laranjeiro
6WIND


More information about the dev mailing list