From nobody Fri May 3 04:23:40 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=1642680190; cv=none; d=zohomail.com; s=zohoarc; b=YT9jfAeK3mdpkbsbKl698kFNKoHBvdpjjQeFUzGHKT1RXT8tidRM58/Ty/DWncRcQuhTS4SQNYRgrXgdIrEZ1ieVEoYfB3SrwcGKTI44zE3nRxudBeCnh/F/BSVW+Hq9lGSVI2xRg11Txx8KR43r4yr0kY8HXgVHJZtTDn5+AGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642680190; 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=x2+28yARsMBGoNNBZObngFgGHwW0iOq0F8K+hZixmwk=; b=TlEes53649pn4qDrYU5oimUKVpm658OD6HbIXKItQ+xFBfmiewBpzK6xgEWw6GabwQ4qTks3bt+nj39AB+NKkmhyL/0JuMvGqj9nudoI2si4iSFpAcAM8TaSYsbD19z65/AjjfDimooqPV88EZfr1GhrpZAXqaRZbON9X/0wh2k= 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 1642680190492162.4400514602852; Thu, 20 Jan 2022 04:03:10 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.259040.446728 (Exim 4.92) (envelope-from ) id 1nAW9L-0007jd-1S; Thu, 20 Jan 2022 12:02:43 +0000 Received: by outflank-mailman (output) from mailman id 259040.446728; Thu, 20 Jan 2022 12:02:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nAW9K-0007hL-RN; Thu, 20 Jan 2022 12:02:42 +0000 Received: by outflank-mailman (input) for mailman id 259040; Thu, 20 Jan 2022 12:02:42 +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 1nAW9J-0007aq-So for xen-devel@lists.xenproject.org; Thu, 20 Jan 2022 12:02:41 +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 dd6fc94d-79e8-11ec-bc18-3156f6d857e4; Thu, 20 Jan 2022 13:02:39 +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 7AC18210F4; Thu, 20 Jan 2022 12:02:39 +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 4E6FD13B51; Thu, 20 Jan 2022 12:02:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qOi8EV9P6WF5UwAAMHmgww (envelope-from ); Thu, 20 Jan 2022 12:02:39 +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: dd6fc94d-79e8-11ec-bc18-3156f6d857e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1642680159; 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=x2+28yARsMBGoNNBZObngFgGHwW0iOq0F8K+hZixmwk=; b=o1CHZg1fBbqBSi6K3Vuu2Q6zcwr+Zs+zXgskdbZ/rD66srJMGZKXOdpj6gvlrUFiCooc17 tq7xFKusJscxHCaJmOjRtTObRkEaroavgZ9N8nsmqqtv9wGfvSowm+6o15mgQirpsfKdBW VJSV2N4kLz6oZBVthuUtA818AwsfGY8= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH 1/3] tools/xenstore: merge hashtable_private.h into hashtable.c Date: Thu, 20 Jan 2022 13:02:34 +0100 Message-Id: <20220120120236.13826-2-jgross@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220120120236.13826-1-jgross@suse.com> References: <20220120120236.13826-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1642680192523100001 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 Fri May 3 04:23:40 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=1642680192; cv=none; d=zohomail.com; s=zohoarc; b=GfIE5VWtB7WmIE2EKWSIBtbe6q9mnMs9QDPHlwf23S6Ik7BtDTmdVGBIakTS3B8R0PV0aIjU3/yAYprBqttBwbBTVoE2CIYGNBN7n+77sB9Y3Lb4pZb+K92OHv0iRBPl0tbOz8eHJWjJI2YX27nxTOODzHVm4oe8flYgpVKJR3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642680192; 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=CfrxD3KienyM7pfSnYwZtHjuwO56/KVSIOkTvQ20tA0=; b=L5zCxBjA7icje+m401S68Tf9hntVi0U1VFESWUqzxRQthZ1t8u12KA2TCqypuh4xSpkEc8SjKppmMSICH/JfEXRTy/WtroC48DCVPimWnhT5ywP0oF/RLXlai/4z6woRJdXAXPcvLmYK2Dsik8F3YMc4tHc3UZLAFWwCowm+JAM= 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 1642680192210115.4320216239073; Thu, 20 Jan 2022 04:03:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.259039.446722 (Exim 4.92) (envelope-from ) id 1nAW9K-0007dX-Oi; Thu, 20 Jan 2022 12:02:42 +0000 Received: by outflank-mailman (output) from mailman id 259039.446722; Thu, 20 Jan 2022 12:02:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nAW9K-0007d4-Ik; Thu, 20 Jan 2022 12:02:42 +0000 Received: by outflank-mailman (input) for mailman id 259039; Thu, 20 Jan 2022 12:02:41 +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 1nAW9J-0007ap-Fy for xen-devel@lists.xenproject.org; Thu, 20 Jan 2022 12:02:41 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id dd852dac-79e8-11ec-8fa7-f31e035a9116; Thu, 20 Jan 2022 13:02:39 +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 AABF61F3A9; Thu, 20 Jan 2022 12:02:39 +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 7FCD613B51; Thu, 20 Jan 2022 12:02:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id QCPyHV9P6WF5UwAAMHmgww (envelope-from ); Thu, 20 Jan 2022 12:02:39 +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: dd852dac-79e8-11ec-8fa7-f31e035a9116 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1642680159; 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=CfrxD3KienyM7pfSnYwZtHjuwO56/KVSIOkTvQ20tA0=; b=QsjSp3f9qxpoAl3MSrZV4OTsuhqapl0c2HpKntCjxdFTn1PZ7lnU0YaXx96zA+kqRG7su4 jf8uXkkoxpzfUZdqALbbB2Txco0cFFysTIojS6pqVf6gq6BN8Nyuwk3wCpW+zYxCT/gEjZ MBxmFlEqISGoW3GWPXw/W0Zlh5tLack= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH 2/3] tools/xenstore: fix hashtable_expand() zeroing new area Date: Thu, 20 Jan 2022 13:02:35 +0100 Message-Id: <20220120120236.13826-3-jgross@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220120120236.13826-1-jgross@suse.com> References: <20220120120236.13826-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1642680194656100003 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 Fri May 3 04:23:40 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=1642680194; cv=none; d=zohomail.com; s=zohoarc; b=SXQvwHuVZbsJY+cuK0XibRM/lSlL+/C4h1+WNRUbj1xxGMKdIkYr8hUfJMX/R/hBP25FcBSQE2JGo4v8+Ggh0nEXy5t/Xuq/9igEx7krug7NWSXTf9GoIRMhXa+ZCp0EVy7/O1jxy4fT/ECNhm4z4CfM69l+Ag9LLYCrYjZH9iY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642680194; 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=4wm40Alsny5wX/z5bwEa7HgretT0TQtgGgtRQ8V8VBY=; b=VkIMKFnYBKpLVPpN45MVUCQCbxkB/7jWdkT2iKQTD5If6wdCR1vILr14hEIfU9BTyLAejDMV5QrV1uioePSNrgRC5sl7Suaopd+QlTG+GTtmnAU5WL6im3rfuPWrUVhVQDqZ75dksuXDcRPGV9/NkhEKcbVn4AgMzSrpkkwZQUA= 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 1642680194857676.1296141122258; Thu, 20 Jan 2022 04:03:14 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.259041.446749 (Exim 4.92) (envelope-from ) id 1nAW9M-0008GE-DP; Thu, 20 Jan 2022 12:02:44 +0000 Received: by outflank-mailman (output) from mailman id 259041.446749; Thu, 20 Jan 2022 12:02:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nAW9M-0008Fi-4y; Thu, 20 Jan 2022 12:02:44 +0000 Received: by outflank-mailman (input) for mailman id 259041; Thu, 20 Jan 2022 12:02:42 +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 1nAW9K-0007aq-DS for xen-devel@lists.xenproject.org; Thu, 20 Jan 2022 12:02:42 +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 ddb15cdf-79e8-11ec-bc18-3156f6d857e4; Thu, 20 Jan 2022 13:02:40 +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 DD3ED210FA; Thu, 20 Jan 2022 12:02:39 +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 B0C7A13B51; Thu, 20 Jan 2022 12:02:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sFvjKV9P6WF5UwAAMHmgww (envelope-from ); Thu, 20 Jan 2022 12:02:39 +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: ddb15cdf-79e8-11ec-bc18-3156f6d857e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1642680159; 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=4wm40Alsny5wX/z5bwEa7HgretT0TQtgGgtRQ8V8VBY=; b=Zjw18zdEMPiJnP2Fud4sGP8xYZciGwKS4XM18OxVGyk+rEq9gZWW0Shs5X71YfIS6uzkNg sYrSTH1fftPapS3m/Gem0wcgbVI6XDUMA/cJ26wMpM+TcWkGQ/lf+FO90+6zp3HbW+pcrc Z0YYO2kTtpm1DoTI8dnKhbC66y85RNA= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH 3/3] tools/xenstore: drop DEFINE_HASHTABLE_* macros and usage intro Date: Thu, 20 Jan 2022 13:02:36 +0100 Message-Id: <20220120120236.13826-4-jgross@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220120120236.13826-1-jgross@suse.com> References: <20220120120236.13826-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1642680195830100005 Content-Type: text/plain; charset="utf-8" The DEFINE_HASHTABLE_* macros are used nowhere, so drop them. The usage intro isn't needed either with those macros dropped. Signed-off-by: Juergen Gross --- 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