From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yy39j-0001CQ-BA for qemu-devel@nongnu.org; Thu, 28 May 2015 15:07:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yy39g-0004Sl-4a for qemu-devel@nongnu.org; Thu, 28 May 2015 15:07:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yy39f-0004Sh-TW for qemu-devel@nongnu.org; Thu, 28 May 2015 15:07:48 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id A53FA3674B2 for ; Thu, 28 May 2015 19:07:47 +0000 (UTC) Message-ID: <55676782.70300@redhat.com> Date: Thu, 28 May 2015 13:07:46 -0600 From: Eric Blake MIME-Version: 1.0 References: <1432815695-31687-1-git-send-email-armbru@redhat.com> <1432815695-31687-9-git-send-email-armbru@redhat.com> In-Reply-To: <1432815695-31687-9-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4K5tJ3FTojwGJeHcdvDNGTPiOFBewCMLH" Subject: Re: [Qemu-devel] [PATCH 8/9] QemuOpts: Convert qemu_opt_foreach() to Error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --4K5tJ3FTojwGJeHcdvDNGTPiOFBewCMLH Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/28/2015 06:21 AM, Markus Armbruster wrote: > Retain the function value for now, to permit selective conversion of > its callers. >=20 > Signed-off-by: Markus Armbruster > --- > 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(-) >=20 > 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 *opa= que); > +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 > +++ b/util/qemu-option.c > @@ -597,17 +597,19 @@ void qemu_opt_set_number(QemuOpts *opts, const ch= ar *name, int64_t val, > } > =20 > /** > - * 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= =2E > * Return zero when the loop completes. > */ > -int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opa= que) > +int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opa= que, > + Error **errp) > { > QemuOpt *opt; > int rc; > =20 > QTAILQ_FOREACH(opt, &opts->head, next) { > - rc =3D func(opt->name, opt->str, opaque); > + rc =3D 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? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --4K5tJ3FTojwGJeHcdvDNGTPiOFBewCMLH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVZ2eCAAoJEKeha0olJ0Nq4/YH/3fLVJPCneu554QygB3BsnZV SDM/wQ7lxb31qi0eGQcfYJMUVhYqPuTI5VzBiZIoQZgsw514NNclQeNSnx7Dgk8L jF/Ql8+RzJI1S43cpbHkTQ4ZSb5Q7jhHa2xy948dHnLUcnD8nP69gBHE2pZxSMQy 2Z1lNntXiomAZ07zBikqXnSbqCMBtyglmGCkmhXcQ9dg/cfPukhILR53+lIw2A/a 5zqvL3B+8lD6/w8VRUyAUAaCy9Is5HszeFFx5jdS1w79lCye29vIK8W88hhcfOL6 R96JpICuyskaJOr4pJteRrPJbbuHPpmop4cg68WclW9jnI2842Rf4rQYIdox1tQ= =Hj5m -----END PGP SIGNATURE----- --4K5tJ3FTojwGJeHcdvDNGTPiOFBewCMLH--