qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 8/9] QemuOpts: Convert qemu_opt_foreach() to Error
Date: Thu, 28 May 2015 13:07:46 -0600	[thread overview]
Message-ID: <55676782.70300@redhat.com> (raw)
In-Reply-To: <1432815695-31687-9-git-send-email-armbru@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2685 bytes --]

On 05/28/2015 06:21 AM, Markus Armbruster wrote:
> Retain the function value for now, to permit selective conversion of
> its callers.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  include/qemu/option.h | 7 +++++--
>  net/vhost-user.c      | 8 +++++---
>  qdev-monitor.c        | 5 +++--
>  ui/spice-core.c       | 5 +++--
>  util/qemu-config.c    | 5 +++--
>  util/qemu-option.c    | 8 +++++---
>  vl.c                  | 9 +++++----
>  7 files changed, 29 insertions(+), 18 deletions(-)
> 
> diff --git a/include/qemu/option.h b/include/qemu/option.h
> index a3cf4c1..ac0e43b 100644
> --- a/include/qemu/option.h
> +++ b/include/qemu/option.h
> @@ -100,8 +100,11 @@ void qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val,
>                         Error **errp);
>  void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
>                           Error **errp);
> -typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void *opaque);
> -int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque);
> +typedef int (*qemu_opt_loopfunc)(void *opaque,
> +                                 const char *name, const char *value,
> +                                 Error **errp);

Again, justification for reordering callback parameter ordering might be
nice to mention in the commit message, but the code itself is correct, so:

Reviewed-by: Eric Blake <eblake@redhat.com>


> +++ b/util/qemu-option.c
> @@ -597,17 +597,19 @@ void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
>  }
>  
>  /**
> - * For each member of @opts, call @func(name, value, @opaque).
> + * For each member of @opts, call @func(@opaque, name, value, @errp).
> + * @func() may store an Error through @errp, but must return non-zero then.
>   * When @func() returns non-zero, break the loop and return that value.
>   * Return zero when the loop completes.
>   */
> -int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque)
> +int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
> +                     Error **errp)
>  {
>      QemuOpt *opt;
>      int rc;
>  
>      QTAILQ_FOREACH(opt, &opts->head, next) {
> -        rc = func(opt->name, opt->str, opaque);
> +        rc = func(opaque, opt->name, opt->str, errp);
>          if (rc) {
>              return rc;
>          }

As in my earlier review, wouldn't it be better to add:

assert(!*errp)

at this point, to ensure we meet the contract?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2015-05-28 19:07 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-28 12:21 [Qemu-devel] [PATCH 0/9] Miscellaneous error reporting improvements Markus Armbruster
2015-05-28 12:21 ` [Qemu-devel] [PATCH 1/9] vl: Report failure to sandbox at most once Markus Armbruster
2015-05-28 14:24   ` Eric Blake
2015-05-28 12:21 ` [Qemu-devel] [PATCH 2/9] vl: Print -device help " Markus Armbruster
2015-05-28 14:47   ` Eric Blake
2015-05-28 12:21 ` [Qemu-devel] [PATCH 3/9] vl: Fail right after first bad -object Markus Armbruster
2015-05-28 14:52   ` Eric Blake
2015-06-02  8:41     ` Markus Armbruster
2015-05-28 12:21 ` [Qemu-devel] [PATCH 4/9] QemuOpts: Drop qemu_opts_foreach() parameter abort_on_failure Markus Armbruster
2015-05-28 15:10   ` Eric Blake
2015-06-02  8:42     ` Markus Armbruster
2015-05-28 12:21 ` [Qemu-devel] [PATCH 5/9] QemuOpts: Convert qemu_opts_foreach() to Error Markus Armbruster
2015-05-28 16:18   ` Eric Blake
2015-06-02 11:33     ` Markus Armbruster
2015-06-02 12:34       ` Eric Blake
2015-06-02 14:13         ` Paolo Bonzini
2015-05-28 12:21 ` [Qemu-devel] [PATCH 6/9] blkdebug: Simplify passing of Error through qemu_opts_foreach() Markus Armbruster
2015-05-28 17:15   ` Eric Blake
2015-05-28 12:21 ` [Qemu-devel] [PATCH 7/9] QemuOpts: Drop qemu_opt_foreach() parameter abort_on_failure Markus Armbruster
2015-05-28 18:57   ` Eric Blake
2015-05-28 12:21 ` [Qemu-devel] [PATCH 8/9] QemuOpts: Convert qemu_opt_foreach() to Error Markus Armbruster
2015-05-28 19:07   ` Eric Blake [this message]
2015-05-28 12:21 ` [Qemu-devel] [PATCH 9/9] vhost-user: Improve -netdev/netdev_add/-net/... error reporting Markus Armbruster
2015-05-28 19:20   ` Eric Blake
2015-06-02 16:32   ` Stefan Hajnoczi
2015-05-29  8:51 ` [Qemu-devel] [PATCH 0/9] Miscellaneous error reporting improvements Kevin Wolf
2015-05-29 11:22   ` Markus Armbruster
2015-05-29 12:42     ` Kevin Wolf
2015-05-29 14:00     ` Eric Blake
2015-06-02 11:51       ` Markus Armbruster
2015-06-02 12:51         ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55676782.70300@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).