From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvvaR-0004cM-Ly for qemu-devel@nongnu.org; Fri, 22 May 2015 18:38:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YvvaQ-0004sB-17 for qemu-devel@nongnu.org; Fri, 22 May 2015 18:38:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvvaP-0004s1-PC for qemu-devel@nongnu.org; Fri, 22 May 2015 18:38:37 -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 (8.14.4/8.14.4) with ESMTP id t4MMcb4T016587 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 22 May 2015 18:38:37 -0400 Message-ID: <555FAFEC.3080302@redhat.com> Date: Fri, 22 May 2015 16:38:36 -0600 From: Eric Blake MIME-Version: 1.0 References: <1432294585-5984-1-git-send-email-armbru@redhat.com> <1432294585-5984-14-git-send-email-armbru@redhat.com> In-Reply-To: <1432294585-5984-14-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VNcWIwBIW6QgxVITSacG4n72kJsChxlWe" Subject: Re: [Qemu-devel] [PATCH 13/20] monitor: Limit QError use to command handlers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --VNcWIwBIW6QgxVITSacG4n72kJsChxlWe Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/22/2015 05:36 AM, Markus Armbruster wrote: > The previous commits narrowed use of QError to handle_qmp_command() > and its helpers monitor_protocol_emitter(), build_qmp_error_dict(). > Narrow it further to just the command handler call: instead of > converting Error to QError throughout handle_qmp_command(), convert > the QError gotten from the command handler to Error, and switch the > helpers from QError to Error. >=20 > Signed-off-by: Markus Armbruster > --- > monitor.c | 26 ++++++++++++++------------ > 1 file changed, 14 insertions(+), 12 deletions(-) >=20 > diff --git a/monitor.c b/monitor.c > index 71ca03f..65ef400 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -391,19 +391,19 @@ static void monitor_json_emitter(Monitor *mon, co= nst QObject *data) > QDECREF(json); > } > =20 > -static QDict *build_qmp_error_dict(const QError *err) > +static QDict *build_qmp_error_dict(Error *err) > { > QObject *obj; > =20 > - obj =3D qobject_from_jsonf("{ 'error': { 'class': %s, 'desc': %p }= }", > - ErrorClass_lookup[err->err_class], > - qerror_human(err)); > + obj =3D qobject_from_jsonf("{ 'error': { 'class': %s, 'desc': %s }= }", > + ErrorClass_lookup[error_get_class(err)], > + error_get_pretty(err)); You're getting rid of one of three uses of '_jsonf.*%p' in the tree (two in monitor.c, one in tests/check-qjson.c) [I didn't check for multi-line instances where the format string was on a different line than the function call]. Is it worth completely getting rid of the %p formatter, and simplifying qobject/json-*.c accordingly, in a later patch? [oh, and I hate that I could not find documentation on the format strings accepted by qobject_from_jsonf; it took me forever to track down that %i correlated to bool, when I was doing my series for "qobject" Use 'bool' for qbool] > @@ -4984,13 +4984,12 @@ static void handle_qmp_command(JSONMessageParse= r *parser, QList *tokens) > obj =3D json_parser_parse(tokens, NULL); > if (!obj) { > // FIXME: should be triggered in json_parser_parse() > - qerror_report(QERR_JSON_PARSING); > + error_set(&local_err, QERR_JSON_PARSING); > goto err_out; Is this FIXME still valid, or are we reaching the point where it could be replaced by an assert(obj) in a later patch? Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --VNcWIwBIW6QgxVITSacG4n72kJsChxlWe 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/ iQEcBAEBCAAGBQJVX6/sAAoJEKeha0olJ0Nq09EH/ivYTJuQt7HtGYzxU76iAODj SN9+O2WYW4UWc6uflxsU2tnMYWsV5zFJOtkEZil4dk8nyPpWtHfxDMpXtmcV82CJ tve/nz16h9Nc27O3iqFQAp14ttrT9WVj4prV9Dm+9rYrq1aJ9Zwdd7Ze9k+/OIS6 wyzB6F7wtY5X3yZcEuSveCAc16kA1o5cKeIaAN0Ek48wZcr7BNY+oEn4bDP/zuZV aUE9V9f1MnPY1A4ziudVxD2o66sOkfJk+sYvIu4xWWv03bZ6jgvaMLSk0xAem505 vyLs9gUGy8wDh8SChKVnag0uLSnayNgDZhHYQpyKkOPsGr/9rNoTH0YQadrqGG8= =ukbZ -----END PGP SIGNATURE----- --VNcWIwBIW6QgxVITSacG4n72kJsChxlWe--