diff mbox

[v9,16/37] qapi: Swap 'name' in visit_* callbacks to match public API

Message ID 1453219845-30939-17-git-send-email-eblake@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Blake Jan. 19, 2016, 4:10 p.m. UTC
As explained in the previous patches, matching argument order of
'name, &value' to JSON's "name":value makes sense.  However,
while the last two patches were easy with Coccinelle, I ended up
doing this one all by hand.  Now all the visitor callbacks match
the main interface.

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

---
v9: no change
v8: new patch
---
 include/qapi/visitor-impl.h  | 39 +++++++++++++++++++++------------------
 qapi/opts-visitor.c          | 16 ++++++++--------
 qapi/qapi-dealloc-visitor.c  | 25 ++++++++++++-------------
 qapi/qapi-visit-core.c       | 38 +++++++++++++++++++-------------------
 qapi/qmp-input-visitor.c     | 22 +++++++++++-----------
 qapi/qmp-output-visitor.c    | 16 ++++++++--------
 qapi/string-input-visitor.c  | 16 ++++++++--------
 qapi/string-output-visitor.c | 16 ++++++++--------
 8 files changed, 95 insertions(+), 93 deletions(-)

Comments

Markus Armbruster Jan. 20, 2016, 6:55 p.m. UTC | #1
Eric Blake <eblake@redhat.com> writes:

