From patchwork Thu Dec 15 00:44:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 705865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tfFXG0NzZz9ryv for ; Thu, 15 Dec 2016 12:02:06 +1100 (AEDT) Received: from localhost ([::1]:51187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cHKQu-0000cR-0s for incoming@patchwork.ozlabs.org; Wed, 14 Dec 2016 20:02:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cHKBt-0002wq-G1 for qemu-devel@nongnu.org; Wed, 14 Dec 2016 19:46:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cHKBp-0001IW-TQ for qemu-devel@nongnu.org; Wed, 14 Dec 2016 19:46:33 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59257 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cHKBp-0001Ht-M8 for qemu-devel@nongnu.org; Wed, 14 Dec 2016 19:46:29 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uBF0jfit079896 for ; Wed, 14 Dec 2016 19:46:29 -0500 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 27bdm790ay-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 14 Dec 2016 19:46:28 -0500 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Dec 2016 17:46:27 -0700 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Dec 2016 17:46:25 -0700 Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id B42653E40030; Wed, 14 Dec 2016 17:46:24 -0700 (MST) Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uBF0kOWt42074300; Thu, 15 Dec 2016 00:46:24 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 491BD12403F; Wed, 14 Dec 2016 19:46:24 -0500 (EST) Received: from localhost (unknown [9.80.108.238]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 0CADE124035; Wed, 14 Dec 2016 19:46:24 -0500 (EST) From: Michael Roth To: qemu-devel@nongnu.org Date: Wed, 14 Dec 2016 18:44:23 -0600 X-Mailer: git-send-email 1.9.1 In-Reply-To: <1481762701-4587-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1481762701-4587-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16121500-8235-0000-0000-00000A301154 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006250; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000196; SDB=6.00793944; UDB=6.00384987; IPR=6.00571750; BA=6.00004968; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013630; XFM=3.00000011; UTC=2016-12-15 00:46:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16121500-8236-0000-0000-000037A95559 Message-Id: <1481762701-4587-30-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-14_15:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1612150008 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 29/67] qht: simplify qht_reset_size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , "Emilio G. Cota" , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" 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 Message-Id: <1475706880-10667-2-git-send-email-cota@braap.org> Signed-off-by: Paolo Bonzini (cherry picked from commit f555a9d0b3c785b698f32e6879e97d0a4b387314) Signed-off-by: Michael Roth --- 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