From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brun3-0007bp-2I for qemu-devel@nongnu.org; Wed, 05 Oct 2016 18:35:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brumy-00068e-EC for qemu-devel@nongnu.org; Wed, 05 Oct 2016 18:35:52 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:42506) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brumw-000637-4L for qemu-devel@nongnu.org; Wed, 05 Oct 2016 18:35:48 -0400 From: "Emilio G. Cota" Date: Wed, 5 Oct 2016 18:34:38 -0400 Message-Id: <1475706880-10667-2-git-send-email-cota@braap.org> In-Reply-To: <1475706880-10667-1-git-send-email-cota@braap.org> References: <1475706880-10667-1-git-send-email-cota@braap.org> Subject: [Qemu-devel] [PATCH 1/3] qht: simplify qht_reset_size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: "Daniel P . Berrange" , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , QEMU Developers 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 --- 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