> As explained in the previous patches, matching argument order of
> 'name, &value' to JSON's "name":value makes sense.  However,
> while the last two patches were easy with Coccinelle, I ended up
> doing this one all by hand.  Now all the visitor callbacks match
> the main interface.
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> ---
> v9: no change
> v8: new patch
> ---
>  include/qapi/visitor-impl.h  | 39 +++++++++++++++++++++------------------
>  qapi/opts-visitor.c          | 16 ++++++++--------
>  qapi/qapi-dealloc-visitor.c  | 25 ++++++++++++-------------
>  qapi/qapi-visit-core.c       | 38 +++++++++++++++++++-------------------
>  qapi/qmp-input-visitor.c     | 22 +++++++++++-----------
>  qapi/qmp-output-visitor.c    | 16 ++++++++--------
>  qapi/string-input-visitor.c  | 16 ++++++++--------
>  qapi/string-output-visitor.c | 16 ++++++++--------
>  8 files changed, 95 insertions(+), 93 deletions(-)
>
> diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h
> index e6399d1..0257359 100644
> --- a/include/qapi/visitor-impl.h
> +++ b/include/qapi/visitor-impl.h
> @@ -18,8 +18,8 @@
>  struct Visitor
>  {
>      /* Must be set */
> -    void (*start_struct)(Visitor *v, void **obj, const char *kind,
> -                         const char *name, size_t size, Error **errp);
> +    void (*start_struct)(Visitor *v, const char *name, void **obj,
> +                         const char *kind, size_t size, Error **errp);
>      void (*end_struct)(Visitor *v, Error **errp);
>
>      void (*start_implicit_struct)(Visitor *v, void **obj, size_t size,
> @@ -30,39 +30,42 @@ struct Visitor
>      GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp);
>      void (*end_list)(Visitor *v, Error **errp);
>
> -    void (*type_enum)(Visitor *v, int *obj, const char * const strings[],
> -                      const char *kind, const char *name, Error **errp);
> +    void (*type_enum)(Visitor *v, const char *name, int *obj,
> +                      const char * const strings[], const char *kind,

Opportunity to change to 'const char *const'.  I prefer that, because it
makes the fact that this is a pointer-* and not a binary operator-*
visually obvious.

Same elsewhere.

> +                      Error **errp);
>      /* May be NULL; only needed for input visitors. */
> -    void (*get_next_type)(Visitor *v, QType *type, bool promote_int,
> -                          const char *name, Error **errp);
> +    void (*get_next_type)(Visitor *v, const char *name, QType *type,
> +                          bool promote_int, Error **errp);
>
>      /* Must be set. */
> -    void (*type_int64)(Visitor *v, int64_t *obj, const char *name,
> +    void (*type_int64)(Visitor *v, const char *name, int64_t *obj,
>                         Error **errp);
>      /* Must be set. */
> -    void (*type_uint64)(Visitor *v, uint64_t *obj, const char *name,
> +    void (*type_uint64)(Visitor *v, const char *name, uint64_t *obj,
>                          Error **errp);
>      /* Optional; fallback is type_uint64().  */
> -    void (*type_size)(Visitor *v, uint64_t *obj, const char *name,
> +    void (*type_size)(Visitor *v, const char *name, uint64_t *obj,
>                        Error **errp);
>      /* Must be set. */
> -    void (*type_bool)(Visitor *v, bool *obj, const char *name, Error **errp);
> -    void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp);
> -    void (*type_number)(Visitor *v, double *obj, const char *name,
> +    void (*type_bool)(Visitor *v, const char *name, bool *obj, Error **errp);
> +    void (*type_str)(Visitor *v, const char *name, char **obj, Error **errp);
> +    void (*type_number)(Visitor *v, const char *name, double *obj,
>                          Error **errp);
> -    void (*type_any)(Visitor *v, QObject **obj, const char *name,
> +    void (*type_any)(Visitor *v, const char *name, QObject **obj,
>                       Error **errp);
>
>      /* May be NULL; most useful for input visitors. */
> -    void (*optional)(Visitor *v, bool *present, const char *name);
> +    void (*optional)(Visitor *v, const char *name, bool *present);
>
>      bool (*start_union)(Visitor *v, bool data_present, Error **errp);
>      void (*end_union)(Visitor *v, bool data_present, Error **errp);
>  };
>
> -void input_type_enum(Visitor *v, int *obj, const char * const strings[],
> -                     const char *kind, const char *name, Error **errp);
> -void output_type_enum(Visitor *v, int *obj, const char * const strings[],
> -                      const char *kind, const char *name, Error **errp);
> +void input_type_enum(Visitor *v, const char *name, int *obj,
> +                     const char * const strings[], const char *kind,
> +                     Error **errp);
> +void output_type_enum(Visitor *v, const char *name, int *obj,
> +                      const char * const strings[], const char *kind,
> +                      Error **errp);
>
>  #endif

I checked the changes to this file carefully.  Can we rely on the
compiler to flag mistakes in the rest of the patch?
Eric Blake Jan. 20, 2016, 9:01 p.m. UTC | #2
On 01/20/2016 11:55 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
> 
>> As explained in the previous patches, matching argument order of
>> 'name, &value' to JSON's "name":value makes sense.  However,
>> while the last two patches were easy with Coccinelle, I ended up
>> doing this one all by hand.  Now all the visitor callbacks match
>> the main interface.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>

>> @@ -30,39 +30,42 @@ struct Visitor
>>      GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp);
>>      void (*end_list)(Visitor *v, Error **errp);
>>
>> -    void (*type_enum)(Visitor *v, int *obj, const char * const strings[],
>> -                      const char *kind, const char *name, Error **errp);
>> +    void (*type_enum)(Visitor *v, const char *name, int *obj,
>> +                      const char * const strings[], const char *kind,
> 
> Opportunity to change to 'const char *const'.  I prefer that, because it
> makes the fact that this is a pointer-* and not a binary operator-*
> visually obvious.
> 
> Same elsewhere.

Hmm, I probably have churn later in the series.  Will fix.

>>      /* May be NULL; most useful for input visitors. */
>> -    void (*optional)(Visitor *v, bool *present, const char *name);
>> +    void (*optional)(Visitor *v, const char *name, bool *present);
>>

> 
> I checked the changes to this file carefully.  Can we rely on the
> compiler to flag mistakes in the rest of the patch?

C's (intentionally-loose) treatment of 'char *' like 'void *' is a bit
worrisome, but the fact that we have 'const' on only one of the two
swapped arguments was indeed enough to make the compiler complain about
mismatch in parameter types when trying to assign incorrectly-typed
static functions to the updated struct members.
Markus Armbruster Jan. 21, 2016, 9:19 a.m. UTC | #3
Eric Blake <eblake@redhat.com> writes:

> On 01/20/2016 11:55 AM, Markus Armbruster wrote:
>> Eric Blake <eblake@redhat.com> writes:
>> 
>>> As explained in the previous patches, matching argument order of
>>> 'name, &value' to JSON's "name":value makes sense.  However,
>>> while the last two patches were easy with Coccinelle, I ended up
>>> doing this one all by hand.  Now all the visitor callbacks match
>>> the main interface.
>>>
>>> Signed-off-by: Eric Blake <eblake@redhat.com>
>>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>>
>
>>> @@ -30,39 +30,42 @@ struct Visitor
>>>      GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp);
>>>      void (*end_list)(Visitor *v, Error **errp);
>>>
>>> -    void (*type_enum)(Visitor *v, int *obj, const char * const strings[],
>>> -                      const char *kind, const char *name, Error **errp);
>>> +    void (*type_enum)(Visitor *v, const char *name, int *obj,
>>> +                      const char * const strings[], const char *kind,
>> 
>> Opportunity to change to 'const char *const'.  I prefer that, because it
>> makes the fact that this is a pointer-* and not a binary operator-*
>> visually obvious.
>> 
>> Same elsewhere.
>
> Hmm, I probably have churn later in the series.  Will fix.
>
>>>      /* May be NULL; most useful for input visitors. */
>>> -    void (*optional)(Visitor *v, bool *present, const char *name);
>>> +    void (*optional)(Visitor *v, const char *name, bool *present);
>>>
>
>> 
>> I checked the changes to this file carefully.  Can we rely on the
>> compiler to flag mistakes in the rest of the patch?
>
> C's (intentionally-loose) treatment of 'char *' like 'void *' is a bit
> worrisome, but the fact that we have 'const' on only one of the two
> swapped arguments was indeed enough to make the compiler complain about
> mismatch in parameter types when trying to assign incorrectly-typed
> static functions to the updated struct members.

Okay, I guess that's good enough.
diff mbox

Patch

diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h
index e6399d1..0257359 100644
--- a/include/qapi/visitor-impl.h
+++ b/include/qapi/visitor-impl.h
@@ -18,8 +18,8 @@ 
 struct Visitor
 {
     /* Must be set */
-    void (*start_struct)(Visitor *v, void **obj, const char *kind,
-                         const char *name, size_t size, Error **errp);
+    void (*start_struct)(Visitor *v, const char *name, void **obj,
+                         const char *kind, size_t size, Error **errp);
     void (*end_struct)(Visitor *v, Error **errp);

     void (*start_implicit_struct)(Visitor *v, void **obj, size_t size,
@@ -30,39 +30,42 @@  struct Visitor
     GenericList *(*next_list)(Visitor *v, GenericList **list, Error **errp);
     void (*end_list)(Visitor *v, Error **errp);

-    void (*type_enum)(Visitor *v, int *obj, const char * const strings[],
-                      const char *kind, const char *name, Error **errp);
+    void (*type_enum)(Visitor *v, const char *name, int *obj,
+                      const char * const strings[], const char *kind,
+                      Error **errp);
     /* May be NULL; only needed for input visitors. */
-    void (*get_next_type)(Visitor *v, QType *type, bool promote_int,
-                          const char *name, Error **errp);
+    void (*get_next_type)(Visitor *v, const char *name, QType *type,
+                          bool promote_int, Error **errp);

     /* Must be set. */
-    void (*type_int64)(Visitor *v, int64_t *obj, const char *name,
+    void (*type_int64)(Visitor *v, const char *name, int64_t *obj,
                        Error **errp);
     /* Must be set. */
-    void (*type_uint64)(Visitor *v, uint64_t *obj, const char *name,
+    void (*type_uint64)(Visitor *v, const char *name, uint64_t *obj,
                         Error **errp);
     /* Optional; fallback is type_uint64().  */
-    void (*type_size)(Visitor *v, uint64_t *obj, const char *name,
+    void (*type_size)(Visitor *v, const char *name, uint64_t *obj,
                       Error **errp);
     /* Must be set. */
-    void (*type_bool)(Visitor *v, bool *obj, const char *name, Error **errp);
-    void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp);
-    void (*type_number)(Visitor *v, double *obj, const char *name,
+    void (*type_bool)(Visitor *v, const char *name, bool *obj, Error **errp);
+    void (*type_str)(Visitor *v, const char *name, char **obj, Error **errp);
+    void (*type_number)(Visitor *v, const char *name, double *obj,
                         Error **errp);
-    void (*type_any)(Visitor *v, QObject **obj, const char *name,
+    void (*type_any)(Visitor *v, const char *name, QObject **obj,
                      Error **errp);

     /* May be NULL; most useful for input visitors. */
-    void (*optional)(Visitor *v, bool *present, const char *name);
+    void (*optional)(Visitor *v, const char *name, bool *present);

     bool (*start_union)(Visitor *v, bool data_present, Error **errp);
     void (*end_union)(Visitor *v, bool data_present, Error **errp);
 };

-void input_type_enum(Visitor *v, int *obj, const char * const strings[],
-                     const char *kind, const char *name, Error **errp);
-void output_type_enum(Visitor *v, int *obj, const char * const strings[],
-                      const char *kind, const char *name, Error **errp);
+void input_type_enum(Visitor *v, const char *name, int *obj,
+                     const char * const strings[], const char *kind,
+                     Error **errp);
+void output_type_enum(Visitor *v, const char *name, int *obj,
+                      const char * const strings[], const char *kind,
+                      Error **errp);

 #endif
diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 56c798f..b1c8e50 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -124,8 +124,8 @@  opts_visitor_insert(GHashTable *unprocessed_opts, const QemuOpt *opt)


 static void
-opts_start_struct(Visitor *v, void **obj, const char *kind,
-                  const char *name, size_t size, Error **errp)
+opts_start_struct(Visitor *v, const char *name, void **obj, const char *kind,
+                  size_t size, Error **errp)
 {
     OptsVisitor *ov = to_ov(v);
     const QemuOpt *opt;
@@ -311,7 +311,7 @@  processed(OptsVisitor *ov, const char *name)


 static void
-opts_type_str(Visitor *v, char **obj, const char *name, Error **errp)
+opts_type_str(Visitor *v, const char *name, char **obj, Error **errp)
 {
     OptsVisitor *ov = to_ov(v);
     const QemuOpt *opt;
@@ -327,7 +327,7 @@  opts_type_str(Visitor *v, char **obj, const char *name, Error **errp)

 /* mimics qemu-option.c::parse_option_bool() */
 static void
-opts_type_bool(Visitor *v, bool *obj, const char *name, Error **errp)
+opts_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
 {
     OptsVisitor *ov = to_ov(v);
     const QemuOpt *opt;
@@ -360,7 +360,7 @@  opts_type_bool(Visitor *v, bool *obj, const char *name, Error **errp)


 static void
-opts_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp)
+opts_type_int64(Visitor *v, const char *name, int64_t *obj, Error **errp)
 {
     OptsVisitor *ov = to_ov(v);
     const QemuOpt *opt;
@@ -416,7 +416,7 @@  opts_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp)


 static void
-opts_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp)
+opts_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp)
 {
     OptsVisitor *ov = to_ov(v);
     const QemuOpt *opt;
@@ -468,7 +468,7 @@  opts_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp)


 static void
-opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
+opts_type_size(Visitor *v, const char *name, uint64_t *obj, Error **errp)
 {
     OptsVisitor *ov = to_ov(v);
     const QemuOpt *opt;
@@ -494,7 +494,7 @@  opts_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)


 static void
-opts_optional(Visitor *v, bool *present, const char *name)
+opts_optional(Visitor *v, const char *name, bool *present)
 {
     OptsVisitor *ov = to_ov(v);

diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c
index 11eb828..b521f7c 100644
--- a/qapi/qapi-dealloc-visitor.c
+++ b/qapi/qapi-dealloc-visitor.c
@@ -58,8 +58,8 @@  static void *qapi_dealloc_pop(QapiDeallocVisitor *qov)
     return value;
 }

-static void qapi_dealloc_start_struct(Visitor *v, void **obj, const char *kind,
-                                      const char *name, size_t unused,
+static void qapi_dealloc_start_struct(Visitor *v, const char *name, void **obj,
+                                      const char *kind, size_t unused,
                                       Error **errp)
 {
     QapiDeallocVisitor *qov = to_qov(v);
@@ -127,7 +127,7 @@  static void qapi_dealloc_end_list(Visitor *v, Error **errp)
     assert(obj == NULL); /* should've been list head tracker with no payload */
 }

-static void qapi_dealloc_type_str(Visitor *v, char **obj, const char *name,
+static void qapi_dealloc_type_str(Visitor *v, const char *name, char **obj,
                                   Error **errp)
 {
     if (obj) {
@@ -135,38 +135,37 @@  static void qapi_dealloc_type_str(Visitor *v, char **obj, const char *name,
     }
 }

-static void qapi_dealloc_type_int64(Visitor *v, int64_t *obj, const char *name,
+static void qapi_dealloc_type_int64(Visitor *v, const char *name, int64_t *obj,
                                     Error **errp)
 {
 }

-static void qapi_dealloc_type_uint64(Visitor *v, uint64_t *obj,
-                                     const char *name, Error **errp)
+static void qapi_dealloc_type_uint64(Visitor *v, const char *name,
+                                     uint64_t *obj, Error **errp)
 {
 }

-static void qapi_dealloc_type_bool(Visitor *v, bool *obj, const char *name,
+static void qapi_dealloc_type_bool(Visitor *v, const char *name, bool *obj,
                                    Error **errp)
 {
 }

-static void qapi_dealloc_type_number(Visitor *v, double *obj, const char *name,
+static void qapi_dealloc_type_number(Visitor *v, const char *name, double *obj,
                                      Error **errp)
 {
 }

-static void qapi_dealloc_type_anything(Visitor *v, QObject **obj,
-                                       const char *name, Error **errp)
+static void qapi_dealloc_type_anything(Visitor *v, const char *name,
+                                       QObject **obj, Error **errp)
 {
     if (obj) {
         qobject_decref(*obj);
     }
 }

-static void qapi_dealloc_type_enum(Visitor *v, int *obj,
+static void qapi_dealloc_type_enum(Visitor *v, const char *name, int *obj,
                                    const char * const strings[],
-                                   const char *kind, const char *name,
-                                   Error **errp)
+                                   const char *kind, Error **errp)
 {
 }

diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c
index 609db22..7bc3de6 100644
--- a/qapi/qapi-visit-core.c
+++ b/qapi/qapi-visit-core.c
@@ -20,7 +20,7 @@ 
 void visit_start_struct(Visitor *v, const char *name, void **obj,
                         const char *kind, size_t size, Error **errp)
 {
-    v->start_struct(v, obj, kind, name, size, errp);
+    v->start_struct(v, name, obj, kind, size, errp);
 }

 void visit_end_struct(Visitor *v, Error **errp)
@@ -76,7 +76,7 @@  void visit_end_union(Visitor *v, bool data_present, Error **errp)
 bool visit_optional(Visitor *v, const char *name, bool *present)
 {
     if (v->optional) {
-        v->optional(v, present, name);
+        v->optional(v, name, present);
     }
     return *present;
 }
@@ -85,7 +85,7 @@  void visit_get_next_type(Visitor *v, const char *name, QType *type,
                          bool promote_int, Error **errp)
 {
     if (v->get_next_type) {
-        v->get_next_type(v, type, promote_int, name, errp);
+        v->get_next_type(v, name, type, promote_int, errp);
     }
 }

@@ -93,12 +93,12 @@  void visit_type_enum(Visitor *v, const char *name, int *obj,
                      const char *const strings[], const char *kind,
                      Error **errp)
 {
-    v->type_enum(v, obj, strings, kind, name, errp);
+    v->type_enum(v, name, obj, strings, kind, errp);
 }

 void visit_type_int(Visitor *v, const char *name, int64_t *obj, Error **errp)
 {
-    v->type_int64(v, obj, name, errp);
+    v->type_int64(v, name, obj, errp);
 }

 static void visit_type_uintN(Visitor *v, uint64_t *obj, const char *name,
@@ -107,7 +107,7 @@  static void visit_type_uintN(Visitor *v, uint64_t *obj, const char *name,
     Error *err = NULL;
     uint64_t value = *obj;

-    v->type_uint64(v, &value, name, &err);
+    v->type_uint64(v, name, &value, &err);
     if (err) {
         error_propagate(errp, err);
     } else if (value > max) {
@@ -145,7 +145,7 @@  void visit_type_uint32(Visitor *v, const char *name, uint32_t *obj,
 void visit_type_uint64(Visitor *v, const char *name, uint64_t *obj,
                        Error **errp)
 {
-    v->type_uint64(v, obj, name, errp);
+    v->type_uint64(v, name, obj, errp);
 }

 static void visit_type_intN(Visitor *v, int64_t *obj, const char *name,
@@ -155,7 +155,7 @@  static void visit_type_intN(Visitor *v, int64_t *obj, const char *name,
     Error *err = NULL;
     int64_t value = *obj;

-    v->type_int64(v, &value, name, &err);
+    v->type_int64(v, name, &value, &err);
     if (err) {
         error_propagate(errp, err);
     } else if (value < min || value > max) {
@@ -192,42 +192,42 @@  void visit_type_int32(Visitor *v, const char *name, int32_t *obj,
 void visit_type_int64(Visitor *v, const char *name, int64_t *obj,
                       Error **errp)
 {
-    v->type_int64(v, obj, name, errp);
+    v->type_int64(v, name, obj, errp);
 }

 void visit_type_size(Visitor *v, const char *name, uint64_t *obj,
                      Error **errp)
 {
     if (v->type_size) {
-        v->type_size(v, obj, name, errp);
+        v->type_size(v, name, obj, errp);
     } else {
-        v->type_uint64(v, obj, name, errp);
+        v->type_uint64(v, name, obj, errp);
     }
 }

 void visit_type_bool(Visitor *v, const char *name, bool *obj, Error **errp)
 {
-    v->type_bool(v, obj, name, errp);
+    v->type_bool(v, name, obj, errp);
 }

 void visit_type_str(Visitor *v, const char *name, char **obj, Error **errp)
 {
-    v->type_str(v, obj, name, errp);
+    v->type_str(v, name, obj, errp);
 }

 void visit_type_number(Visitor *v, const char *name, double *obj,
                        Error **errp)
 {
-    v->type_number(v, obj, name, errp);
+    v->type_number(v, name, obj, errp);
 }

 void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **errp)
 {
-    v->type_any(v, obj, name, errp);
+    v->type_any(v, name, obj, errp);
 }

-void output_type_enum(Visitor *v, int *obj, const char * const strings[],
-                      const char *kind, const char *name,
+void output_type_enum(Visitor *v, const char *name, int *obj,
+                      const char * const strings[], const char *kind,
                       Error **errp)
 {
     int i = 0;
@@ -245,8 +245,8 @@  void output_type_enum(Visitor *v, int *obj, const char * const strings[],
     visit_type_str(v, name, &enum_str, errp);
 }

-void input_type_enum(Visitor *v, int *obj, const char * const strings[],
-                     const char *kind, const char *name,
+void input_type_enum(Visitor *v, const char *name, int *obj,
+                     const char * const strings[], const char *kind,
                      Error **errp)
 {
     Error *local_err = NULL;
diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c
index 32b60bb..de77740 100644
--- a/qapi/qmp-input-visitor.c
+++ b/qapi/qmp-input-visitor.c
@@ -114,8 +114,8 @@  static void qmp_input_pop(QmpInputVisitor *qiv, Error **errp)
     qiv->nb_stack--;
 }

-static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind,
-                                   const char *name, size_t size, Error **errp)
+static void qmp_input_start_struct(Visitor *v, const char *name, void **obj,
+                                   const char *kind, size_t size, Error **errp)
 {
     QmpInputVisitor *qiv = to_qiv(v);
     QObject *qobj = qmp_input_get_object(qiv, name, true);
@@ -208,8 +208,8 @@  static void qmp_input_end_list(Visitor *v, Error **errp)
     qmp_input_pop(qiv, errp);
 }

-static void qmp_input_get_next_type(Visitor *v, QType *type, bool promote_int,
-                                    const char *name, Error **errp)
+static void qmp_input_get_next_type(Visitor *v, const char *name, QType *type,
+                                    bool promote_int, Error **errp)
 {
     QmpInputVisitor *qiv = to_qiv(v);
     QObject *qobj = qmp_input_get_object(qiv, name, false);
@@ -224,7 +224,7 @@  static void qmp_input_get_next_type(Visitor *v, QType *type, bool promote_int,
     }
 }

-static void qmp_input_type_int64(Visitor *v, int64_t *obj, const char *name,
+static void qmp_input_type_int64(Visitor *v, const char *name, int64_t *obj,
                                  Error **errp)
 {
     QmpInputVisitor *qiv = to_qiv(v);
@@ -239,7 +239,7 @@  static void qmp_input_type_int64(Visitor *v, int64_t *obj, const char *name,
     *obj = qint_get_int(qint);
 }

-static void qmp_input_type_uint64(Visitor *v, uint64_t *obj, const char *name,
+static void qmp_input_type_uint64(Visitor *v, const char *name, uint64_t *obj,
                                   Error **errp)
 {
     /* FIXME: qobject_to_qint mishandles values over INT64_MAX */
@@ -255,7 +255,7 @@  static void qmp_input_type_uint64(Visitor *v, uint64_t *obj, const char *name,
     *obj = qint_get_int(qint);
 }

-static void qmp_input_type_bool(Visitor *v, bool *obj, const char *name,
+static void qmp_input_type_bool(Visitor *v, const char *name, bool *obj,
                                 Error **errp)
 {
     QmpInputVisitor *qiv = to_qiv(v);
@@ -270,7 +270,7 @@  static void qmp_input_type_bool(Visitor *v, bool *obj, const char *name,
     *obj = qbool_get_bool(qbool);
 }

-static void qmp_input_type_str(Visitor *v, char **obj, const char *name,
+static void qmp_input_type_str(Visitor *v, const char *name, char **obj,
                                Error **errp)
 {
     QmpInputVisitor *qiv = to_qiv(v);
@@ -285,7 +285,7 @@  static void qmp_input_type_str(Visitor *v, char **obj, const char *name,
     *obj = g_strdup(qstring_get_str(qstr));
 }

-static void qmp_input_type_number(Visitor *v, double *obj, const char *name,
+static void qmp_input_type_number(Visitor *v, const char *name, double *obj,
                                   Error **errp)
 {
     QmpInputVisitor *qiv = to_qiv(v);
@@ -309,7 +309,7 @@  static void qmp_input_type_number(Visitor *v, double *obj, const char *name,
                "number");
 }

-static void qmp_input_type_any(Visitor *v, QObject **obj, const char *name,
+static void qmp_input_type_any(Visitor *v, const char *name, QObject **obj,
                                Error **errp)
 {
     QmpInputVisitor *qiv = to_qiv(v);
@@ -319,7 +319,7 @@  static void qmp_input_type_any(Visitor *v, QObject **obj, const char *name,
     *obj = qobj;
 }

-static void qmp_input_optional(Visitor *v, bool *present, const char *name)
+static void qmp_input_optional(Visitor *v, const char *name, bool *present)
 {
     QmpInputVisitor *qiv = to_qiv(v);
     QObject *qobj = qmp_input_get_object(qiv, name, true);
diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c
index f8eebaa..af600a9 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -110,8 +110,8 @@  static void qmp_output_add_obj(QmpOutputVisitor *qov, const char *name,
     }
 }

-static void qmp_output_start_struct(Visitor *v, void **obj, const char *kind,
-                                    const char *name, size_t unused,
+static void qmp_output_start_struct(Visitor *v, const char *name, void **obj,
+                                    const char *kind, size_t unused,
                                     Error **errp)
 {
     QmpOutputVisitor *qov = to_qov(v);
@@ -158,14 +158,14 @@  static void qmp_output_end_list(Visitor *v, Error **errp)
     qmp_output_pop(qov);
 }

-static void qmp_output_type_int64(Visitor *v, int64_t *obj, const char *name,
+static void qmp_output_type_int64(Visitor *v, const char *name, int64_t *obj,
                                   Error **errp)
 {
     QmpOutputVisitor *qov = to_qov(v);
     qmp_output_add(qov, name, qint_from_int(*obj));
 }

-static void qmp_output_type_uint64(Visitor *v, uint64_t *obj, const char *name,
+static void qmp_output_type_uint64(Visitor *v, const char *name, uint64_t *obj,
                                    Error **errp)
 {
     /* FIXME: QMP outputs values larger than INT64_MAX as negative */
@@ -173,14 +173,14 @@  static void qmp_output_type_uint64(Visitor *v, uint64_t *obj, const char *name,
     qmp_output_add(qov, name, qint_from_int(*obj));
 }

-static void qmp_output_type_bool(Visitor *v, bool *obj, const char *name,
+static void qmp_output_type_bool(Visitor *v, const char *name, bool *obj,
                                  Error **errp)
 {
     QmpOutputVisitor *qov = to_qov(v);
     qmp_output_add(qov, name, qbool_from_bool(*obj));
 }

-static void qmp_output_type_str(Visitor *v, char **obj, const char *name,
+static void qmp_output_type_str(Visitor *v, const char *name, char **obj,
                                 Error **errp)
 {
     QmpOutputVisitor *qov = to_qov(v);
@@ -191,14 +191,14 @@  static void qmp_output_type_str(Visitor *v, char **obj, const char *name,
     }
 }

-static void qmp_output_type_number(Visitor *v, double *obj, const char *name,
+static void qmp_output_type_number(Visitor *v, const char *name, double *obj,
                                    Error **errp)
 {
     QmpOutputVisitor *qov = to_qov(v);
     qmp_output_add(qov, name, qfloat_from_double(*obj));
 }

-static void qmp_output_type_any(Visitor *v, QObject **obj, const char *name,
+static void qmp_output_type_any(Visitor *v, const char *name, QObject **obj,
                                 Error **errp)
 {
     QmpOutputVisitor *qov = to_qov(v);
diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
index d7546b5..5347b61 100644
--- a/qapi/string-input-visitor.c
+++ b/qapi/string-input-visitor.c
@@ -184,7 +184,7 @@  end_list(Visitor *v, Error **errp)
     siv->head = true;
 }

-static void parse_type_int64(Visitor *v, int64_t *obj, const char *name,
+static void parse_type_int64(Visitor *v, const char *name, int64_t *obj,
                              Error **errp)
 {
     StringInputVisitor *siv = to_siv(v);
@@ -226,13 +226,13 @@  error:
                "an int64 value or range");
 }

-static void parse_type_uint64(Visitor *v, uint64_t *obj, const char *name,
+static void parse_type_uint64(Visitor *v, const char *name, uint64_t *obj,
                               Error **errp)
 {
     /* FIXME: parse_type_int64 mishandles values over INT64_MAX */
     int64_t i;
     Error *err = NULL;
-    parse_type_int64(v, &i, name, &err);
+    parse_type_int64(v, name, &i, &err);
     if (err) {
         error_propagate(errp, err);
     } else {
@@ -240,7 +240,7 @@  static void parse_type_uint64(Visitor *v, uint64_t *obj, const char *name,
     }
 }

-static void parse_type_size(Visitor *v, uint64_t *obj, const char *name,
+static void parse_type_size(Visitor *v, const char *name, uint64_t *obj,
                             Error **errp)
 {
     StringInputVisitor *siv = to_siv(v);
@@ -262,7 +262,7 @@  static void parse_type_size(Visitor *v, uint64_t *obj, const char *name,
     *obj = val;
 }

-static void parse_type_bool(Visitor *v, bool *obj, const char *name,
+static void parse_type_bool(Visitor *v, const char *name, bool *obj,
                             Error **errp)
 {
     StringInputVisitor *siv = to_siv(v);
@@ -286,7 +286,7 @@  static void parse_type_bool(Visitor *v, bool *obj, const char *name,
                "boolean");
 }

-static void parse_type_str(Visitor *v, char **obj, const char *name,
+static void parse_type_str(Visitor *v, const char *name, char **obj,
                            Error **errp)
 {
     StringInputVisitor *siv = to_siv(v);
@@ -298,7 +298,7 @@  static void parse_type_str(Visitor *v, char **obj, const char *name,
     }
 }

-static void parse_type_number(Visitor *v, double *obj, const char *name,
+static void parse_type_number(Visitor *v, const char *name, double *obj,
                               Error **errp)
 {
     StringInputVisitor *siv = to_siv(v);
@@ -318,7 +318,7 @@  static void parse_type_number(Visitor *v, double *obj, const char *name,
     *obj = val;
 }

-static void parse_optional(Visitor *v, bool *present, const char *name)
+static void parse_optional(Visitor *v, const char *name, bool *present)
 {
     StringInputVisitor *siv = to_siv(v);

diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 3ed2b2c..74de6b6 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -121,7 +121,7 @@  static void format_string(StringOutputVisitor *sov, Range *r, bool next,
     }
 }

-static void print_type_int64(Visitor *v, int64_t *obj, const char *name,
+static void print_type_int64(Visitor *v, const char *name, int64_t *obj,
                              Error **errp)
 {
     StringOutputVisitor *sov = to_sov(v);
@@ -197,16 +197,16 @@  static void print_type_int64(Visitor *v, int64_t *obj, const char *name,
     }
 }

-static void print_type_uint64(Visitor *v, uint64_t *obj, const char *name,
+static void print_type_uint64(Visitor *v, const char *name, uint64_t *obj,
                              Error **errp)
 {
     /* FIXME: print_type_int64 mishandles values over INT64_MAX */
     int64_t i = *obj;
-    print_type_int64(v, &i, name, errp);
+    print_type_int64(v, name, &i, errp);
 }

-static void print_type_size(Visitor *v, uint64_t *obj, const char *name,
-                           Error **errp)
+static void print_type_size(Visitor *v, const char *name, uint64_t *obj,
+                            Error **errp)
 {
     StringOutputVisitor *sov = to_sov(v);
     static const char suffixes[] = { 'B', 'K', 'M', 'G', 'T', 'P', 'E' };
@@ -236,14 +236,14 @@  static void print_type_size(Visitor *v, uint64_t *obj, const char *name,
     string_output_set(sov, out);
 }

-static void print_type_bool(Visitor *v, bool *obj, const char *name,
+static void print_type_bool(Visitor *v, const char *name, bool *obj,
                             Error **errp)
 {
     StringOutputVisitor *sov = to_sov(v);
     string_output_set(sov, g_strdup(*obj ? "true" : "false"));
 }

-static void print_type_str(Visitor *v, char **obj, const char *name,
+static void print_type_str(Visitor *v, const char *name, char **obj,
                            Error **errp)
 {
     StringOutputVisitor *sov = to_sov(v);
@@ -257,7 +257,7 @@  static void print_type_str(Visitor *v, char **obj, const char *name,
     string_output_set(sov, out);
 }

-static void print_type_number(Visitor *v, double *obj, const char *name,
+static void print_type_number(Visitor *v, const char *name, double *obj,
                               Error **errp)
 {
     StringOutputVisitor *sov = to_sov(v);