From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yy0Vh-0005y1-Gd for qemu-devel@nongnu.org; Thu, 28 May 2015 12:18:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yy0Ve-0005xS-Aj for qemu-devel@nongnu.org; Thu, 28 May 2015 12:18:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yy0Ve-0005x6-3y for qemu-devel@nongnu.org; Thu, 28 May 2015 12:18:18 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 95A7719CBCD for ; Thu, 28 May 2015 16:18:17 +0000 (UTC) Message-ID: <55673FC2.8040804@redhat.com> Date: Thu, 28 May 2015 10:18:10 -0600 From: Eric Blake MIME-Version: 1.0 References: <1432815695-31687-1-git-send-email-armbru@redhat.com> <1432815695-31687-6-git-send-email-armbru@redhat.com> In-Reply-To: <1432815695-31687-6-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="IVfl16PXWkHWcIJl8OHUiGPMsqdEls0KQ" Subject: Re: [Qemu-devel] [PATCH 5/9] QemuOpts: Convert qemu_opts_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) --IVfl16PXWkHWcIJl8OHUiGPMsqdEls0KQ 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 > --- > block/blkdebug.c | 6 ++-- > hw/core/qdev-properties-system.c | 5 +-- > include/qemu/option.h | 4 +-- > include/ui/console.h | 2 +- > net/net.c | 9 ++--- > net/vhost-user.c | 4 +-- > numa.c | 5 +-- > tpm.c | 6 ++-- > ui/vnc.c | 2 +- > util/qemu-config.c | 4 +-- > util/qemu-option.c | 7 ++-- > vl.c | 72 ++++++++++++++++++++++++--------= -------- > 12 files changed, 72 insertions(+), 54 deletions(-) >=20 > diff --git a/block/blkdebug.c b/block/blkdebug.c > index 58f5105..50ef1fc 100644 > --- a/block/blkdebug.c > +++ b/block/blkdebug.c > @@ -219,7 +219,7 @@ struct add_rule_data { > Error **errp; > }; > =20 > -static int add_rule(QemuOpts *opts, void *opaque) > +static int add_rule(void *opaque, QemuOpts *opts, Error **errp) > +++ b/include/qemu/option.h > @@ -125,9 +125,9 @@ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, = const QDict *qdict, > QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict); > void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp= ); > =20 > -typedef int (*qemu_opts_loopfunc)(QemuOpts *opts, void *opaque); > +typedef int (*qemu_opts_loopfunc)(void *opaque, QemuOpts *opts, Error = **errp); Might be nice to justify in the commit message why swapping the arguments of the callback made sense. But doesn't affect code correctness, so: Reviewed-by: Eric Blake > +++ b/util/qemu-option.c > @@ -1047,13 +1047,14 @@ void qemu_opts_validate(QemuOpts *opts, const Q= emuOptDesc *desc, Error **errp) > } > =20 > /** > - * For each member of @list, call @func(member, @opaque). > + * For each member of @list, call @func(@opaque, member, @errp). > * Call it with the current location temporarily set to the member's. > + * @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_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, > - void *opaque) > + void *opaque, Error **errp) > { > Location loc; > QemuOpts *opts; > @@ -1062,7 +1063,7 @@ int qemu_opts_foreach(QemuOptsList *list, qemu_op= ts_loopfunc func, > loc_push_none(&loc); > QTAILQ_FOREACH(opts, &list->head, next) { > loc_restore(&opts->loc); > - rc =3D func(opts, opaque); > + rc =3D func(opaque, opts, errp); > if (rc) { > return rc; > } Do you want to enforce that if errp is set, that rc is non-zero, to match your contract? Perhaps by assert(!*errp) at this point? But if the return value goes away later in the series in favor of only using errp, it may be a moot question. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --IVfl16PXWkHWcIJl8OHUiGPMsqdEls0KQ 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/ iQEcBAEBCAAGBQJVZz/CAAoJEKeha0olJ0NqRigH/3b0AJ8pjXxLJaPvGXnMbZDZ V7xDi2GIGdajnLhsQ1bHC8+za0813KqTnGjnvBflWPgD94aqLpRAMndcTKFW+LgS 1cw6vPQSuMT9AL8YIEnEtyBBuzebVcIS6dp+zBxeBlqxqGwjQi3o9NIVs1ufyDi4 jQBgV7W343d5tKcUFi2m2W+dYjrZ/l9iUlaurtql4Tx+rKaXMaHd7bRHhqPHWerx qbkOtqTrvq7J878fPA0oKP3CCP7ie1hQtoHIHc76H8zCZh8tQMXy3/r6shp5dN2c y2ot2sgeYlulC1f8TNlU6n4QtHfazP+GOKIaWCjdE2NBv/vCAUFTPyQX4v8P7lk= =K3OR -----END PGP SIGNATURE----- --IVfl16PXWkHWcIJl8OHUiGPMsqdEls0KQ--