qom: Make object_child_foreach() safe for objects removal

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>
Reviewed-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
Alexey Kardashevskiy 2014-07-14 00:41:08 +10:00 committed by Andreas Färber
parent 01eb313907
commit 8af734ca31
1 changed files with 2 additions and 2 deletions

View File

@ -668,10 +668,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) {