aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-07-07 18:05:54 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-07-10 15:18:08 +0200
commit5325cc34a2ca985283134c7e264be7851b112d4e (patch)
treeba4fb68122e2dcf8860552167c56f97dc962cb00 /qom
parent1c94a351644fb2555f34e63c8ddc29f70bd4803a (diff)
qom: Put name parameter before value / visitor parameter
The object_property_set_FOO() setters take property name and value in an unusual order: void object_property_set_FOO(Object *obj, FOO_TYPE value, const char *name, Error **errp) Having to pass value before name feels grating. Swap them. Same for object_property_set(), object_property_get(), and object_property_parse(). Convert callers with this Coccinelle script: @@ identifier fun = { object_property_get, object_property_parse, object_property_set_str, object_property_set_link, object_property_set_bool, object_property_set_int, object_property_set_uint, object_property_set, object_property_set_qobject }; expression obj, v, name, errp; @@ - fun(obj, v, name, errp) + fun(obj, name, v, errp) Chokes on hw/arm/musicpal.c's lcd_refresh() with the unhelpful error message "no position information". Convert that one manually. Fails to convert hw/arm/armsse.c, because Coccinelle gets confused by ARMSSE being used both as typedef and function-like macro there. Convert manually. Fails to convert hw/rx/rx-gdbsim.c, because Coccinelle gets confused by RXCPU being used both as typedef and function-like macro there. Convert manually. The other files using RXCPU that way don't need conversion. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200707160613.848843-27-armbru@redhat.com> [Straightforwad conflict with commit 2336172d9b "audio: set default value for pcspk.iobase property" resolved]
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c52
-rw-r--r--qom/object_interfaces.c2
-rw-r--r--qom/qom-hmp-cmds.c2
-rw-r--r--qom/qom-qmp-cmds.c2
-rw-r--r--qom/qom-qobject.c9
5 files changed, 34 insertions, 33 deletions
diff --git a/qom/object.c b/qom/object.c
index be8fed6688..7d75c452b9 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -404,7 +404,7 @@ void object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp
continue;
}
p->used = true;
- object_property_parse(obj, p->value, p->property, &err);
+ object_property_parse(obj, p->property, p->value, &err);
if (err != NULL) {
error_prepend(&err, "can't apply global %s.%s=%s: ",
p->driver, p->property, p->value);
@@ -798,7 +798,7 @@ int object_set_propv(Object *obj,
const char *value = va_arg(vargs, char *);
g_assert(value != NULL);
- object_property_parse(obj, value, propname, &local_err);
+ object_property_parse(obj, propname, value, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return -1;
@@ -1312,7 +1312,7 @@ void object_property_del(Object *obj, const char *name)
g_hash_table_remove(obj->properties, name);
}
-void object_property_get(Object *obj, Visitor *v, const char *name,
+void object_property_get(Object *obj, const char *name, Visitor *v,
Error **errp)
{
ObjectProperty *prop = object_property_find(obj, name, errp);
@@ -1327,7 +1327,7 @@ void object_property_get(Object *obj, Visitor *v, const char *name,
}
}
-void object_property_set(Object *obj, Visitor *v, const char *name,
+void object_property_set(Object *obj, const char *name, Visitor *v,
Error **errp)
{
ObjectProperty *prop = object_property_find(obj, name, errp);
@@ -1342,11 +1342,11 @@ void object_property_set(Object *obj, Visitor *v, const char *name,
}
}
-void object_property_set_str(Object *obj, const char *value,
- const char *name, Error **errp)
+void object_property_set_str(Object *obj, const char *name,
+ const char *value, Error **errp)
{
QString *qstr = qstring_from_str(value);
- object_property_set_qobject(obj, QOBJECT(qstr), name, errp);
+ object_property_set_qobject(obj, name, QOBJECT(qstr), errp);
qobject_unref(qstr);
}
@@ -1370,15 +1370,15 @@ char *object_property_get_str(Object *obj, const char *name,
return retval;
}
-void object_property_set_link(Object *obj, Object *value,
- const char *name, Error **errp)
+void object_property_set_link(Object *obj, const char *name,
+ Object *value, Error **errp)
{
if (value) {
char *path = object_get_canonical_path(value);
- object_property_set_str(obj, path, name, errp);
+ object_property_set_str(obj, name, path, errp);
g_free(path);
} else {
- object_property_set_str(obj, "", name, errp);
+ object_property_set_str(obj, name, "", errp);
}
}
@@ -1400,11 +1400,11 @@ Object *object_property_get_link(Object *obj, const char *name,
return target;
}
-void object_property_set_bool(Object *obj, bool value,
- const char *name, Error **errp)
+void object_property_set_bool(Object *obj, const char *name,
+ bool value, Error **errp)
{
QBool *qbool = qbool_from_bool(value);
- object_property_set_qobject(obj, QOBJECT(qbool), name, errp);
+ object_property_set_qobject(obj, name, QOBJECT(qbool), errp);
qobject_unref(qbool);
}
@@ -1431,11 +1431,11 @@ bool object_property_get_bool(Object *obj, const char *name,
return retval;
}
-void object_property_set_int(Object *obj, int64_t value,
- const char *name, Error **errp)
+void object_property_set_int(Object *obj, const char *name,
+ int64_t value, Error **errp)
{
QNum *qnum = qnum_from_int(value);
- object_property_set_qobject(obj, QOBJECT(qnum), name, errp);
+ object_property_set_qobject(obj, name, QOBJECT(qnum), errp);
qobject_unref(qnum);
}
@@ -1500,12 +1500,12 @@ void object_property_set_default_uint(ObjectProperty *prop, uint64_t value)
object_property_set_default(prop, QOBJECT(qnum_from_uint(value)));
}
-void object_property_set_uint(Object *obj, uint64_t value,
- const char *name, Error **errp)
+void object_property_set_uint(Object *obj, const char *name,
+ uint64_t value, Error **errp)
{
QNum *qnum = qnum_from_uint(value);
- object_property_set_qobject(obj, QOBJECT(qnum), name, errp);
+ object_property_set_qobject(obj, name, QOBJECT(qnum), errp);
qobject_unref(qnum);
}
@@ -1567,11 +1567,11 @@ int object_property_get_enum(Object *obj, const char *name,
return ret;
}
-void object_property_parse(Object *obj, const char *string,
- const char *name, Error **errp)
+void object_property_parse(Object *obj, const char *name,
+ const char *string, Error **errp)
{
Visitor *v = string_input_visitor_new(string);
- object_property_set(obj, v, name, errp);
+ object_property_set(obj, name, v, errp);
visit_free(v);
}
@@ -1583,7 +1583,7 @@ char *object_property_print(Object *obj, const char *name, bool human,
Error *local_err = NULL;
v = string_output_visitor_new(human, &string);
- object_property_get(obj, v, name, &local_err);
+ object_property_get(obj, name, v, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto out;
@@ -2645,7 +2645,7 @@ static void property_get_alias(Object *obj, Visitor *v, const char *name,
{
AliasProperty *prop = opaque;
- object_property_get(prop->target_obj, v, prop->target_name, errp);
+ object_property_get(prop->target_obj, prop->target_name, v, errp);
}
static void property_set_alias(Object *obj, Visitor *v, const char *name,
@@ -2653,7 +2653,7 @@ static void property_set_alias(Object *obj, Visitor *v, const char *name,
{
AliasProperty *prop = opaque;
- object_property_set(prop->target_obj, v, prop->target_name, errp);
+ object_property_set(prop->target_obj, prop->target_name, v, errp);
}
static Object *property_resolve_alias(Object *obj, void *opaque,
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 3085ae0b31..4c59ee56d5 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -67,7 +67,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
goto out;
}
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
- object_property_set(obj, v, e->key, &local_err);
+ object_property_set(obj, e->key, v, &local_err);
if (local_err) {
break;
}
diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c
index b0abe84cb1..9ed8bb1c9f 100644
--- a/qom/qom-hmp-cmds.c
+++ b/qom/qom-hmp-cmds.c
@@ -57,7 +57,7 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict)
error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
"Device '%s' not found", path);
} else {
- object_property_parse(obj, value, property, &err);
+ object_property_parse(obj, property, value, &err);
}
} else {
QObject *obj = qobject_from_json(value, &err);
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 5e2c8cbf33..310ab2d048 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -71,7 +71,7 @@ void qmp_qom_set(const char *path, const char *property, QObject *value,
return;
}
- object_property_set_qobject(obj, value, property, errp);
+ object_property_set_qobject(obj, property, value, errp);
}
QObject *qmp_qom_get(const char *path, const char *property, Error **errp)
diff --git a/qom/qom-qobject.c b/qom/qom-qobject.c
index c3b95aa354..f949572d8a 100644
--- a/qom/qom-qobject.c
+++ b/qom/qom-qobject.c
@@ -17,13 +17,14 @@
#include "qapi/qobject-input-visitor.h"
#include "qapi/qobject-output-visitor.h"
-void object_property_set_qobject(Object *obj, QObject *value,
- const char *name, Error **errp)
+void object_property_set_qobject(Object *obj,
+ const char *name, QObject *value,
+ Error **errp)
{
Visitor *v;
v = qobject_input_visitor_new(value);
- object_property_set(obj, v, name, errp);
+ object_property_set(obj, name, v, errp);
visit_free(v);
}
@@ -35,7 +36,7 @@ QObject *object_property_get_qobject(Object *obj, const char *name,
Visitor *v;
v = qobject_output_visitor_new(&ret);
- object_property_get(obj, v, name, &local_err);
+ object_property_get(obj, name, v, &local_err);
if (!local_err) {
visit_complete(v, &ret);
}