From: "Emilio G. Cota" <cota@braap.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Daniel P . Berrange" <berrange@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Richard Henderson" <rth@twiddle.net>,
"QEMU Developers" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH 1/3] qht: simplify qht_reset_size
Date: Wed, 5 Oct 2016 18:34:38 -0400 [thread overview]
Message-ID: <1475706880-10667-2-git-send-email-cota@braap.org> (raw)
In-Reply-To: <1475706880-10667-1-git-send-email-cota@braap.org>
Sometimes gcc doesn't pick up the fact that 'new' is properly
set if 'resize == true', which may generate an unnecessary
build warning.
Fix it by removing 'resize' and directly checking that 'new'
is non-NULL.
Signed-off-by: Emilio G. Cota <cota@braap.org>
---
util/qht.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/util/qht.c b/util/qht.c
index 16a8d79..af8da3c 100644
--- a/util/qht.c
+++ b/util/qht.c
@@ -410,10 +410,9 @@ void qht_reset(struct qht *ht)
bool qht_reset_size(struct qht *ht, size_t n_elems)
{
- struct qht_map *new;
+ struct qht_map *new = NULL;
struct qht_map *map;
size_t n_buckets;
- bool resize = false;
n_buckets = qht_elems_to_buckets(n_elems);
@@ -421,18 +420,17 @@ bool qht_reset_size(struct qht *ht, size_t n_elems)
map = ht->map;
if (n_buckets != map->n_buckets) {
new = qht_map_create(n_buckets);
- resize = true;
}
qht_map_lock_buckets(map);
qht_map_reset__all_locked(map);
- if (resize) {
+ if (new) {
qht_do_resize(ht, new);
}
qht_map_unlock_buckets(map);
qemu_mutex_unlock(&ht->lock);
- return resize;
+ return !!new;
}
static inline
--
2.7.4
next prev parent reply other threads:[~2016-10-05 22:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 20:39 [Qemu-devel] transient failure in the test-qht tests Peter Maydell
2016-08-24 23:44 ` Emilio G. Cota
2016-08-24 23:52 ` Peter Maydell
2016-10-05 22:34 ` [Qemu-devel] [PATCH 0/3] qht fixes Emilio G. Cota
2016-10-05 22:34 ` Emilio G. Cota [this message]
2016-10-05 22:34 ` [Qemu-devel] [PATCH 2/3] qht: fix unlock-after-free segfault upon resizing Emilio G. Cota
2016-10-05 22:34 ` [Qemu-devel] [PATCH 3/3] test-qht: perform lookups under rcu_read_lock Emilio G. Cota
2016-10-06 8:31 ` [Qemu-devel] [PATCH 0/3] qht fixes Dr. David Alan Gilbert
2016-10-06 10:56 ` Paolo Bonzini
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=1475706880-10667-2-git-send-email-cota@braap.org \
--to=cota@braap.org \
--cc=alex.bennee@linaro.org \
--cc=berrange@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).