From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8toF-0004dF-7k for qemu-devel@nongnu.org; Thu, 30 Jan 2014 10:45:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8to9-00080h-Ur for qemu-devel@nongnu.org; Thu, 30 Jan 2014 10:45:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8to9-00080b-MX for qemu-devel@nongnu.org; Thu, 30 Jan 2014 10:45:37 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0UFja56003727 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 30 Jan 2014 10:45:36 -0500 Message-ID: <52EA739F.8020105@redhat.com> Date: Thu, 30 Jan 2014 08:45:35 -0700 From: Eric Blake MIME-Version: 1.0 References: <1391090848-2115-1-git-send-email-armbru@redhat.com> In-Reply-To: <1391090848-2115-1-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="en1WXT4vCvV9mXKiOoIhDPJl1kl4VL0VN" Subject: Re: [Qemu-devel] [PATCH] Use error_is_set() only when necessary 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) --en1WXT4vCvV9mXKiOoIhDPJl1kl4VL0VN Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 01/30/2014 07:07 AM, Markus Armbruster wrote: > error_is_set(&var) is the same as var !=3D NULL, but it takes > whole-program analysis to figure that out. Unnecessarily hard for > optimizers, static checkers, and human readers. Dumb it down to > obvious. >=20 > Gets rid of several dozen Coverity false positives. >=20 > Note that the obvious form is already used in many places. >=20 > Signed-off-by: Markus Armbruster > --- > 37 files changed, 156 insertions(+), 156 deletions(-) Good diffstat - shows it should be fairly mechanical. > @@ -1399,7 +1399,7 @@ fail: > QDECREF(bs->options); > QDECREF(options); > bs->options =3D NULL; > - if (error_is_set(&local_err)) { > + if (local_err) { > error_propagate(errp, local_err); > } > return ret; Is it worth a further cleanup on instances like this? That is, error_propagate(errp, NULL) is a safe no-op, so we can avoid the 'if (local_err)' conditional. But that should not be in this patch (keep the mechanical changes easy). > +++ b/block/snapshot.c > @@ -345,7 +345,7 @@ int bdrv_snapshot_load_tmp_by_id_or_name(BlockDrive= rState *bs, > ret =3D bdrv_snapshot_load_tmp(bs, NULL, id_or_name, &local_er= r); > } > =20 > - if (error_is_set(&local_err)) { > + if (local_err) { > error_propagate(errp, local_err); > } Another example that can be simplified. > +++ b/tests/test-qmp-input-strict.c > @@ -92,7 +92,7 @@ static void test_validate_struct(TestInputVisitorData= *data, > v =3D validate_test_init(data, "{ 'integer': -42, 'boolean': true,= 'string': 'foo' }"); > =20 > visit_type_TestStruct(v, &p, NULL, &errp); > - g_assert(!error_is_set(&errp)); > + g_assert(!errp); This (and other places in test files) chould use visit_type_TestStruct(v, &p, NULL, &error_abort) and ditch local errp. But that's a separate patch as well. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --en1WXT4vCvV9mXKiOoIhDPJl1kl4VL0VN 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/ iQEcBAEBCAAGBQJS6nOfAAoJEKeha0olJ0NqV+AIAKAKQo2RLqXKlPt2KD8Fxq/4 Uc59sXUXiK+m4UWGDV3o65+/9xNG6/YmHE503us2GMR04wID6rvAWQEuwH8S9r/2 x4lfKj2Dqp+hhrXb+HIHq10xID9kLPqLrXulxfVSUX9taV1k/S6SJSArjU+3n3tj oIHvapXCH3hMqtsrjJT69NIIJvVl5DZ+zc7r12Hd9Ae0sej4CnrJQOFPcKjnrH1T StPoPYItC8Ax5N2zV6Ysn2XhxLURTFTx2Avhx+GydvlQmlRSQc95V+/Kb+IMpGyi z1FpdnycbjoZxCZ7tnmxRrFN9UtDpCW79sjWUJ6+XR0nYc1RPOvufHvvfYVTI8E= =YCM3 -----END PGP SIGNATURE----- --en1WXT4vCvV9mXKiOoIhDPJl1kl4VL0VN--