Patchwork [1/7] qemu-option: Make qemu_opts_foreach() accumulate return values

login
register
mail settings
Submitter Markus Armbruster
Date Jan. 29, 2010, 6:48 p.m.
Message ID <1264790942-15045-2-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/44005/
State New
Headers show

Comments

Markus Armbruster - Jan. 29, 2010, 6:48 p.m.
Return the bitwise inclusive or of all return values instead of the
last call's value.  This lets you find out whether any of the calls
returned a non-zero value.

No functional change, as existing users either don't care for the
value, or pass non-zero abort_on_failure, which breaks the loop on the
first non-zero return value.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qemu-option.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Anthony Liguori - Feb. 3, 2010, 6:51 p.m.
On 01/29/2010 12:48 PM, Markus Armbruster wrote:
> Return the bitwise inclusive or of all return values instead of the
> last call's value.  This lets you find out whether any of the calls
> returned a non-zero value.
>
> No functional change, as existing users either don't care for the
> value, or pass non-zero abort_on_failure, which breaks the loop on the
> first non-zero return value.
>
> Signed-off-by: Markus Armbruster<armbru@redhat.com>
>    

Applied all.  Thanks.

It's great to see you working on this.  I'm really happy with how qdev 
has turned out but it desperately needs better online help.

Regards,

Anthony Liguori

> ---
>   qemu-option.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/qemu-option.c b/qemu-option.c
> index 24392fc..a52a4c4 100644
> --- a/qemu-option.c
> +++ b/qemu-option.c
> @@ -814,7 +814,7 @@ int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque,
>       int rc = 0;
>
>       QTAILQ_FOREACH(opts,&list->head, next) {
> -        rc = func(opts, opaque);
> +        rc |= func(opts, opaque);
>           if (abort_on_failure&&   rc != 0)
>               break;
>       }
>

Patch

diff --git a/qemu-option.c b/qemu-option.c
index 24392fc..a52a4c4 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -814,7 +814,7 @@  int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque,
     int rc = 0;
 
     QTAILQ_FOREACH(opts, &list->head, next) {
-        rc = func(opts, opaque);
+        rc |= func(opts, opaque);
         if (abort_on_failure  &&  rc != 0)
             break;
     }