提交 8af734ca 编写于 作者: A Alexey Kardashevskiy 提交者: Andreas Färber

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: NAlexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: NHu Tao <hutao@cn.fujitsu.com>
Signed-off-by: NAndreas Färber <afaerber@suse.de>
上级 01eb3139
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册