qdev: Remove some non-run codes in qdev_walk_children().
PATCH 1/1 qdev: Remove some non-run codes in qdev_walk_children().
As you have known, qdev_reset_one() forever return a ZERO value to its caller, so some branches can not be forever covered in qdev_walk_children().
I thought that the return value for dev->info->reset(dev) can be returned, but dev->info->reset(dev) is referring to a function with void type.
--- hw/qdev.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
hw/qdev.c +1 -4
@@ -513,10 +513,7 @@ int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn,int err;if (devfn) { - err =devfn (dev, opaque); -if (err) { -return err; - } +devfn (dev, opaque); } QLIST_FOREACH(bus, &dev->child_bus, sibling) {
Signature · 1 line
1.7.2.3
Quoted 5 lines · Zhi Yong Wu
As you have known,
qdev_reset_one()forever return a ZERO value to its caller, so some branches can not be forever covered inqdev_walk_children().I thought that the return value for
dev->info->reset(dev)can be returned, butdev->info->reset(dev)is referring to a function with void type.Signed-off-by Zhi Yong Wu<[email protected]>
But the details of qdev_reset_one are irrelevant to qdev_walk_children(). There may be other functions that want to walk the tree and it's useful to be able to interrupt the tree transversal by returning a non-zero value.
Regards,
Anthony Liguori
Quoted 20 lines
--- hw/qdev.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)hw/qdev.c +1
-4@@ -513,10 +513,7 @@ int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn,int err;if (devfn) { - err =devfn (dev, opaque); -if (err) { -return err; - } +devfn (dev, opaque); } QLIST_FOREACH(bus,&dev->child_bus, sibling) {
Quoted 5 lines · Anthony Liguori
Quoted 4 lines · Zhi Yong Wu
As you have known,
qdev_reset_one()forever return a ZERO value to its caller, so some branches can not be forever covered inqdev_walk_children().
Quoted 8 lines
Quoted 4 lines
I thought that the return value for
dev->info->reset(dev)can be returned, butdev->info->reset(dev)is referring to a function with void type.Signed-off-by Zhi Yong Wu<[email protected]>But the details of
qdev_reset_oneare irrelevant toqdev_walk_children(). There may be other functions that want to walk the tree and it's useful to From The function reference flow, currently onlyqdev_reset_alland
qbus_walk_children invoke qdev_walk_children, and they both pass qdev_reset_one() as devfn to qdev_walk_children().
Quoted 1 line
be able to interrupt the tree transversal by returning a non-zero value.
Yeah, It is. Maybe later some new functions will need this. Anyway, thanks for your explain.
Quoted 28 lines
Regards,
Anthony Liguori
Quoted 21 lines
---
hw/qdev.c | 5 +----1 files changed, 1 insertions(+), 4 deletions(-)hw/qdev.c +1
-4@@ -513,10 +513,7 @@ int qdev_walk_children(DeviceState *dev,qdev_walkerfn *devfn, int err; if (devfn) { - err = devfn(dev, opaque); - if (err) { - return err; - } + devfn(dev, opaque); }QLIST_FOREACH(bus,&dev->child_bus, sibling) {
Signature · 3 lines
Regards, Zhi Yong Wu