aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2014-07-14 00:41:08 +1000
committerAndreas Färber <afaerber@suse.de>2014-09-04 16:14:47 +0200
commit8af734ca318369c4eb76f355ed4cc7d4e6abc2a6 (patch)
tree98d98a591f95c2f05ef9fc2205b19dc92848053e /qom
parent01eb313907dda97313b8fea62e5632fca64f069c (diff)
downloadqemu-8af734ca318369c4eb76f355ed4cc7d4e6abc2a6.zip
qemu-8af734ca318369c4eb76f355ed4cc7d4e6abc2a6.tar.gz
qemu-8af734ca318369c4eb76f355ed4cc7d4e6abc2a6.tar.bz2
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>
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/qom/object.c b/qom/object.c
index 79bd0cc..a298b32 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -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) {