Skip to content

Commit

Permalink
qom: Make object_child_foreach() safe for objects removal
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Hu Tao <[email protected]>
Signed-off-by: Andreas Färber <[email protected]>
  • Loading branch information
aik authored and afaerber committed Sep 4, 2014
1 parent 01eb313 commit 8af734c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions qom/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8af734c

Please sign in to comment.