DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Gaëtan Rivet" <gaetan.rivet@6wind.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>,
	Akhil Goyal <akhil.goyal@nxp.com>,
	Declan Doherty <declan.doherty@intel.com>,
	dev@dpdk.org, pablo.de.lara.guarch@intel.com, stable@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 2/3] crypto: fix pedentic compilation errors
Date: Wed, 22 Nov 2017 15:31:51 +0100	[thread overview]
Message-ID: <20171122143151.y5f44gnmy25t5sq2@bidouze.vm.6wind.com> (raw)
In-Reply-To: <20171122135614.GB624@hmswarspite.think-freely.org>

On Wed, Nov 22, 2017 at 08:56:14AM -0500, Neil Horman wrote:
> On Wed, Nov 22, 2017 at 09:10:17AM +0100, Nelio Laranjeiro wrote:
> >  /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@intel.com
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@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;
> >  		/**< Symmetric operation parameters */
> >  	}; /**< operation specific parameters */
> >  };
> > -- 
> > 2.11.0
> > 
> > 
> As Laura notes, this isn't the right solution.  In addition to adding a 64 bit
> pointer, it I think also results in incorrect semantics.  That is to say, the
> allocation path for this structure allocates the rte_crypto_op and additional
> memory for the sym array contiguously, which the sym[0] syntax correctly
> interprets to mean the storage for the array is inline with the structure.
> Changing to a pointer means you are using the first elements of the array
> storage as your pointer, which could be filled with any old value, leading to
> corruption.
> 
> If you can't use zero length array semantics (which I assume you cant, as I
> don't think clang supports that), a better soution might be to remove the sym
> variable entirely, and replace it with a macro that access the sym array as an
> offset from the start of the pointer.  That would seem to be an ABI change, but
> if you went through that process you would wind up with the same sized struct,
> which would be nice
> 
> Neil
> 

ISO C forbids zero-size arrays, but ISO C99 allows flexible arrays.
Why is this symbole within a union? Why not remove the union, change
sym[0] to sym[]?

-- 
Gaëtan Rivet
6WIND

  reply	other threads:[~2017-11-22 14:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22  8:10 [dpdk-dev] [PATCH 1/3] security: fix device operation type Nelio Laranjeiro
2017-11-22  8:10 ` [dpdk-dev] [PATCH 2/3] crypto: fix pedentic compilation errors Nelio Laranjeiro
2017-11-22  9:48   ` De Lara Guarch, Pablo
2017-11-22 10:35     ` Nelio Laranjeiro
2017-11-22 13:56   ` Neil Horman
2017-11-22 14:31     ` Gaëtan Rivet [this message]
2017-11-22 16:50       ` De Lara Guarch, Pablo
2017-11-22  8:10 ` [dpdk-dev] [PATCH 3/3] security: fix pedentic compilation Nelio Laranjeiro
2017-11-23 10:02   ` [dpdk-dev] [PATCH v2 1/3] security: fix device operation type Nelio Laranjeiro
2017-11-24  9:33     ` Akhil Goyal
2017-11-24 12:07       ` Nelio Laranjeiro
2018-01-08  9:58         ` [dpdk-dev] [dpdk-stable] " De Lara Guarch, Pablo
2018-01-08 10:05           ` Akhil Goyal
2018-01-08 12:34     ` De Lara Guarch, Pablo
2017-11-23 10:02   ` [dpdk-dev] [PATCH v2 2/3] crypto: fix pedantic compilation errors Nelio Laranjeiro
2017-12-11 11:49     ` De Lara Guarch, Pablo
2017-12-11 12:42       ` Nelio Laranjeiro
2017-12-11 13:54         ` De Lara Guarch, Pablo
2017-12-11 14:16           ` Nelio Laranjeiro
2018-01-08 10:00             ` De Lara Guarch, Pablo
2018-01-08 12:35     ` De Lara Guarch, Pablo
2017-11-23 10:02   ` [dpdk-dev] [PATCH v2 3/3] security: fix pedantic compilation Nelio Laranjeiro
2017-11-24  9:34     ` Akhil Goyal
2018-01-08 12:35     ` [dpdk-dev] [dpdk-stable] " De Lara Guarch, Pablo

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=20171122143151.y5f44gnmy25t5sq2@bidouze.vm.6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=akhil.goyal@nxp.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=nelio.laranjeiro@6wind.com \
    --cc=nhorman@tuxdriver.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=stable@dpdk.org \
    /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).