From nobody Mon May 6 07:30:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1642778508; cv=none; d=zohomail.com; s=zohoarc; b=ZPTBDrn64gVC6dWKNOWGsgFAZNu/kV1KBEBYUSoK/7EoIazDhpectya1pYYPEOQTDLM484PIl6H1IEuuv9W32JbnHM8SO6ge7E9cxQLs/827EIYb8GEeOx681J43IA+2klfUtBMndd9Lo02+IzxpGQF+Fz7N70zfsG3Ma3NgjuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642778508; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZBetHUzsVCOLsWp+Bkz8oxjPdadRJFJdO1+aPzoPric=; b=MDm+Ne7IPWZBgIHQx/I1h82SXu1acu5esgtzTfTLyfiHACSWU//HsOgUt9TjQpnIrE+lL72wPsdMR885X+tYV4+2X/KneLzNzPoD8gi/TSidi5eLV/YZjjcYi/iNhQH0z/TBikNtSA93rcGLHpSDAgPCJevxYwTi4CL+qE8Bjvc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1642778508728792.7051921417967; Fri, 21 Jan 2022 07:21:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.259389.447690 (Exim 4.92) (envelope-from ) id 1nAvjC-0003MG-NU; Fri, 21 Jan 2022 15:21:26 +0000 Received: by outflank-mailman (output) from mailman id 259389.447690; Fri, 21 Jan 2022 15:21:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nAvjC-0003La-GH; Fri, 21 Jan 2022 15:21:26 +0000 Received: by outflank-mailman (input) for mailman id 259389; Fri, 21 Jan 2022 15:21:24 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nAvjA-0003JT-OQ for xen-devel@lists.xenproject.org; Fri, 21 Jan 2022 15:21:24 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id cac561d0-7acd-11ec-8fa7-f31e035a9116; Fri, 21 Jan 2022 16:21:23 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0250F212C9; Fri, 21 Jan 2022 15:21:23 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CD54313D44; Fri, 21 Jan 2022 15:21:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KMniMHLP6mFpAgAAMHmgww (envelope-from ); Fri, 21 Jan 2022 15:21:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cac561d0-7acd-11ec-8fa7-f31e035a9116 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1642778483; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZBetHUzsVCOLsWp+Bkz8oxjPdadRJFJdO1+aPzoPric=; b=U39AAEV9UwCi/N4edg8P8B8vwoIgUeRLsR2vaOzDuqGKUaV/IKq+XTOd4OejfohCg+b0/6 LOUT4IjUcOrzCpY6ggnzjtRQVJuaFedqVg4mjCMGHV2uPWUuUT1Q3zG5RPiO1FsRzJuAjJ 4vJv36wUjyqWEH/sBhmUtEgTjpHTUb0= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH v2 1/3] tools/xenstore: merge hashtable_private.h into hashtable.c Date: Fri, 21 Jan 2022 16:21:18 +0100 Message-Id: <20220121152120.23160-2-jgross@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220121152120.23160-1-jgross@suse.com> References: <20220121152120.23160-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1642778509514100009 Content-Type: text/plain; charset="utf-8" hashtable_private.h is used in hashtable.c only. Signed-off-by: Juergen Gross Reviewed-by: Anthony PERARD --- tools/xenstore/hashtable.c | 31 +++++++++-- tools/xenstore/hashtable_private.h | 85 ------------------------------ 2 files changed, 27 insertions(+), 89 deletions(-) delete mode 100644 tools/xenstore/hashtable_private.h diff --git a/tools/xenstore/hashtable.c b/tools/xenstore/hashtable.c index 394b1cf9d0..39fb3ed338 100644 --- a/tools/xenstore/hashtable.c +++ b/tools/xenstore/hashtable.c @@ -1,13 +1,29 @@ /* Copyright (C) 2004 Christopher Clark = */ =20 #include "hashtable.h" -#include "hashtable_private.h" #include #include #include #include #include =20 +struct entry +{ + void *k, *v; + unsigned int h; + struct entry *next; +}; + +struct hashtable { + unsigned int tablelength; + struct entry **table; + unsigned int entrycount; + unsigned int loadlimit; + unsigned int primeindex; + unsigned int (*hashfn) (void *k); + int (*eqfn) (void *k1, void *k2); +}; + /* Credit for primes table: Aaron Krowne http://br.endernet.org/~akrowne/ @@ -25,6 +41,13 @@ static const unsigned int primes[] =3D { const unsigned int prime_table_length =3D sizeof(primes)/sizeof(primes[0]); const unsigned int max_load_factor =3D 65; /* percentage */ =20 +/*************************************************************************= ****/ +/* indexFor */ +static inline unsigned int +indexFor(unsigned int tablelength, unsigned int hashvalue) { + return (hashvalue % tablelength); +} + /*************************************************************************= ****/ struct hashtable * create_hashtable(unsigned int minsize, @@ -211,7 +234,7 @@ hashtable_remove(struct hashtable *h, void *k) *pE =3D e->next; h->entrycount--; v =3D e->v; - freekey(e->k); + free(e->k); free(e); return v; } @@ -235,7 +258,7 @@ hashtable_destroy(struct hashtable *h, int free_values) { e =3D table[i]; while (NULL !=3D e) - { f =3D e; e =3D e->next; freekey(f->k); free(f->v); free(f); } + { f =3D e; e =3D e->next; free(f->k); free(f->v); free(f); } } } else @@ -244,7 +267,7 @@ hashtable_destroy(struct hashtable *h, int free_values) { e =3D table[i]; while (NULL !=3D e) - { f =3D e; e =3D e->next; freekey(f->k); free(f); } + { f =3D e; e =3D e->next; free(f->k); free(f); } } } free(h->table); diff --git a/tools/xenstore/hashtable_private.h b/tools/xenstore/hashtable_= private.h deleted file mode 100644 index 3e95f60057..0000000000 --- a/tools/xenstore/hashtable_private.h +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (C) 2002, 2004 Christopher Clark */ - -#ifndef __HASHTABLE_PRIVATE_CWC22_H__ -#define __HASHTABLE_PRIVATE_CWC22_H__ - -#include "hashtable.h" - -/*************************************************************************= ****/ -struct entry -{ - void *k, *v; - unsigned int h; - struct entry *next; -}; - -struct hashtable { - unsigned int tablelength; - struct entry **table; - unsigned int entrycount; - unsigned int loadlimit; - unsigned int primeindex; - unsigned int (*hashfn) (void *k); - int (*eqfn) (void *k1, void *k2); -}; - -/*************************************************************************= ****/ -unsigned int -hash(struct hashtable *h, void *k); - -/*************************************************************************= ****/ -/* indexFor */ -static inline unsigned int -indexFor(unsigned int tablelength, unsigned int hashvalue) { - return (hashvalue % tablelength); -}; - -/* Only works if tablelength =3D=3D 2^N */ -/*static inline unsigned int -indexFor(unsigned int tablelength, unsigned int hashvalue) -{ - return (hashvalue & (tablelength - 1u)); -} -*/ - -/*************************************************************************= ****/ -#define freekey(X) free(X) -/*define freekey(X) ; */ - - -/*************************************************************************= ****/ - -#endif /* __HASHTABLE_PRIVATE_CWC22_H__*/ - -/* - * Copyright (c) 2002, Christopher Clark - * All rights reserved. - *=20 - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - *=20 - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - *=20 - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - *=20 - * * Neither the name of the original author; nor the names of any contrib= utors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - *=20 - *=20 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT O= WNER - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ --=20 2.31.1 From nobody Mon May 6 07:30:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1642778507; cv=none; d=zohomail.com; s=zohoarc; b=QtzP7dXrGw8okd4YDApxVY47tLo8oIDZKYyilYLWpARausrAly0PvL6j1Ao+o3c9EL7eGe0dc2Z6oUbyxQPBPpkEp+B16cqzBVYRAeBD6Cuz7nkganFvWDMW06iTE/qL0I/4Y9hHT/qZMuRh7xTrQq5znNghO1b3UCIx8iVS02g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642778507; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VXZ4prMIpVFrrFMIWdWQrhRMeB3VhjvcCXF+R1jtDDI=; b=EG6ya23eo7drrJU4xOTXkX30Y/YynA/u+0lFicf6OJ10UMMLaaVX44rZr48FS0t8K7a4w60XlOFshN19dGvRDcexZ2bpevL7r4kHMObyjI4H11jBtl4cEGd27T9zIh+w1yJpVDqtCAGWLiDU1dPMNeUFXAf5jAzvsMf4z1IPPas= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1642778507295985.9473286080396; Fri, 21 Jan 2022 07:21:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.259388.447685 (Exim 4.92) (envelope-from ) id 1nAvjC-0003Jq-Bd; Fri, 21 Jan 2022 15:21:26 +0000 Received: by outflank-mailman (output) from mailman id 259388.447685; Fri, 21 Jan 2022 15:21:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nAvjC-0003Jj-8H; Fri, 21 Jan 2022 15:21:26 +0000 Received: by outflank-mailman (input) for mailman id 259388; Fri, 21 Jan 2022 15:21:24 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nAvjA-0003JS-I1 for xen-devel@lists.xenproject.org; Fri, 21 Jan 2022 15:21:24 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cae5fff1-7acd-11ec-bc18-3156f6d857e4; Fri, 21 Jan 2022 16:21:23 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 32F521F3CA; Fri, 21 Jan 2022 15:21:23 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 07C1E139FE; Fri, 21 Jan 2022 15:21:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UOyLAHPP6mFpAgAAMHmgww (envelope-from ); Fri, 21 Jan 2022 15:21:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cae5fff1-7acd-11ec-bc18-3156f6d857e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1642778483; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VXZ4prMIpVFrrFMIWdWQrhRMeB3VhjvcCXF+R1jtDDI=; b=K0RVKNNxDd6j45+dZrVhb2dnyL5frrMrFuBynomw1azt35e1z2ocyBv2UiBzfA05hQZnwC Y0fTJuMM8o/WBI2tzl5uVdOLkVfY58oZXALVpbi98B5xWYeFignI4JiBQbzobXm6Zm2ALL fWa49cqpclhC9Gwsrw2//JT2GQWtAyU= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH v2 2/3] tools/xenstore: fix hashtable_expand() zeroing new area Date: Fri, 21 Jan 2022 16:21:19 +0100 Message-Id: <20220121152120.23160-3-jgross@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220121152120.23160-1-jgross@suse.com> References: <20220121152120.23160-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1642778509321100005 Content-Type: text/plain; charset="utf-8" When realloc()ing the hashtable for expanding it, zero out all the new bytes at the end of the table, not only one byte for each new element. Fixes: 186f0e02a1c ("Added hashtable implementation") Signed-off-by: Juergen Gross Reviewed-by: Anthony PERARD --- This might be a backport candidate --- tools/xenstore/hashtable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/xenstore/hashtable.c b/tools/xenstore/hashtable.c index 39fb3ed338..6ac336eff1 100644 --- a/tools/xenstore/hashtable.c +++ b/tools/xenstore/hashtable.c @@ -136,7 +136,8 @@ hashtable_expand(struct hashtable *h) realloc(h->table, newsize * sizeof(struct entry *)); if (NULL =3D=3D newtable) { (h->primeindex)--; return 0; } h->table =3D newtable; - memset(newtable[h->tablelength], 0, newsize - h->tablelength); + memset(newtable + h->tablelength, 0, + (newsize - h->tablelength) * sizeof(*newtable)); for (i =3D 0; i < h->tablelength; i++) { for (pE =3D &(newtable[i]), e =3D *pE; e !=3D NULL; e =3D *pE)= { index =3D indexFor(newsize,e->h); --=20 2.31.1 From nobody Mon May 6 07:30:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1642778507; cv=none; d=zohomail.com; s=zohoarc; b=AxJXTSJzrjCB/q4ZUTJQv5yqUNET53GPxsZjlbDxGH9mG5t0O62vrFvmyBGn+xbT8ggAhermryCQoypdO7bxBjvlT5z8tAC5mWeGhBFfS6qFfsmdxgi7oz8itIgH1etUJgptjYDheVFCMyxwnej3/l4gG+bcrZSNXLwIgTLsIwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642778507; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=O9732WdVSEHkO7bksmSTG5m8vSoXsF5+FW9lmh0rLLs=; b=ZcZfRLS0P74kohqqiZ4fDsMN3H//oBPlTVo3btjlbArIvokxxcCfNdng7DuBI82YJee9fjmQo5zjHrJNtQak4bGd8KGYeAVV+D0cr6Nwk3TzWPcg7d16Ma1zyKmd06FpvqF5LHDbGUvB6ExGwKvQDJLc4PI+eIdPEgg5IYqTRRU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1642778507680366.3462398342127; Fri, 21 Jan 2022 07:21:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.259391.447717 (Exim 4.92) (envelope-from ) id 1nAvjE-00041B-AB; Fri, 21 Jan 2022 15:21:28 +0000 Received: by outflank-mailman (output) from mailman id 259391.447717; Fri, 21 Jan 2022 15:21:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nAvjE-0003zL-47; Fri, 21 Jan 2022 15:21:28 +0000 Received: by outflank-mailman (input) for mailman id 259391; Fri, 21 Jan 2022 15:21:26 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nAvjC-0003JS-Ad for xen-devel@lists.xenproject.org; Fri, 21 Jan 2022 15:21:26 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id cb099909-7acd-11ec-bc18-3156f6d857e4; Fri, 21 Jan 2022 16:21:23 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6711F21984; Fri, 21 Jan 2022 15:21:23 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3ACA5139FE; Fri, 21 Jan 2022 15:21:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0MAlDXPP6mFpAgAAMHmgww (envelope-from ); Fri, 21 Jan 2022 15:21:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: cb099909-7acd-11ec-bc18-3156f6d857e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1642778483; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O9732WdVSEHkO7bksmSTG5m8vSoXsF5+FW9lmh0rLLs=; b=AZDKhfiG9ScnlbZp73vc2ZT78gHhwJjaDRasVlqh2mfTanN95N5NS7AJsS3avwPnfBPaJ6 Lq5Gg5Qruh2s3af7gY5qF5BenHa4H/0Rvz4DD9qem81SbgIwbeW7iTKen7FM8srYuZIpXq /+H/EKtn6V+Sw7DkcTMl5rpBorhFAfo= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH v2 3/3] tools/xenstore: drop DEFINE_HASHTABLE_* macros and usage intro Date: Fri, 21 Jan 2022 16:21:20 +0100 Message-Id: <20220121152120.23160-4-jgross@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220121152120.23160-1-jgross@suse.com> References: <20220121152120.23160-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1642778509319100004 Content-Type: text/plain; charset="utf-8" The DEFINE_HASHTABLE_* macros are used nowhere, so drop them. The usage intro isn't really needed either. Signed-off-by: Juergen Gross Reviewed-by: Anthony PERARD --- V2: - reword commit message (Anthony PERARD) --- tools/xenstore/hashtable.h | 76 -------------------------------------- 1 file changed, 76 deletions(-) diff --git a/tools/xenstore/hashtable.h b/tools/xenstore/hashtable.h index b90781abd4..62fef6081a 100644 --- a/tools/xenstore/hashtable.h +++ b/tools/xenstore/hashtable.h @@ -5,62 +5,6 @@ =20 struct hashtable; =20 -/* Example of use: - * - * struct hashtable *h; - * struct some_key *k; - * struct some_value *v; - * - * static unsigned int hash_from_key_fn( void *k ); - * static int keys_equal_fn ( void *key1, void *key2= ); - * - * h =3D create_hashtable(16, hash_from_key_fn, keys_equal_fn); - * k =3D (struct some_key *) malloc(sizeof(struct some_key)); - * v =3D (struct some_value *) malloc(sizeof(struct some_value)); - * - * (initialise k and v to suitable values) - *=20 - * if (! hashtable_insert(h,k,v) ) - * { exit(-1); } - * - * if (NULL =3D=3D (found =3D hashtable_search(h,k) )) - * { printf("not found!"); } - * - * if (NULL =3D=3D (found =3D hashtable_remove(h,k) )) - * { printf("Not found\n"); } - * - */ - -/* Macros may be used to define type-safe(r) hashtable access functions, w= ith - * methods specialized to take known key and value types as parameters. - *=20 - * Example: - * - * Insert this at the start of your file: - * - * DEFINE_HASHTABLE_INSERT(insert_some, struct some_key, struct some_value= ); - * DEFINE_HASHTABLE_SEARCH(search_some, struct some_key, struct some_value= ); - * DEFINE_HASHTABLE_REMOVE(remove_some, struct some_key, struct some_value= ); - * - * This defines the functions 'insert_some', 'search_some' and 'remove_som= e'. - * These operate just like hashtable_insert etc., with the same parameters, - * but their function signatures have 'struct some_key *' rather than - * 'void *', and hence can generate compile time errors if your program is - * supplying incorrect data as a key (and similarly for value). - * - * Note that the hash and key equality functions passed to create_hashtable - * still take 'void *' parameters instead of 'some key *'. This shouldn't = be - * a difficult issue as they're only defined and passed once, and the other - * functions will ensure that only valid keys are supplied to them. - * - * The cost for this checking is increased code size and runtime overhead - * - if performance is important, it may be worth switching back to the - * unsafe methods once your program has been debugged with the safe method= s. - * This just requires switching to some simple alternative defines - eg: - * #define insert_some hashtable_insert - * - */ - /*************************************************************************= **** * create_hashtable =20 @@ -98,12 +42,6 @@ create_hashtable(unsigned int minsize, int=20 hashtable_insert(struct hashtable *h, void *k, void *v); =20 -#define DEFINE_HASHTABLE_INSERT(fnname, keytype, valuetype) \ -int fnname (struct hashtable *h, keytype *k, valuetype *v) \ -{ \ - return hashtable_insert(h,k,v); \ -} - /*************************************************************************= **** * hashtable_search =20 @@ -116,12 +54,6 @@ int fnname (struct hashtable *h, keytype *k, valuetype = *v) \ void * hashtable_search(struct hashtable *h, void *k); =20 -#define DEFINE_HASHTABLE_SEARCH(fnname, keytype, valuetype) \ -valuetype * fnname (struct hashtable *h, keytype *k) \ -{ \ - return (valuetype *) (hashtable_search(h,k)); \ -} - /*************************************************************************= **** * hashtable_remove =20 @@ -134,13 +66,6 @@ valuetype * fnname (struct hashtable *h, keytype *k) \ void * /* returns value */ hashtable_remove(struct hashtable *h, void *k); =20 -#define DEFINE_HASHTABLE_REMOVE(fnname, keytype, valuetype) \ -valuetype * fnname (struct hashtable *h, keytype *k) \ -{ \ - return (valuetype *) (hashtable_remove(h,k)); \ -} - - /*************************************************************************= **** * hashtable_count =20 @@ -151,7 +76,6 @@ valuetype * fnname (struct hashtable *h, keytype *k) \ unsigned int hashtable_count(struct hashtable *h); =20 - /*************************************************************************= **** * hashtable_destroy =20 --=20 2.31.1