Message ID | 1408097555-28126-2-git-send-email-aik@ozlabs.ru |
---|---|
State | New |
Headers | show |
On Fri, Aug 15, 2014 at 08:12:23PM +1000, Alexey Kardashevskiy wrote: > Current object_child_foreach() uses QTAILQ_FOREACH() to walk > through children and that makes children removal from the callback > impossible. > > This makes object_child_foreach() use QTAILQ_FOREACH_SAFE(). > > Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Seems like a good idea to me. Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
diff --git a/qom/object.c b/qom/object.c index 0e8267b..4a814dc 100644 --- a/qom/object.c +++ b/qom/object.c @@ -678,10 +678,10 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque), void *opaque) { - ObjectProperty *prop; + ObjectProperty *prop, *next; int ret = 0; - QTAILQ_FOREACH(prop, &obj->properties, node) { + QTAILQ_FOREACH_SAFE(prop, &obj->properties, node, next) { if (object_property_is_child(prop)) { ret = fn(prop->opaque, opaque); if (ret != 0) {
Current object_child_foreach() uses QTAILQ_FOREACH() to walk through children and that makes children removal from the callback impossible. This makes object_child_foreach() use QTAILQ_FOREACH_SAFE(). Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- This went to Andreas's qom-next tree, it is here for the reference only. --- qom/object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)