aboutsummaryrefslogtreecommitdiff
path: root/hw/core
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2016-01-29 06:48:54 -0700
committerMarkus Armbruster <armbru@redhat.com>2016-02-08 17:29:56 +0100
commit51e72bc1dd6ace6e91d675f41a1f09bd00ab8043 (patch)
treece8eccf21a3dfa59301dcea8cc9bd96fcf01854c /hw/core
parent4fa45492c3387c0fa51e8e81160ac9a7814f44a2 (diff)
qapi: Swap visit_* arguments for consistent 'name' placement
JSON uses "name":value, but many of our visitor interfaces were called with visit_type_FOO(v, &value, name, errp). This can be a bit confusing to have to mentally swap the parameter order to match JSON order. It's particularly bad for visit_start_struct(), where the 'name' parameter is smack in the middle of the otherwise-related group of 'obj, kind, size' parameters! It's time to do a global swap of the parameter ordering, so that the 'name' parameter is always immediately after the Visitor argument. Additional reason in favor of the swap: the existing include/qjson.h prefers listing 'name' first in json_prop_*(), and I have plans to unify that file with the qapi visitors; listing 'name' first in qapi will minimize churn to the (admittedly few) qjson.h clients. Later patches will then fix docs, object.h, visitor-impl.h, and those clients to match. Done by first patching scripts/qapi*.py by hand to make generated files do what I want, then by running the following Coccinelle script to affect the rest of the code base: $ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'` I then had to apply some touchups (Coccinelle insisted on TAB indentation in visitor.h, and botched the signature of visit_type_enum() by rewriting 'const char *const strings[]' to the syntactically invalid 'const char*const[] strings'). The movement of parameters is sufficient to provoke compiler errors if any callers were missed. // Part 1: Swap declaration order @@ type TV, TErr, TObj, T1, T2; identifier OBJ, ARG1, ARG2; @@ void visit_start_struct -(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp) +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp) { ... } @@ type bool, TV, T1; identifier ARG1; @@ bool visit_optional -(TV v, T1 ARG1, const char *name) +(TV v, const char *name, T1 ARG1) { ... } @@ type TV, TErr, TObj, T1; identifier OBJ, ARG1; @@ void visit_get_next_type -(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp) +(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp) { ... } @@ type TV, TErr, TObj, T1, T2; identifier OBJ, ARG1, ARG2; @@ void visit_type_enum -(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp) +(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp) { ... } @@ type TV, TErr, TObj; identifier OBJ; identifier VISIT_TYPE =~ "^visit_type_"; @@ void VISIT_TYPE -(TV v, TObj OBJ, const char *name, TErr errp) +(TV v, const char *name, TObj OBJ, TErr errp) { ... } // Part 2: swap caller order @@ expression V, NAME, OBJ, ARG1, ARG2, ERR; identifier VISIT_TYPE =~ "^visit_type_"; @@ ( -visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR) +visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR) | -visit_optional(V, ARG1, NAME) +visit_optional(V, NAME, ARG1) | -visit_get_next_type(V, OBJ, ARG1, NAME, ERR) +visit_get_next_type(V, NAME, OBJ, ARG1, ERR) | -visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR) +visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR) | -VISIT_TYPE(V, OBJ, NAME, ERR) +VISIT_TYPE(V, NAME, OBJ, ERR) ) Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'hw/core')
-rw-r--r--hw/core/machine.c10
-rw-r--r--hw/core/qdev-properties-system.c12
-rw-r--r--hw/core/qdev-properties.c66
-rw-r--r--hw/core/qdev.c2
4 files changed, 45 insertions, 45 deletions
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 1261368add..03d9a951b2 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -41,7 +41,7 @@ static void machine_set_kernel_irqchip(Object *obj, Visitor *v,
MachineState *ms = MACHINE(obj);
OnOffSplit mode;
- visit_type_OnOffSplit(v, &mode, name, &err);
+ visit_type_OnOffSplit(v, name, &mode, &err);
if (err) {
error_propagate(errp, err);
return;
@@ -75,7 +75,7 @@ static void machine_get_kvm_shadow_mem(Object *obj, Visitor *v,
MachineState *ms = MACHINE(obj);
int64_t value = ms->kvm_shadow_mem;
- visit_type_int(v, &value, name, errp);
+ visit_type_int(v, name, &value, errp);
}
static void machine_set_kvm_shadow_mem(Object *obj, Visitor *v,
@@ -86,7 +86,7 @@ static void machine_set_kvm_shadow_mem(Object *obj, Visitor *v,
Error *error = NULL;
int64_t value;
- visit_type_int(v, &value, name, &error);
+ visit_type_int(v, name, &value, &error);
if (error) {
error_propagate(errp, error);
return;
@@ -177,7 +177,7 @@ static void machine_get_phandle_start(Object *obj, Visitor *v,
MachineState *ms = MACHINE(obj);
int64_t value = ms->phandle_start;
- visit_type_int(v, &value, name, errp);
+ visit_type_int(v, name, &value, errp);
}
static void machine_set_phandle_start(Object *obj, Visitor *v,
@@ -188,7 +188,7 @@ static void machine_set_phandle_start(Object *obj, Visitor *v,
Error *error = NULL;
int64_t value;
- visit_type_int(v, &value, name, &error);
+ visit_type_int(v, name, &value, &error);
if (error) {
error_propagate(errp, error);
return;
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index ff00f5c9cb..acbe403c63 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -31,7 +31,7 @@ static void get_pointer(Object *obj, Visitor *v, Property *prop,
char *p;
p = *ptr ? print(*ptr) : g_strdup("");
- visit_type_str(v, &p, name, errp);
+ visit_type_str(v, name, &p, errp);
g_free(p);
}
@@ -51,7 +51,7 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop,
return;
}
- visit_type_str(v, &str, name, &local_err);
+ visit_type_str(v, name, &str, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -202,7 +202,7 @@ static void get_netdev(Object *obj, Visitor *v, void *opaque,
NICPeers *peers_ptr = qdev_get_prop_ptr(dev, prop);
char *p = g_strdup(peers_ptr->ncs[0] ? peers_ptr->ncs[0]->name : "");
- visit_type_str(v, &p, name, errp);
+ visit_type_str(v, name, &p, errp);
g_free(p);
}
@@ -223,7 +223,7 @@ static void set_netdev(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_str(v, &str, name, &local_err);
+ visit_type_str(v, name, &str, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -308,7 +308,7 @@ static void get_vlan(Object *obj, Visitor *v, void *opaque,
}
}
- visit_type_int32(v, &id, name, errp);
+ visit_type_int32(v, name, &id, errp);
}
static void set_vlan(Object *obj, Visitor *v, void *opaque,
@@ -327,7 +327,7 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_int32(v, &id, name, &local_err);
+ visit_type_int32(v, name, &id, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index e878e80c67..77f354233f 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -49,8 +49,8 @@ static void get_enum(Object *obj, Visitor *v, void *opaque,
Property *prop = opaque;
int *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_enum(v, ptr, prop->info->enum_table,
- prop->info->name, prop->name, errp);
+ visit_type_enum(v, prop->name, ptr, prop->info->enum_table,
+ prop->info->name, errp);
}
static void set_enum(Object *obj, Visitor *v, void *opaque,
@@ -65,8 +65,8 @@ static void set_enum(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_enum(v, ptr, prop->info->enum_table,
- prop->info->name, prop->name, errp);
+ visit_type_enum(v, prop->name, ptr, prop->info->enum_table,
+ prop->info->name, errp);
}
/* Bit */
@@ -96,7 +96,7 @@ static void prop_get_bit(Object *obj, Visitor *v, void *opaque,
uint32_t *p = qdev_get_prop_ptr(dev, prop);
bool value = (*p & qdev_get_prop_mask(prop)) != 0;
- visit_type_bool(v, &value, name, errp);
+ visit_type_bool(v, name, &value, errp);
}
static void prop_set_bit(Object *obj, Visitor *v, void *opaque,
@@ -112,7 +112,7 @@ static void prop_set_bit(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_bool(v, &value, name, &local_err);
+ visit_type_bool(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -154,7 +154,7 @@ static void prop_get_bit64(Object *obj, Visitor *v, void *opaque,
uint64_t *p = qdev_get_prop_ptr(dev, prop);
bool value = (*p & qdev_get_prop_mask64(prop)) != 0;
- visit_type_bool(v, &value, name, errp);
+ visit_type_bool(v, name, &value, errp);
}
static void prop_set_bit64(Object *obj, Visitor *v, void *opaque,
@@ -170,7 +170,7 @@ static void prop_set_bit64(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_bool(v, &value, name, &local_err);
+ visit_type_bool(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -194,7 +194,7 @@ static void get_bool(Object *obj, Visitor *v, void *opaque,
Property *prop = opaque;
bool *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_bool(v, ptr, name, errp);
+ visit_type_bool(v, name, ptr, errp);
}
static void set_bool(Object *obj, Visitor *v, void *opaque,
@@ -209,7 +209,7 @@ static void set_bool(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_bool(v, ptr, name, errp);
+ visit_type_bool(v, name, ptr, errp);
}
PropertyInfo qdev_prop_bool = {
@@ -227,7 +227,7 @@ static void get_uint8(Object *obj, Visitor *v, void *opaque,
Property *prop = opaque;
uint8_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_uint8(v, ptr, name, errp);
+ visit_type_uint8(v, name, ptr, errp);
}
static void set_uint8(Object *obj, Visitor *v, void *opaque,
@@ -242,7 +242,7 @@ static void set_uint8(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_uint8(v, ptr, name, errp);
+ visit_type_uint8(v, name, ptr, errp);
}
PropertyInfo qdev_prop_uint8 = {
@@ -260,7 +260,7 @@ static void get_uint16(Object *obj, Visitor *v, void *opaque,
Property *prop = opaque;
uint16_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_uint16(v, ptr, name, errp);
+ visit_type_uint16(v, name, ptr, errp);
}
static void set_uint16(Object *obj, Visitor *v, void *opaque,
@@ -275,7 +275,7 @@ static void set_uint16(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_uint16(v, ptr, name, errp);
+ visit_type_uint16(v, name, ptr, errp);
}
PropertyInfo qdev_prop_uint16 = {
@@ -293,7 +293,7 @@ static void get_uint32(Object *obj, Visitor *v, void *opaque,
Property *prop = opaque;
uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_uint32(v, ptr, name, errp);
+ visit_type_uint32(v, name, ptr, errp);
}
static void set_uint32(Object *obj, Visitor *v, void *opaque,
@@ -308,7 +308,7 @@ static void set_uint32(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_uint32(v, ptr, name, errp);
+ visit_type_uint32(v, name, ptr, errp);
}
static void get_int32(Object *obj, Visitor *v, void *opaque,
@@ -318,7 +318,7 @@ static void get_int32(Object *obj, Visitor *v, void *opaque,
Property *prop = opaque;
int32_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_int32(v, ptr, name, errp);
+ visit_type_int32(v, name, ptr, errp);
}
static void set_int32(Object *obj, Visitor *v, void *opaque,
@@ -333,7 +333,7 @@ static void set_int32(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_int32(v, ptr, name, errp);
+ visit_type_int32(v, name, ptr, errp);
}
PropertyInfo qdev_prop_uint32 = {
@@ -357,7 +357,7 @@ static void get_uint64(Object *obj, Visitor *v, void *opaque,
Property *prop = opaque;
uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_uint64(v, ptr, name, errp);
+ visit_type_uint64(v, name, ptr, errp);
}
static void set_uint64(Object *obj, Visitor *v, void *opaque,
@@ -372,7 +372,7 @@ static void set_uint64(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_uint64(v, ptr, name, errp);
+ visit_type_uint64(v, name, ptr, errp);
}
PropertyInfo qdev_prop_uint64 = {
@@ -398,9 +398,9 @@ static void get_string(Object *obj, Visitor *v, void *opaque,
if (!*ptr) {
char *str = (char *)"";
- visit_type_str(v, &str, name, errp);
+ visit_type_str(v, name, &str, errp);
} else {
- visit_type_str(v, ptr, name, errp);
+ visit_type_str(v, name, ptr, errp);
}
}
@@ -418,7 +418,7 @@ static void set_string(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_str(v, &str, name, &local_err);
+ visit_type_str(v, name, &str, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -461,7 +461,7 @@ static void get_mac(Object *obj, Visitor *v, void *opaque,
mac->a[0], mac->a[1], mac->a[2],
mac->a[3], mac->a[4], mac->a[5]);
- visit_type_str(v, &p, name, errp);
+ visit_type_str(v, name, &p, errp);
}
static void set_mac(Object *obj, Visitor *v, void *opaque,
@@ -479,7 +479,7 @@ static void set_mac(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_str(v, &str, name, &local_err);
+ visit_type_str(v, name, &str, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -573,11 +573,11 @@ static void set_pci_devfn(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_str(v, &str, name, &local_err);
+ visit_type_str(v, name, &str, &local_err);
if (local_err) {
error_free(local_err);
local_err = NULL;
- visit_type_int32(v, &value, name, &local_err);
+ visit_type_int32(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
} else if (value < -1 || value > 255) {
@@ -644,7 +644,7 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_uint16(v, &value, name, &local_err);
+ visit_type_uint16(v, name, &value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -690,7 +690,7 @@ static void get_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
addr->domain, addr->bus, addr->slot, addr->function);
assert(rc == sizeof(buffer) - 1);
- visit_type_str(v, &p, name, errp);
+ visit_type_str(v, name, &p, errp);
}
/*
@@ -715,7 +715,7 @@ static void set_pci_host_devaddr(Object *obj, Visitor *v, void *opaque,
return;
}
- visit_type_str(v, &str, name, &local_err);
+ visit_type_str(v, name, &str, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -837,7 +837,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, void *opaque,
name);
return;
}
- visit_type_uint32(v, alenptr, name, &local_err);
+ visit_type_uint32(v, name, alenptr, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -1101,7 +1101,7 @@ static void get_size(Object *obj, Visitor *v, void *opaque,
Property *prop = opaque;
uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_size(v, ptr, name, errp);
+ visit_type_size(v, name, ptr, errp);
}
static void set_size(Object *obj, Visitor *v, void *opaque,
@@ -1111,7 +1111,7 @@ static void set_size(Object *obj, Visitor *v, void *opaque,
Property *prop = opaque;
uint64_t *ptr = qdev_get_prop_ptr(dev, prop);
- visit_type_size(v, ptr, name, errp);
+ visit_type_size(v, name, ptr, errp);
}
PropertyInfo qdev_prop_size = {
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 779de2ba93..c731bb2032 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -903,7 +903,7 @@ static void qdev_get_legacy_property(Object *obj, Visitor *v, void *opaque,
char *ptr = buffer;
prop->info->print(dev, prop, buffer, sizeof(buffer));
- visit_type_str(v, &ptr, name, errp);
+ visit_type_str(v, name, &ptr, errp);
}
/**