From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Greg Kurz <groug@kaod.org>
Cc: Laurent Vivier <lvivier@redhat.com>,
Thomas Huth <thuth@redhat.com>, Corey Minyard <minyard@acm.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
qemu-ppc@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH 5/5] util/qsp: Do not declare local variable only used for assertion
Date: Wed, 2 Sep 2020 11:53:00 +0200 [thread overview]
Message-ID: <f69d4081-a297-a9ca-b5c9-39efff9fa3ca@redhat.com> (raw)
In-Reply-To: <20200902111112.251568b8@bahia.lan>
On 9/2/20 11:11 AM, Greg Kurz wrote:
> On Wed, 2 Sep 2020 10:08:01 +0200
> Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
>> This variable is used once in an assertion. Remove single
>> declaration and access directly in the assert().
>>
>> See in "qemu/osdep.h":
>>
>> * [...] disable assertion is not
>> * supported upstream so the risk is all yours. Meanwhile, please
>> * submit patches to remove any side-effects inside an assertion, or
>> * fixing error handling that should use Error instead of assert.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> util/qsp.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/util/qsp.c b/util/qsp.c
>> index 7d5147f1b20..1db044ecedd 100644
>> --- a/util/qsp.c
>> +++ b/util/qsp.c
>> @@ -560,9 +560,7 @@ static void qsp_iter_diff(void *p, uint32_t hash, void *htp)
>>
>> /* No point in reporting an empty entry */
>> if (new->n_acqs == 0 && new->ns == 0) {
>> - bool removed = qht_remove(ht, new, hash);
>> -
>> - g_assert(removed);
>> + g_assert(qht_remove(ht, new, hash));
>
> Urgh... this is doing exactly the opposite of the "qemu/osdep.h"
> recommandations above. We still want to remove new from the
> hash table even if QEMU was built without assertions.
Oops you are right :/
>
>> g_free(new);
>> }
>> }
>
prev parent reply other threads:[~2020-09-02 9:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-02 8:07 [PATCH 0/5] misc: Reduce assert side-effects Philippe Mathieu-Daudé
2020-09-02 8:07 ` [PATCH 1/5] tests/qtest/ipmi-kcs: Fix assert side-effect Philippe Mathieu-Daudé
2020-09-02 8:50 ` Greg Kurz
2020-09-02 9:54 ` Thomas Huth
2020-09-02 8:07 ` [PATCH 2/5] hw/pci-bridge: Do not declare local variable only used for assertion Philippe Mathieu-Daudé
2020-09-02 8:59 ` Greg Kurz
2020-09-02 8:07 ` [PATCH 3/5] hw/ppc/spapr: " Philippe Mathieu-Daudé
2020-09-02 9:00 ` Greg Kurz
2020-09-02 8:08 ` [PATCH 4/5] tcg/tcg: " Philippe Mathieu-Daudé
2020-09-02 9:02 ` Greg Kurz
2020-09-02 8:08 ` [PATCH 5/5] util/qsp: " Philippe Mathieu-Daudé
2020-09-02 9:11 ` Greg Kurz
2020-09-02 9:53 ` Philippe Mathieu-Daudé [this message]
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=f69d4081-a297-a9ca-b5c9-39efff9fa3ca@redhat.com \
--to=philmd@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=groug@kaod.org \
--cc=lvivier@redhat.com \
--cc=minyard@acm.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=rth@twiddle.net \
--cc=thuth@redhat.com \
/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).