From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLvfE-00047u-NK for qemu-devel@nongnu.org; Thu, 12 Feb 2015 10:26:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLvfD-0006Ux-HU for qemu-devel@nongnu.org; Thu, 12 Feb 2015 10:26:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40915) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLvfD-0006Ug-B4 for qemu-devel@nongnu.org; Thu, 12 Feb 2015 10:26:47 -0500 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 t1CFQk0J008206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 12 Feb 2015 10:26:46 -0500 Message-ID: <54DCC635.3010405@redhat.com> Date: Thu, 12 Feb 2015 08:26:45 -0700 From: Eric Blake MIME-Version: 1.0 References: <1423748040-3448-1-git-send-email-armbru@redhat.com> <1423748040-3448-2-git-send-email-armbru@redhat.com> In-Reply-To: <1423748040-3448-2-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VEl0qLkD6O3OPaVgjPnkes5SkgThltIKJ" Subject: Re: [Qemu-devel] [PATCH v2 01/10] error: New convenience function error_report_err() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --VEl0qLkD6O3OPaVgjPnkes5SkgThltIKJ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/12/2015 06:33 AM, Markus Armbruster wrote: > I've typed error_report("%s", error_get_pretty(ERR)) too many times > already, and I've fixed too many instances of qerror_report_err(ERR) > to error_report("%s", error_get_pretty(ERR)) as well. Capture the > pattern in a convenience function. >=20 > Since it's almost invariably followed by error_free(), stuff that into > the convenience function as well. >=20 > The next patch will put it to use. >=20 > Signed-off-by: Markus Armbruster > --- > include/qapi/error.h | 5 +++++ > util/error.c | 6 ++++++ > 2 files changed, 11 insertions(+) > +++ b/util/error.c > @@ -152,6 +152,12 @@ const char *error_get_pretty(Error *err) > return err->msg; > } > =20 > +void error_report_err(Error *err) > +{ > + error_report("%s", error_get_pretty(err)); > + error_free(err); When I read v1, I wondered if it would make sense to allow: Error *local_err =3D NULL; error_report_err(local_err); as a no-op, so that calling code can unconditionally use this function rather than always burying it inside an 'if (problem)'. But in reviewing the rest of the patches, I wasn't sure it would save very many lines, and it also seems like it would be a bit more confusing to see a call to an error report function when there is no error to report. So in the opposite direction of thought, I wonder if you should add: assert(err); and enforce that this function is only ever used on real error messages, especially since error_get_pretty segfaults if called on no error. But I can also live without the assert, so: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --VEl0qLkD6O3OPaVgjPnkes5SkgThltIKJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJU3MY2AAoJEKeha0olJ0NqaxgH/21DS5VuYZV06wt5XSh4Fb6t csC1U0We/lT+AECwo2af7szy8lI9pqj6uRz5gn5/8Gbgdrpcc4h9vIaVUeSsDi2j ggOPDuIwK3j3C0lUjxOhIPYyzXPXQkkHw5WdGzz8aypRORFzAH4NULRVgFwsrRTG pWsmKKXb8ocgyK4J2woQGWK23UGWr9n/orMxCRdQqfuZiY6JWVwVNMUX+wupvw3y B8VLoroMrLev2djcpbsUtgx0Elr7WOXM3TTNAzf0O422gR9ubm0kdHag1h45blp0 EwlnZSb4KbOXltA6wi/DHEzB4YWMPw+kNI9GSQ3FcKktCvV9h2I0+iZxhPsMcNk= =y456 -----END PGP SIGNATURE----- --VEl0qLkD6O3OPaVgjPnkes5SkgThltIKJ--