[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/22] qom: Introduce object_property_is_{child, lin
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH 02/22] qom: Introduce object_property_is_{child, link}() |
Date: |
Mon, 18 Jun 2012 15:58:54 +0200 |
Avoids hardcoding partial string comparisons.
Signed-off-by: Alexander Barabash <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
---
qom/object.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index 9582230..105c649 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -296,6 +296,16 @@ void object_initialize(void *data, const char *typename)
object_initialize_with_type(data, type);
}
+static inline bool object_property_is_child(ObjectProperty *prop)
+{
+ return strstart(prop->type, "child<", NULL);
+}
+
+static inline bool object_property_is_link(ObjectProperty *prop)
+{
+ return strstart(prop->type, "link<", NULL);
+}
+
static void object_property_del_all(Object *obj)
{
while (!QTAILQ_EMPTY(&obj->properties)) {
@@ -318,7 +328,7 @@ static void object_property_del_child(Object *obj, Object
*child, Error **errp)
ObjectProperty *prop;
QTAILQ_FOREACH(prop, &obj->properties, node) {
- if (strstart(prop->type, "child<", NULL) && prop->opaque == child) {
+ if (object_property_is_child(prop) && prop->opaque == child) {
object_property_del(obj, prop->name, errp);
break;
}
@@ -1008,7 +1018,7 @@ gchar *object_get_canonical_path(Object *obj)
g_assert(obj->parent != NULL);
QTAILQ_FOREACH(prop, &obj->parent->properties, node) {
- if (!strstart(prop->type, "child<", NULL)) {
+ if (!object_property_is_child(prop)) {
continue;
}
@@ -1042,9 +1052,9 @@ Object *object_resolve_path_component(Object *parent,
gchar *part)
return NULL;
}
- if (strstart(prop->type, "link<", NULL)) {
+ if (object_property_is_link(prop)) {
return *(Object **)prop->opaque;
- } else if (strstart(prop->type, "child<", NULL)) {
+ } else if (object_property_is_child(prop)) {
return prop->opaque;
} else {
return NULL;
@@ -1087,7 +1097,7 @@ static Object *object_resolve_partial_path(Object *parent,
QTAILQ_FOREACH(prop, &parent->properties, node) {
Object *found;
- if (!strstart(prop->type, "child<", NULL)) {
+ if (!object_property_is_child(prop)) {
continue;
}
--
1.7.7
- [Qemu-devel] [PATCH 03/22] qom: Add object_child_foreach(), (continued)
- [Qemu-devel] [PATCH 03/22] qom: Add object_child_foreach(), Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 16/22] qdev: Move SysBus initialization to sysbus.c, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 20/22] qbus: Initialize in standard way, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 07/22] qom: Assert that public types have a non-NULL parent field, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 18/22] qdev: Connect busses with their parent devices, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 04/22] qom: Add class_base_init, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 08/22] m48t59: Rename "type" property to "model", Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 22/22] qom: Push error reporting to object_property_find(), Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 10/22] qdev: Push "type" property up to Object, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 06/22] qom: Drop type_register_static_alias() macro, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 02/22] qom: Introduce object_property_is_{child, link}(),
Andreas Färber <=
- [Qemu-devel] [PATCH 11/22] qdev: Move bus properties to a separate global, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 12/22] qdev: Move bus properties to abstract superclasses, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 19/22] qbus: Make child devices links, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 13/22] qdev: Clean up global properties, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 14/22] qdev: Remove qdev_prop_set_defaults, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 21/22] qdev: Remove qdev_prop_exists(), Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 17/22] qdev: Convert busses to QEMU Object Model, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 15/22] qdev: Use wrapper for qdev_get_path, Andreas Färber, 2012/06/18
- Re: [Qemu-devel] [PULL] qom-next queue, second batch: QBus, API additions and cleanups, Anthony Liguori, 2012/06/20