From nobody Wed Nov 5 13:14:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153660631972073.00236953306216; Mon, 10 Sep 2018 12:05:19 -0700 (PDT) Received: from localhost ([::1]:53553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fzRUs-0005a1-JG for importer@patchew.org; Mon, 10 Sep 2018 15:05:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fzRPV-0001MS-RR for qemu-devel@nongnu.org; Mon, 10 Sep 2018 14:59:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fzRPQ-0001FI-Pb for qemu-devel@nongnu.org; Mon, 10 Sep 2018 14:59:43 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:35481) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fzRPQ-0001Cr-Gh for qemu-devel@nongnu.org; Mon, 10 Sep 2018 14:59:40 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 7980B21F43; Mon, 10 Sep 2018 14:59:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 10 Sep 2018 14:59:08 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 0AB921029E; Mon, 10 Sep 2018 14:59:08 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=cofvh+1D3FvnYV HED0DObiPkMcCboFUZYsZNu239q40=; b=cWQYml4HT9vHNnxCXP484gXu5EaozV 4l6Z3WxGOQqlmtJ9vOkSXPUiAQ5jIwxmP0RwfbY+16plAkVKKfw+65uFp41L0N+B 7TPF4pdTItWW1aI3hIfntRsE4p9utG0NabZgA9EzfGEWUTd+jpV8PLNv29F5fzHw TmG6yOo66N714= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=cofvh+1D3FvnYVHED0DObiPkMcCboFUZYsZNu239q40=; b=RuNXL/Up fr5YUjZHH+iSFpgnfJdZWz4Capd89WRB93BbCcjhMhFXz9AnZFHbcszgdh8eBGTY SHatiM9XIm34Is1fPPVcJ1BjZy8/4Fwkn9U0HW1MYysqBzke8qi8dF7W6iTzFr+I 7tuWFGtfxx+/7aoYLRvWPN8H+8vOTbWbrc06/xqg0MQSvGuG2VMnmJMb+KylT0vQ V+VK0FeOScTokxNs0FEIc/J81Goy39ryLZ+OvpnLAnQ7GTdsee8O0huL+PSLDCmn 5o/zvImFufo8ROW8vPYoXaVZPSuNeyJQu9lDVqtXo+k03NhUbaV5HQxe27jThJ9I 8DlN0a0d/ze7gg== X-ME-Proxy: X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Mon, 10 Sep 2018 14:58:56 -0400 Message-Id: <20180910185859.27917-10-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180910185859.27917-1-cota@braap.org> References: <20180910185859.27917-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v2 09/12] qht: constify qht_lookup 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" seqlock_read_begin takes a const param since c04649eeea ("seqlock: constify seqlock_read_begin", 2018-08-23), so we can constify the entire lookup. Signed-off-by: Emilio G. Cota --- include/qemu/qht.h | 4 ++-- util/qht.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/qemu/qht.h b/include/qemu/qht.h index 6484837487..2e2d6bca93 100644 --- a/include/qemu/qht.h +++ b/include/qemu/qht.h @@ -104,7 +104,7 @@ bool qht_insert(struct qht *ht, void *p, uint32_t hash,= void **existing); * Returns the corresponding pointer when a match is found. * Returns NULL otherwise. */ -void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, +void *qht_lookup_custom(const struct qht *ht, const void *userp, uint32_t = hash, qht_lookup_func_t func); =20 /** @@ -115,7 +115,7 @@ void *qht_lookup_custom(struct qht *ht, const void *use= rp, uint32_t hash, * * Calls qht_lookup_custom() using @ht's default comparison function. */ -void *qht_lookup(struct qht *ht, const void *userp, uint32_t hash); +void *qht_lookup(const struct qht *ht, const void *userp, uint32_t hash); =20 /** * qht_remove - remove a pointer from the hash table diff --git a/util/qht.c b/util/qht.c index 3564a7e20f..020dfe6912 100644 --- a/util/qht.c +++ b/util/qht.c @@ -236,7 +236,7 @@ static inline void qht_head_init(struct qht_bucket *b) } =20 static inline -struct qht_bucket *qht_map_to_bucket(struct qht_map *map, uint32_t hash) +struct qht_bucket *qht_map_to_bucket(const struct qht_map *map, uint32_t h= ash) { return &map->buckets[hash & (map->n_buckets - 1)]; } @@ -482,10 +482,10 @@ bool qht_reset_size(struct qht *ht, size_t n_elems) } =20 static inline -void *qht_do_lookup(struct qht_bucket *head, qht_lookup_func_t func, +void *qht_do_lookup(const struct qht_bucket *head, qht_lookup_func_t func, const void *userp, uint32_t hash) { - struct qht_bucket *b =3D head; + const struct qht_bucket *b =3D head; int i; =20 do { @@ -509,7 +509,7 @@ void *qht_do_lookup(struct qht_bucket *head, qht_lookup= _func_t func, } =20 static __attribute__((noinline)) -void *qht_lookup__slowpath(struct qht_bucket *b, qht_lookup_func_t func, +void *qht_lookup__slowpath(const struct qht_bucket *b, qht_lookup_func_t f= unc, const void *userp, uint32_t hash) { unsigned int version; @@ -522,11 +522,11 @@ void *qht_lookup__slowpath(struct qht_bucket *b, qht_= lookup_func_t func, return ret; } =20 -void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, +void *qht_lookup_custom(const struct qht *ht, const void *userp, uint32_t = hash, qht_lookup_func_t func) { - struct qht_bucket *b; - struct qht_map *map; + const struct qht_bucket *b; + const struct qht_map *map; unsigned int version; void *ret; =20 @@ -545,7 +545,7 @@ void *qht_lookup_custom(struct qht *ht, const void *use= rp, uint32_t hash, return qht_lookup__slowpath(b, func, userp, hash); } =20 -void *qht_lookup(struct qht *ht, const void *userp, uint32_t hash) +void *qht_lookup(const struct qht *ht, const void *userp, uint32_t hash) { return qht_lookup_custom(ht, userp, hash, ht->cmp); } --=20 2.17.1