aboutsummaryrefslogtreecommitdiff
path: root/qom/object.c
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/object.c
parent1c94a351644fb2555f34e63c8ddc29f70bd4803a (diff)
downloadqemu-5325cc34a2ca985283134c7e264be7851b112d4e.zip
qemu-5325cc34a2ca985283134c7e264be7851b112d4e.tar.gz
qemu-5325cc34a2ca985283134c7e264be7851b112d4e.tar.bz2
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/object.c')
-rw-r--r--qom/object.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/qom/object.c b/qom/object.c
index be8fed6..7d75c45 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,