On Mon, Jun 19, 2017 at 10:43:51AM +0100, Peter Maydell wrote:
> On 19 June 2017 at 09:48, Dr. David Alan Gilbert <dgilb...@redhat.com> wrote:
> > * Eduardo Habkost (ehabk...@redhat.com) wrote:
> >> On Thu, Jun 15, 2017 at 01:14:15PM +0100, Dr. David Alan Gilbert wrote:
> >> > * Eduardo Habkost (ehabk...@redhat.com) wrote:
> >> > >  void visit_start_struct(Visitor *v, const char *name, void **obj,
> >> > > -                        size_t size, Error **errp);
> >> > > +                        size_t size, Error *errp[static 1]);
> >> > >
> >> >
> >> > Is it possible to typedef that to something that hides the magic syntax?
> >> > Then we could get that down to QError errp   or something like that?
> >>
> >> Unfortunately it is not possible to hide it in a typedef: the
> >> "static" keyword inside the square brackets is a feature of
> >> function parameter declarations only.  Using it on a typedef
> >> results in:
> >>
> >> a.c:3:16: error: static or type qualifiers in non-parameter array 
> >> declarator
> >>  typedef Error *ErrorPtr[static 1];
> >
> > That's a shame; it's rather odd looking; still I think it's
> > worth it if it simplifies the error code.
> 
> Is gcc's __attribute__((nonnull)) any better? It seems to apply
> to the whole function prototype rather than an individual argument
> though so probably not :-(

It's possible to specify which arguments are non-null with
nonnull(<arg-index>, ...).  It's harder to use, but probably more
Coccinelle-friendly.

-- 
Eduardo

Reply via email to