From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auQDp-00028Y-Lj for qemu-devel@nongnu.org; Sun, 24 Apr 2016 16:01:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1auQDm-0003zq-Eq for qemu-devel@nongnu.org; Sun, 24 Apr 2016 16:01:37 -0400 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]:35300) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auQDm-0003zF-8x for qemu-devel@nongnu.org; Sun, 24 Apr 2016 16:01:34 -0400 Received: by mail-pf0-x231.google.com with SMTP id n1so59417259pfn.2 for ; Sun, 24 Apr 2016 13:01:34 -0700 (PDT) Sender: Richard Henderson References: <1461107270-19234-1-git-send-email-cota@braap.org> <1461107270-19234-9-git-send-email-cota@braap.org> From: Richard Henderson Message-ID: <571D261B.40406@twiddle.net> Date: Sun, 24 Apr 2016 13:01:31 -0700 MIME-Version: 1.0 In-Reply-To: <1461107270-19234-9-git-send-email-cota@braap.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 08/11] qht: QEMU's fast, resizable and scalable Hash Table List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Emilio G. Cota" , QEMU Developers , MTTCG Devel Cc: =?UTF-8?Q?Alex_Benn=c3=a9e?= , Paolo Bonzini , Peter Crosthwaite , Peter Maydell , Sergey Fedorov On 04/19/2016 04:07 PM, Emilio G. Cota wrote: > +static void qht_insert__locked(struct qht *ht, struct qht_map *map, > + struct qht_bucket *head, void *p, uint32_t hash) > +{ > + struct qht_bucket *b = head; > + struct qht_bucket *prev = NULL; > + struct qht_bucket *new = NULL; > + int i; > + > + for (;;) { > + if (b == NULL) { > + b = qemu_memalign(QHT_BUCKET_ALIGN, sizeof(*b)); > + memset(b, 0, sizeof(*b)); > + new = b; > + } > + for (i = 0; i < QHT_BUCKET_ENTRIES; i++) { > + if (b->hashes[i]) { > + continue; > + } Surely that's b->pointers[i] != NULL. We've made no provision that the hash function must return non-zero. > +static inline bool qht_remove__locked(struct qht_map *map, struct qht_bucket *b, > + const void *p, uint32_t hash) > +{ > + int i; > + > + do { > + for (i = 0; i < QHT_BUCKET_ENTRIES; i++) { > + if (b->hashes[i] == hash && b->pointers[i] == p) { Don't you only need to test p here? r~