qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qdev: Remove some non-run codes in qdev_walk_children().
@ 2011-08-08  4:15 Zhi Yong Wu
  2011-08-11 19:40 ` Anthony Liguori
  0 siblings, 1 reply; 3+ messages in thread
From: Zhi Yong Wu @ 2011-08-08  4:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: aliguori, stefanha, Zhi Yong Wu, armbru, zwu.kernel, ryanh,
	luowenj

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.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 hw/qdev.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index 292b52f..cbc5e02 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -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) {
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qdev: Remove some non-run codes in qdev_walk_children().
  2011-08-08  4:15 [Qemu-devel] [PATCH] qdev: Remove some non-run codes in qdev_walk_children() Zhi Yong Wu
@ 2011-08-11 19:40 ` Anthony Liguori
  2011-08-12  2:14   ` Zhi Yong Wu
  0 siblings, 1 reply; 3+ messages in thread
From: Anthony Liguori @ 2011-08-11 19:40 UTC (permalink / raw)
  To: Zhi Yong Wu; +Cc: stefanha, armbru, qemu-devel, zwu.kernel, ryanh, luowenj

On 08/07/2011 11:15 PM, Zhi Yong Wu wrote:
> 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.
>
> Signed-off-by: Zhi Yong Wu<wuzhy@linux.vnet.ibm.com>

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

> ---
>   hw/qdev.c |    5 +----
>   1 files changed, 1 insertions(+), 4 deletions(-)
>
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 292b52f..cbc5e02 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -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) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qdev: Remove some non-run codes in qdev_walk_children().
  2011-08-11 19:40 ` Anthony Liguori
@ 2011-08-12  2:14   ` Zhi Yong Wu
  0 siblings, 0 replies; 3+ messages in thread
From: Zhi Yong Wu @ 2011-08-12  2:14 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: stefanha, Zhi Yong Wu, armbru, qemu-devel, ryanh, luowenj

On Fri, Aug 12, 2011 at 3:40 AM, Anthony Liguori <aliguori@us.ibm.com> wrote:
> On 08/07/2011 11:15 PM, Zhi Yong Wu wrote:
>>
>> 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.
>>
>> Signed-off-by: Zhi Yong Wu<wuzhy@linux.vnet.ibm.com>
>
> 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
>From The function reference flow, currently only qdev_reset_all and
qbus_walk_children invoke qdev_walk_children, and they both pass
qdev_reset_one() as devfn to qdev_walk_children().
> 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.
>
> Regards,
>
> Anthony Liguori
>
>> ---
>>  hw/qdev.c |    5 +----
>>  1 files changed, 1 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/qdev.c b/hw/qdev.c
>> index 292b52f..cbc5e02 100644
>> --- a/hw/qdev.c
>> +++ b/hw/qdev.c
>> @@ -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) {
>
>

-- 
Regards,

Zhi Yong Wu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-12  2:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-08  4:15 [Qemu-devel] [PATCH] qdev: Remove some non-run codes in qdev_walk_children() Zhi Yong Wu
2011-08-11 19:40 ` Anthony Liguori
2011-08-12  2:14   ` Zhi Yong Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).