Eric Blake <ebl...@redhat.com> writes:

> Similar to the previous patch, it's nice to have all functions
> in the tree that involve a visitor and a name for conversion to
> or from QAPI to consistently stick the 'name' parameter next
> to the Visitor parameter.
>
> Done by manually changing include/qom/object.h and qom/object.c,
> then running this Coccinelle script and touching up the fallout
> (Coccinelle insisted on adding some trailing whitespace).
>
>     @ rule1 @
>     identifier fn;
>     type Object, Visitor, Error;
>     identifier obj, v, opaque, name, errp;
>     @@
>      void fn
>     - (Object *obj, Visitor *v, void *opaque, const char *name,
>     + (Object *obj, Visitor *v, const char *name, void *opaque,
>        Error **errp) { ... }

I think we want to match void functions with exactly these parameter
types.  The parameter names don't matter.

However, the actual match is looser!  For instance, it also matches

    void foo(int *pi, unsigned *pu, void *vp, const char *cp, double **dpp)
    {
    }

This could mess up unrelated function.  I could double-check it doesn't,
but I'd rather have a narrower match instead.  Can't give one offhand,
though.  Ideas?

>
>     @@
>     identifier rule1.fn;
>     expression obj, v, opaque, name, errp;
>     @@
>      fn(obj, v,
>     -   opaque, name,
>     +   name, opaque,
>         errp)

The rule1.fn restricts the match to functions changed by the previous
rule.  Good.

>
> Signed-off-by: Eric Blake <ebl...@redhat.com>
> Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com>

Reply via email to