From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH] Use error_is_set() only when necessary
Date: Thu, 30 Jan 2014 08:45:35 -0700 [thread overview]
Message-ID: <52EA739F.8020105@redhat.com> (raw)
In-Reply-To: <1391090848-2115-1-git-send-email-armbru@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2096 bytes --]
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 <armbru@redhat.com>
> ---
> 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).
> +++ 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 <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2014-01-30 15:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-30 14:07 [Qemu-devel] [PATCH] Use error_is_set() only when necessary Markus Armbruster
2014-01-30 15:45 ` Eric Blake [this message]
2014-01-30 16:02 ` Markus Armbruster
2014-01-30 17:14 ` Andreas Färber
2014-01-31 7:42 ` Markus Armbruster
2014-02-10 20:54 ` Luiz Capitulino
2014-02-11 1:24 ` Fam Zheng
2014-02-11 8:25 ` Markus Armbruster
2014-02-21 11:01 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52EA739F.8020105@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).