From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8u51-0007qr-5L for qemu-devel@nongnu.org; Thu, 30 Jan 2014 11:03:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8u4u-0005II-OV for qemu-devel@nongnu.org; Thu, 30 Jan 2014 11:03:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8u4u-0005I9-Dm for qemu-devel@nongnu.org; Thu, 30 Jan 2014 11:02:56 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0UG2sCP026985 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 30 Jan 2014 11:02:55 -0500 From: Markus Armbruster References: <1391090848-2115-1-git-send-email-armbru@redhat.com> <52EA739F.8020105@redhat.com> Date: Thu, 30 Jan 2014 17:02:52 +0100 In-Reply-To: <52EA739F.8020105@redhat.com> (Eric Blake's message of "Thu, 30 Jan 2014 08:45:35 -0700") Message-ID: <87mwid31ar.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain 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: Eric Blake Cc: qemu-devel@nongnu.org, lcapitulino@redhat.com Eric Blake writes: > On 01/30/2014 07:07 AM, Markus Armbruster wrote: >> error_is_set(&var) is the same as var != 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. >> >> Gets rid of several dozen Coverity false positives. >> >> Note that the obvious form is already used in many places. >> >> 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 = 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). I like your suggestion, and I agree it should be a separate patch. >> +++ b/block/snapshot.c >> @@ -345,7 +345,7 @@ int bdrv_snapshot_load_tmp_by_id_or_name(BlockDriverState *bs, >> ret = bdrv_snapshot_load_tmp(bs, NULL, id_or_name, &local_err); >> } >> >> - 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 = validate_test_init(data, "{ 'integer': -42, 'boolean': >> true, 'string': 'foo' }"); >> >> 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 I like this one, too. Thanks!