From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359364; cv=none; d=zohomail.com; s=zohoarc; b=FdNKWZklkVACF309gTg0WMZMIIxR9eRxARX7FNVHJZ8RKnReSvtKaTluE8JHeENebT/lpPpyWJZnbs8cmxsCij2v/TcTv8340oKyZrdsuos1FCcXwJ7wErKny8oY7QMP+6sNV4mFlHRD6VeCVYQVMqPJVh2S97+eK7qeStKSNJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359364; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qzzvZxraEhP+TWkqxL2cg4XK9cxkyWFNzcPlWcd59ck=; b=DCfAxUsmFNHyAet1uNgZuCH000xkr2CbwTkGx1riCvDkflpSBiRNkVtPWJpGEgfR64+4HvKBfpGdTU+EDXf37YRq3oS79ssGQR4iQcKssibkM75gXRsRueveKlCXQuzVy1K4Td1sWy4qSb59eYE+6zjruvUUvMJ6NV2yWE2NCUg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603359364362216.1570520923475; Thu, 22 Oct 2020 02:36:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-mlUenTw6NQKOj09d-qE9oQ-1; Thu, 22 Oct 2020 05:35:46 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D18B879525; Thu, 22 Oct 2020 09:35:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7CD3F6EF75; Thu, 22 Oct 2020 09:35:41 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 499E718184AE; Thu, 22 Oct 2020 09:35:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZCBB024440 for ; Thu, 22 Oct 2020 05:35:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id B28D25B4A3; Thu, 22 Oct 2020 09:35:12 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC6BA5B4B3 for ; Thu, 22 Oct 2020 09:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359363; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qzzvZxraEhP+TWkqxL2cg4XK9cxkyWFNzcPlWcd59ck=; b=h53hC6SFd9ByjKRIP78B0rSNorKS/RwdPMlTFdkvSCusyC4Y06bQue+S4f593mZuraD4CI tfvyVqcwuQxdfZZ6L984CjvKdOuyQNhd5UXm+muXR9BMenlByHzXfABi3FojMSo92ElN0X PfT8sxS8ef31+1F9zNOSTTkqULt0adM= X-MC-Unique: mlUenTw6NQKOj09d-qE9oQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/15] virCgroupKillRecursive: Return -1 on failure condition Date: Thu, 22 Oct 2020 11:34:52 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" virCgroupKillRecursive sneakily initializes 'ret' to 0 rather than the usual -1. 401030499bf moved an error condition but didn't actually modify 'ret' return the proper error code. Fixes: 401030499bf Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/vircgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index d408e3366f..5f4cb01bc0 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -2591,6 +2591,7 @@ virCgroupKillRecursive(virCgroupPtr group, int signum) if (!backends || !backendAvailable) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no cgroup backend available")); + ret =3D -1; goto cleanup; } --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359356; cv=none; d=zohomail.com; s=zohoarc; b=mpZus3eI2FNSoesmnTe/UnhX8QELvfryExwKtbllu0CetMM2qG/fD1VY75H4N29rACJhqxjVZfBxIWNONKyU/kNsDMYV+mj22aJ5/elkWu/txjXKkWXwXccUXwAgrSMLqlmTMmmxUInZhTfXrZdHIVIrNIIdJL8dtsPSaceP85c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359356; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EcSPAD2VczFoSUMoTrvcyqo1ywzX6szJDbOg3tEuczM=; b=CScARH13VRrRH8fmKclp/5rqhT6G4JlLrHydNpkTwkk+wiY583z8i20+Q/EuySr1TeieanoKV8BAW/0FNJPY9Yu37oCtzZuKMl0AYN0AZi65ehuvgfV7ePXO3RnrKf6NGGK6CWx6pBRjChT/ESj6wBVF1mX98uOUz3uo5BzrQ2k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603359356296369.57714259359034; Thu, 22 Oct 2020 02:35:56 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-CgsYlLBrMDCVQXfQYl1EGw-1; Thu, 22 Oct 2020 05:35:52 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9EBA11009E38; Thu, 22 Oct 2020 09:35:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 79FC05C3E2; Thu, 22 Oct 2020 09:35:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4411B181A06B; Thu, 22 Oct 2020 09:35:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZDrg024448 for ; Thu, 22 Oct 2020 05:35:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id C0E8E5B4A3; Thu, 22 Oct 2020 09:35:13 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 267D15B4B3 for ; Thu, 22 Oct 2020 09:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359354; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=EcSPAD2VczFoSUMoTrvcyqo1ywzX6szJDbOg3tEuczM=; b=SCZP7cKHawOC/dtDukPC+qA1xFm2u58UxVzFhY76XOa/FHQVM+tJx8SSoAyFRijJXvljWr TtKoTbAxfWsHHUGo+X0YLysA0iovYaSgQ/FAXQXDtWx+BXJIWKIJBC5NgmqCG9FyrKQeCy A04ItG9gMf0imAmLnmNU7j28mLeb2Yk= X-MC-Unique: CgsYlLBrMDCVQXfQYl1EGw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/15] util: virhash: Remove virHashTableSize Date: Thu, 22 Oct 2020 11:34:53 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It's used only in one place in tests which isn't even automatically evaluated. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/libvirt_private.syms | 1 - src/util/virhash.c | 17 ----------------- src/util/virhash.h | 1 - tests/virhashtest.c | 6 ------ 4 files changed, 25 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b2d786409b..79c8403208 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2213,7 +2213,6 @@ virHashRemoveSet; virHashSearch; virHashSize; virHashSteal; -virHashTableSize; virHashUpdateEntry; virHashValueFree; diff --git a/src/util/virhash.c b/src/util/virhash.c index 4b503a0313..7dd2d9f81d 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -549,23 +549,6 @@ virHashSize(const virHashTable *table) return table->nbElems; } -/** - * virHashTableSize: - * @table: the hash table - * - * Query the size of the hash @table, i.e., number of buckets in the table. - * - * Returns the number of keys in the hash table or - * -1 in case of error - */ -ssize_t -virHashTableSize(const virHashTable *table) -{ - if (table =3D=3D NULL) - return -1; - return table->size; -} - /** * virHashRemoveEntry: diff --git a/src/util/virhash.h b/src/util/virhash.h index cb59fb639b..37853aba36 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -125,7 +125,6 @@ virHashTablePtr virHashCreateFull(ssize_t size, virHashKeyFree keyFree); void virHashFree(virHashTablePtr table); ssize_t virHashSize(const virHashTable *table); -ssize_t virHashTableSize(const virHashTable *table); /* * Add a new entry to the hash table. diff --git a/tests/virhashtest.c b/tests/virhashtest.c index af30791241..7b1b8dd38c 100644 --- a/tests/virhashtest.c +++ b/tests/virhashtest.c @@ -27,16 +27,10 @@ testHashInit(int size) * collision list in the same order as in the uuids array */ for (i =3D G_N_ELEMENTS(uuids) - 1; i >=3D 0; i--) { - ssize_t oldsize =3D virHashTableSize(hash); if (virHashAddEntry(hash, uuids[i], (void *) uuids[i]) < 0) { virHashFree(hash); return NULL; } - - if (virHashTableSize(hash) !=3D oldsize) { - VIR_TEST_DEBUG("hash grown from %zu to %zu", - (size_t)oldsize, (size_t)virHashTableSize(hash)); - } } for (i =3D 0; i < G_N_ELEMENTS(uuids); i++) { --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359328; cv=none; d=zohomail.com; s=zohoarc; b=BhSjoPCZR6j9axSIWa+9R0jnhn81s02bGsZpBws8fi7pIqtYa6+B36sE1lSwxM8z4UwKcpNpBOH9SMBOMMibJIEgmUTfQUabDZjDa6e3hHv3Zn/zMOY3hpHGqQPgusfXvwPc8uf6zc4QzTNAgG8rBiK8WTqpI7TLQmqQG0mSa6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359328; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vFLGOZDveqMU0jO8oX+V+u9eggN4134oT1Kiys7xxGo=; b=N8lhPl/LLxWFdSBHZgstahUmwoKMR6fUf7WfWv6hB7cqDSdFGe1WbNNkzkisC2Fe+QI2QOhOZXJyzQG5yQap7r/bBfxioAv5q75LbSO06+NzKYqd2K5n7jpXBiafxktlzCXKR12cEFP6IXVuPTp/in5q47WXhqaiy1zP1Znpu/g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603359328514217.9733902159096; Thu, 22 Oct 2020 02:35:28 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-SLbEU6KAPBO7ngh5NpvJ0Q-1; Thu, 22 Oct 2020 05:35:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 206881009E22; Thu, 22 Oct 2020 09:35:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C774210013D0; Thu, 22 Oct 2020 09:35:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9083F180B65D; Thu, 22 Oct 2020 09:35:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZEZM024454 for ; Thu, 22 Oct 2020 05:35:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id DC6D85B4B2; Thu, 22 Oct 2020 09:35:14 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36C365B4A3 for ; Thu, 22 Oct 2020 09:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359327; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vFLGOZDveqMU0jO8oX+V+u9eggN4134oT1Kiys7xxGo=; b=Gxgp0IkOKH41btzNp09QFmiBvLN1Sz8ob74Z0Ap6FwqVBkluB9mu5pXZoU5SSbmHBVHehr Brei2s+xPR1KF+nccgwbWXol/RYnh9IMrjlBFKKpIFnxhse/DOq+O23jDOCvoCbR6lZldA bxvMJK1hNRrO+bwThmQ9yXtbvuevvqY= X-MC-Unique: SLbEU6KAPBO7ngh5NpvJ0Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/15] util: cgroup: Use GHashTable instead of virHashTable Date: Thu, 22 Oct 2020 11:34:54 +0200 Message-Id: <0eb3562473f926182064541054086a9a3c96ff38.1603358617.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Rewrite using GHashTable which already has interfaces for using a number as hash key. Glib's implementation doesn't copy the key by default, so we need to allocate it, but overal the interface is more suited for this case. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/vircgroup.c | 61 ++++++++----------------------------- src/util/vircgroupbackend.h | 3 +- src/util/vircgrouppriv.h | 2 +- src/util/vircgroupv1.c | 2 +- src/util/vircgroupv2.c | 2 +- 5 files changed, 17 insertions(+), 53 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 5f4cb01bc0..b74ec1a8fa 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -42,7 +42,6 @@ #include "virlog.h" #include "virfile.h" #include "virhash.h" -#include "virhashcode.h" #include "virstring.h" #include "virsystemd.h" #include "virtypedparam.h" @@ -2382,7 +2381,7 @@ virCgroupRemove(virCgroupPtr group) static int virCgroupKillInternal(virCgroupPtr group, int signum, - virHashTablePtr pids, + GHashTable *pids, int controller, const char *taskFile) { @@ -2415,8 +2414,9 @@ virCgroupKillInternal(virCgroupPtr group, goto cleanup; } else { while (!feof(fp)) { - long pid_value; - if (fscanf(fp, "%ld", &pid_value) !=3D 1) { + g_autofree long long *pid_value =3D g_new0(long long, 1); + + if (fscanf(fp, "%lld", pid_value) !=3D 1) { if (feof(fp)) break; virReportSystemError(errno, @@ -2424,16 +2424,17 @@ virCgroupKillInternal(virCgroupPtr group, keypath); goto cleanup; } - if (virHashLookup(pids, (void*)pid_value)) + + if (g_hash_table_lookup(pids, pid_value)) continue; - VIR_DEBUG("pid=3D%ld", pid_value); + VIR_DEBUG("pid=3D%lld", *pid_value); /* Cgroups is a Linux concept, so this cast is safe. */ - if (kill((pid_t)pid_value, signum) < 0) { + if (kill((pid_t)*pid_value, signum) < 0) { if (errno !=3D ESRCH) { virReportSystemError(errno, - _("Failed to kill process %ld= "), - pid_value); + _("Failed to kill process %ll= d"), + *pid_value); goto cleanup; } /* Leave RC =3D=3D 0 since we didn't kill one */ @@ -2442,7 +2443,7 @@ virCgroupKillInternal(virCgroupPtr group, done =3D false; } - ignore_value(virHashAddEntry(pids, (void*)pid_value, (void= *)1)); + g_hash_table_add(pids, g_steal_pointer(&pid_value)); } VIR_FORCE_FCLOSE(fp); } @@ -2458,39 +2459,10 @@ virCgroupKillInternal(virCgroupPtr group, } -static uint32_t -virCgroupPidCode(const void *name, uint32_t seed) -{ - long pid_value =3D (long)(intptr_t)name; - return virHashCodeGen(&pid_value, sizeof(pid_value), seed); -} - - -static bool -virCgroupPidEqual(const void *namea, const void *nameb) -{ - return namea =3D=3D nameb; -} - - -static void * -virCgroupPidCopy(const void *name) -{ - return (void*)name; -} - - -static char * -virCgroupPidPrintHuman(const void *name) -{ - return g_strdup_printf("%ld", (const long)name); -} - - int virCgroupKillRecursiveInternal(virCgroupPtr group, int signum, - virHashTablePtr pids, + GHashTable *pids, int controller, const char *taskFile, bool dormdir) @@ -2565,13 +2537,7 @@ virCgroupKillRecursive(virCgroupPtr group, int signu= m) size_t i; bool backendAvailable =3D false; virCgroupBackendPtr *backends =3D virCgroupBackendGetAll(); - virHashTablePtr pids =3D virHashCreateFull(100, - NULL, - virCgroupPidCode, - virCgroupPidEqual, - virCgroupPidCopy, - virCgroupPidPrintHuman, - NULL); + g_autoptr(GHashTable) pids =3D g_hash_table_new_full(g_int64_hash, g_i= nt64_equal, g_free, NULL); VIR_DEBUG("group=3D%p path=3D%s signum=3D%d", group, group->path, sign= um); @@ -2596,7 +2562,6 @@ virCgroupKillRecursive(virCgroupPtr group, int signum) } cleanup: - virHashFree(pids); return ret; } diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index bcbe435d78..f677157a91 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -23,7 +23,6 @@ #include "internal.h" #include "vircgroup.h" -#include "virhash.h" #define CGROUP_MAX_VAL 512 @@ -136,7 +135,7 @@ typedef int typedef int (*virCgroupKillRecursiveCB)(virCgroupPtr group, int signum, - virHashTablePtr pids); + GHashTable *pids); typedef int (*virCgroupBindMountCB)(virCgroupPtr group, diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h index f2a80aeb82..f85a36efdb 100644 --- a/src/util/vircgrouppriv.h +++ b/src/util/vircgrouppriv.h @@ -136,7 +136,7 @@ int virCgroupRemoveRecursively(char *grppath); int virCgroupKillRecursiveInternal(virCgroupPtr group, int signum, - virHashTablePtr pids, + GHashTable *pids, int controller, const char *taskFile, bool dormdir); diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index a42b7750f9..91c1c4d4b1 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -752,7 +752,7 @@ virCgroupV1HasEmptyTasks(virCgroupPtr cgroup, static int virCgroupV1KillRecursive(virCgroupPtr group, int signum, - virHashTablePtr pids) + GHashTable *pids) { int controller =3D virCgroupV1GetAnyController(group); diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index ddbe3d6663..285b7675d9 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -533,7 +533,7 @@ virCgroupV2HasEmptyTasks(virCgroupPtr cgroup, static int virCgroupV2KillRecursive(virCgroupPtr group, int signum, - virHashTablePtr pids) + GHashTable *pids) { int controller =3D virCgroupV2GetAnyController(group); --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359328; cv=none; d=zohomail.com; s=zohoarc; b=ke/xW2+dsfgfqZwGo1a4BHyRAhPcfMKz40hlVw3G16vt2kNNTTATukjB0qIzrV2r2/qfQIxp4kUl5+IsoNCzDiZXvBq1YTSpHRkWNK2AKNuK7c4FszafQgZ7pCqbarSIjHxNr3/WKdXUj0H9wYCFYG2raGEURldmUZCUNaMw9mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359328; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aoOZN3GR1Aiv1pARW5BowhDcasGqcwtyBBf8FvupENo=; b=FHtEnZrETvVDG5EU53dXYPrCGReFAQEyRFVQgAkcf3PxqTfi+/5UfNR6RL51+6Mfmj4ib3+1iR3+0ai+AzSyFfoS348p7SrfMg4dEBC6V6LIX/Op36o3Q824JiRUTRkWe59Gv6f+29Jj5CChVkhwLXM52nQIb/n0G5tIWSITLiQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603359328752724.5595063659964; Thu, 22 Oct 2020 02:35:28 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-MFdPXwA4MpO0TuUd7yh_Vw-1; Thu, 22 Oct 2020 05:35:24 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21F005F9CC; Thu, 22 Oct 2020 09:35:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D8DF219C4F; Thu, 22 Oct 2020 09:35:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 980F0180B791; Thu, 22 Oct 2020 09:35:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZGJo024469 for ; Thu, 22 Oct 2020 05:35:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id F2FB65B4A8; Thu, 22 Oct 2020 09:35:15 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D4515B4A3 for ; Thu, 22 Oct 2020 09:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359326; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aoOZN3GR1Aiv1pARW5BowhDcasGqcwtyBBf8FvupENo=; b=KDfLsI/5Tq9pdgcnA6gw20poX1NChwQgHGHaNQtUj+fYGPxPNe7LelZ0LBPU7Q6CylGMv2 BibPwH9tfcHF0G/kQOrslkZ/JGOxvjyyHRjFM7UpvV36JTAaBQKDYYbe6NlzbX3b4SwBdx PWaP1BxuUCftRNSSYr05NINmyDlsveY= X-MC-Unique: MFdPXwA4MpO0TuUd7yh_Vw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/15] virCgroupKillRecursive: Refactor cleanup Date: Thu, 22 Oct 2020 11:34:55 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Remove 'cleanup' label and simplify remembering of the returned value from the callback. Signed-off-by: Peter Krempa --- src/util/vircgroup.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index b74ec1a8fa..dafc6c98c0 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -2532,8 +2532,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, int virCgroupKillRecursive(virCgroupPtr group, int signum) { - int ret =3D 0; - int rc; + int ret =3D -1; size_t i; bool backendAvailable =3D false; virCgroupBackendPtr *backends =3D virCgroupBackendGetAll(); @@ -2544,24 +2543,17 @@ virCgroupKillRecursive(virCgroupPtr group, int sign= um) for (i =3D 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) { if (backends && backends[i] && backends[i]->available()) { backendAvailable =3D true; - rc =3D backends[i]->killRecursive(group, signum, pids); - if (rc < 0) { - ret =3D -1; - goto cleanup; - } - if (rc > 0) - ret =3D rc; + if ((ret =3D backends[i]->killRecursive(group, signum, pids)) = < 0) + return -1; } } if (!backends || !backendAvailable) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no cgroup backend available")); - ret =3D -1; - goto cleanup; + return -1; } - cleanup: return ret; } --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359340; cv=none; d=zohomail.com; s=zohoarc; b=g0COJ3fGrcArZ6QRdsZjG/4HFiyGce5RTTnlTwPUr5WnTE+R5tdg/4jXpj5G0n9/M8zWRXHus/94kQqinywoIRB5vRUrQASQDrYsyvdp9INoAlgikfnlH81uG0xfEmMwcc95ItmzZW6LmJgOVCd1Mbfc7Qe0rGlG2GHZ4P+5uZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359340; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2Z6lRaR6x8ibkuWB+wIVNuWuTDIwT5bcCgYE1RG1V78=; b=LUKUjayQDvFskoa5e58WHZE1EXsoZfezbYoWCHKsZW4ntNOKU4lhb9Sjx8RMj4+o0Tuf+zuSHX+jpsvL8gF+YXyhZFAucP1eOmeHLvRCPfYv7+PHPvwZQcU4uMglTiXS5ndVsnOnVYlpRqvx0ywOw1GhrfIxNP4UdA8D3BNifX0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603359340151558.6470642085005; Thu, 22 Oct 2020 02:35:40 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-NlMWDvjwNaaFJUsXNjKzxA-1; Thu, 22 Oct 2020 05:35:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2AD585F9CC; Thu, 22 Oct 2020 09:35:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06DEC60C15; Thu, 22 Oct 2020 09:35:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C73A8922F4; Thu, 22 Oct 2020 09:35:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZHsv024480 for ; Thu, 22 Oct 2020 05:35:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 232575B4A8; Thu, 22 Oct 2020 09:35:17 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 696F15B4A3 for ; Thu, 22 Oct 2020 09:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359339; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2Z6lRaR6x8ibkuWB+wIVNuWuTDIwT5bcCgYE1RG1V78=; b=gm8d6zTQiE+DBOKh3Kks0X17KXlEz/NnPNjEo42umc2lS+Pr0RzTEEthwIJAy3Xsc8Pefb 7heK7Q/+2nLvF+MwO628FleMjBbCHyBZT0q41+iK3g9mVqVisHfbSEKd/6DxfyymQjOsJ3 Ojx8G/4EBiq9qv/++2ghfSpjZ8OwlGE= X-MC-Unique: NlMWDvjwNaaFJUsXNjKzxA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/15] conf: domain_addr: Refactor hash usage in zpci reservation code Date: Thu, 22 Oct 2020 11:34:56 +0200 Message-Id: <5622545f013c590ca9d87ca29eb7f8f280f3c495.1603358617.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Rewrite using GHashTable which already has interfaces for using a number as hash key. Signed-off-by: Peter Krempa Reviewed-by: Bjoern Walk Reviewed-by: Pavel Hrdina --- src/conf/domain_addr.c | 123 +++++++++-------------------------------- src/conf/domain_addr.h | 4 +- 2 files changed, 27 insertions(+), 100 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index c7419916aa..4e47c2547c 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -25,17 +25,18 @@ #include "virlog.h" #include "virstring.h" #include "domain_addr.h" -#include "virhashcode.h" #define VIR_FROM_THIS VIR_FROM_DOMAIN VIR_LOG_INIT("conf.domain_addr"); static int -virDomainZPCIAddressReserveId(virHashTablePtr set, +virDomainZPCIAddressReserveId(GHashTable *set, virZPCIDeviceAddressID *id, const char *name) { + int *idval; + if (!id->isSet) { virReportError(VIR_ERR_INTERNAL_ERROR, _("No zPCI %s to reserve"), @@ -43,26 +44,24 @@ virDomainZPCIAddressReserveId(virHashTablePtr set, return -1; } - if (virHashLookup(set, &id->value)) { + if (g_hash_table_lookup(set, &id->value)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("zPCI %s %o is already reserved"), name, id->value); return -1; } - if (virHashAddEntry(set, &id->value, (void*)1) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to reserve %s %o"), - name, id->value); - return -1; - } + idval =3D g_new0(int, 1); + *idval =3D (int) id->value; + + g_hash_table_add(set, idval); return 0; } static int -virDomainZPCIAddressReserveUid(virHashTablePtr set, +virDomainZPCIAddressReserveUid(GHashTable *set, virZPCIDeviceAddressPtr addr) { return virDomainZPCIAddressReserveId(set, &addr->uid, "uid"); @@ -70,7 +69,7 @@ virDomainZPCIAddressReserveUid(virHashTablePtr set, static int -virDomainZPCIAddressReserveFid(virHashTablePtr set, +virDomainZPCIAddressReserveFid(GHashTable *set, virZPCIDeviceAddressPtr addr) { return virDomainZPCIAddressReserveId(set, &addr->fid, "fid"); @@ -78,7 +77,7 @@ virDomainZPCIAddressReserveFid(virHashTablePtr set, static int -virDomainZPCIAddressAssignId(virHashTablePtr set, +virDomainZPCIAddressAssignId(GHashTable *set, virZPCIDeviceAddressID *id, unsigned int min, unsigned int max, @@ -87,7 +86,7 @@ virDomainZPCIAddressAssignId(virHashTablePtr set, if (id->isSet) return 0; - while (virHashLookup(set, &min)) { + while (g_hash_table_lookup(set, &min)) { if (min =3D=3D max) { virReportError(VIR_ERR_INTERNAL_ERROR, _("There is no more free %s."), @@ -105,7 +104,7 @@ virDomainZPCIAddressAssignId(virHashTablePtr set, static int -virDomainZPCIAddressAssignUid(virHashTablePtr set, +virDomainZPCIAddressAssignUid(GHashTable *set, virZPCIDeviceAddressPtr addr) { return virDomainZPCIAddressAssignId(set, &addr->uid, 1, @@ -114,7 +113,7 @@ virDomainZPCIAddressAssignUid(virHashTablePtr set, static int -virDomainZPCIAddressAssignFid(virHashTablePtr set, +virDomainZPCIAddressAssignFid(GHashTable *set, virZPCIDeviceAddressPtr addr) { return virDomainZPCIAddressAssignId(set, &addr->fid, 0, @@ -123,40 +122,19 @@ virDomainZPCIAddressAssignFid(virHashTablePtr set, static void -virDomainZPCIAddressReleaseId(virHashTablePtr set, - virZPCIDeviceAddressID *id, - const char *name) +virDomainZPCIAddressReleaseId(GHashTable *set, + virZPCIDeviceAddressID *id) { if (!id->isSet) return; - if (virHashRemoveEntry(set, &id->value) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Release %s %o failed"), - name, id->value); - } + g_hash_table_remove(set, &id->value); id->value =3D 0; id->isSet =3D false; } -static void -virDomainZPCIAddressReleaseUid(virHashTablePtr set, - virZPCIDeviceAddressPtr addr) -{ - virDomainZPCIAddressReleaseId(set, &addr->uid, "uid"); -} - - -static void -virDomainZPCIAddressReleaseFid(virHashTablePtr set, - virZPCIDeviceAddressPtr addr) -{ - virDomainZPCIAddressReleaseId(set, &addr->fid, "fid"); -} - - static void virDomainZPCIAddressReleaseIds(virDomainZPCIAddressIdsPtr zpciIds, virZPCIDeviceAddressPtr addr) @@ -164,8 +142,8 @@ virDomainZPCIAddressReleaseIds(virDomainZPCIAddressIdsP= tr zpciIds, if (!zpciIds) return; - virDomainZPCIAddressReleaseUid(zpciIds->uids, addr); - virDomainZPCIAddressReleaseFid(zpciIds->fids, addr); + virDomainZPCIAddressReleaseId(zpciIds->uids, &addr->uid); + virDomainZPCIAddressReleaseId(zpciIds->fids, &addr->fid); } @@ -183,7 +161,7 @@ virDomainZPCIAddressEnsureAddr(virDomainZPCIAddressIdsP= tr zpciIds, return -1; if (virDomainZPCIAddressReserveFid(zpciIds->fids, addr) < 0) { - virDomainZPCIAddressReleaseUid(zpciIds->uids, addr); + virDomainZPCIAddressReleaseId(zpciIds->uids, &addr->uid); return -1; } @@ -965,55 +943,15 @@ virDomainPCIAddressReleaseAddr(virDomainPCIAddressSet= Ptr addrs, } -static uint32_t -virZPCIAddrKeyCode(const void *name, - uint32_t seed) -{ - unsigned int value =3D *((unsigned int *)name); - return virHashCodeGen(&value, sizeof(value), seed); -} - - -static bool -virZPCIAddrKeyEqual(const void *namea, - const void *nameb) -{ - return *((unsigned int *)namea) =3D=3D *((unsigned int *)nameb); -} - - -static void * -virZPCIAddrKeyCopy(const void *name) -{ - unsigned int *copy =3D g_new0(unsigned int, 1); - - *copy =3D *((unsigned int *)name); - return (void *)copy; -} - - -static char * -virZPCIAddrKeyPrintHuman(const void *name) -{ - return g_strdup_printf("%u", *((unsigned int *)name)); -} - - -static void -virZPCIAddrKeyFree(void *name) -{ - VIR_FREE(name); -} - - static void virDomainPCIAddressSetExtensionFree(virDomainPCIAddressSetPtr addrs) { if (!addrs || !addrs->zpciIds) return; - virHashFree(addrs->zpciIds->uids); - virHashFree(addrs->zpciIds->fids); + g_clear_pointer(&addrs->zpciIds->uids, g_hash_table_unref); + g_clear_pointer(&addrs->zpciIds->fids, g_hash_table_unref); + VIR_FREE(addrs->zpciIds); } @@ -1028,19 +966,8 @@ virDomainPCIAddressSetExtensionAlloc(virDomainPCIAddr= essSetPtr addrs, addrs->zpciIds =3D g_new0(virDomainZPCIAddressIds, 1); - addrs->zpciIds->uids =3D virHashCreateFull(10, NULL, - virZPCIAddrKeyCode, - virZPCIAddrKeyEqual, - virZPCIAddrKeyCopy, - virZPCIAddrKeyPrintHuman, - virZPCIAddrKeyFree); - - addrs->zpciIds->fids =3D virHashCreateFull(10, NULL, - virZPCIAddrKeyCode, - virZPCIAddrKeyEqual, - virZPCIAddrKeyCopy, - virZPCIAddrKeyPrintHuman, - virZPCIAddrKeyFree); + addrs->zpciIds->uids =3D g_hash_table_new_full(g_int_hash, g_int_e= qual, g_free, NULL); + addrs->zpciIds->fids =3D g_hash_table_new_full(g_int_hash, g_int_e= qual, g_free, NULL); } return 0; diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index a0460b4030..77dd091fd3 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -115,8 +115,8 @@ typedef struct { typedef virDomainPCIAddressBus *virDomainPCIAddressBusPtr; typedef struct { - virHashTablePtr uids; - virHashTablePtr fids; + GHashTable *uids; + GHashTable *fids; } virDomainZPCIAddressIds; typedef virDomainZPCIAddressIds *virDomainZPCIAddressIdsPtr; --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359363; cv=none; d=zohomail.com; s=zohoarc; b=Sc+dC8swSYybodc2aBxwAjOKJoVzVMluNIXZjhp15Ps8QN5UHFlJmUnmDYfXjpwbMRwR3GSdY966o0Uzc50I6/bqmLJvsBr5mG5x6aP6JI+fTuzEOZiSWhZ5t3D8j20zTam/Bl7NVZBEFeLeSaRbcLROiAtdxJrh4Kg9cffT0O4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359363; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/yfpoIc3Pmf9jOmu6cNgyVaVrp4Spsj1sSSj38Ok5Mk=; b=Ouw1obtGBjrQv85i2mgXxUq5G6OG+t/KDmzt6l0BI64d5Z9RXQC1VpDbKjGKfr9E5CVH4O0aHZ/7tB2U/7+aSlFC/zsB3CH0kIT+nJdTJ3tkIRzq8nqXn82UxqdKm8tN720a9Mle5UIZdhUO4Qw7Zbdb0RU1eS4ZIy8lwzaKZMc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603359363609840.9475123671016; Thu, 22 Oct 2020 02:36:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-WF56OrwzNharOh0c0sG_1g-1; Thu, 22 Oct 2020 05:36:00 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D89F91084D72; Thu, 22 Oct 2020 09:35:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B338B5C22B; Thu, 22 Oct 2020 09:35:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7F2DE181A261; Thu, 22 Oct 2020 09:35:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZIct024488 for ; Thu, 22 Oct 2020 05:35:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 32A0B5B4B2; Thu, 22 Oct 2020 09:35:18 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9306E5B4A8 for ; Thu, 22 Oct 2020 09:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359362; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/yfpoIc3Pmf9jOmu6cNgyVaVrp4Spsj1sSSj38Ok5Mk=; b=UwEAGayd1oY9i1yUy7LoUDcqoAC7h02oO/JtEq5qSGH6u2WLNTP5l2lYo2gT6o1g3Dv253 Dm42mVG7/MZUxxJt5tfZS6LSnsEUjRQ6ioXbFhi3ZEbNt19GT8j9m83syHZQmJxBkPXuaP QDiA0EC1XK0bBRBPp5GSfh0NSSHan8w= X-MC-Unique: WF56OrwzNharOh0c0sG_1g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/15] virHashAtomicNew: Remove 'size' argument Date: Thu, 22 Oct 2020 11:34:57 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use 'virHashNew' internally which uses a default size. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_migration.c | 2 +- src/util/virhash.c | 5 ++--- src/util/virhash.h | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index e18216824c..2f5d61f8e7 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5743,7 +5743,7 @@ qemuMigrationDstErrorFree(void *data) int qemuMigrationDstErrorInit(virQEMUDriverPtr driver) { - driver->migrationErrors =3D virHashAtomicNew(64, qemuMigrationDstError= Free); + driver->migrationErrors =3D virHashAtomicNew(qemuMigrationDstErrorFree= ); if (driver->migrationErrors) return 0; else diff --git a/src/util/virhash.c b/src/util/virhash.c index 7dd2d9f81d..23e12e0255 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -212,8 +212,7 @@ virHashTablePtr virHashCreate(ssize_t size, virHashData= Free dataFree) virHashAtomicPtr -virHashAtomicNew(ssize_t size, - virHashDataFree dataFree) +virHashAtomicNew(virHashDataFree dataFree) { virHashAtomicPtr hash; @@ -223,7 +222,7 @@ virHashAtomicNew(ssize_t size, if (!(hash =3D virObjectLockableNew(virHashAtomicClass))) return NULL; - if (!(hash->hash =3D virHashCreate(size, dataFree))) { + if (!(hash->hash =3D virHashNew(dataFree))) { virObjectUnref(hash); return NULL; } diff --git a/src/util/virhash.h b/src/util/virhash.h index 37853aba36..baf92996a3 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -114,8 +114,7 @@ typedef void (*virHashKeyFree)(void *name); virHashTablePtr virHashNew(virHashDataFree dataFree); virHashTablePtr virHashCreate(ssize_t size, virHashDataFree dataFree); -virHashAtomicPtr virHashAtomicNew(ssize_t size, - virHashDataFree dataFree); +virHashAtomicPtr virHashAtomicNew(virHashDataFree dataFree); virHashTablePtr virHashCreateFull(ssize_t size, virHashDataFree dataFree, virHashKeyCode keyCode, --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359357; cv=none; d=zohomail.com; s=zohoarc; b=NZGIix6qx4t6Rhm8l0HNKw7EbYzlcghCiZ6nhOEZbtSA5Kzul8lVZHEUXNW5b+VdoC9nkuuMzj7LXLEFb6hjCQRdh7GNSrc/m7Bmj9lc8QgG+/17AmllkeFthCz1zDotpZkydCAMJYHU6KeeMV/yJD2HrT1USGt2n/aQzQApA90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359357; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dmJ91S6vcV+BD81dfJIrYbTLfOMhp7qlQ1J5iML7Awk=; b=lBA/INbtuQFOj3Id1xKkBbToAXVVpUdC+fJsirA60/uVcfYGYDO9tpx9HfmIgKMnrgzGdKhZnrcPvt882klGsi4MppnaWFz8T8by2gGCKr5kqrY3px4oiHpIViNHzpvMyxPR9MxTOef0QRUd68RkQ6YDJ0Jah4+b2sudx9qVbkU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603359357725881.3116986191792; Thu, 22 Oct 2020 02:35:57 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-72-WwUlaEqVN0CX3HbUOaqMmQ-1; Thu, 22 Oct 2020 05:35:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E7121009E30; Thu, 22 Oct 2020 09:35:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E3D86EF6C; Thu, 22 Oct 2020 09:35:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 267C2922F9; Thu, 22 Oct 2020 09:35:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZJoB024503 for ; Thu, 22 Oct 2020 05:35:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C3885B4A8; Thu, 22 Oct 2020 09:35:19 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 986785B4A3 for ; Thu, 22 Oct 2020 09:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359356; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dmJ91S6vcV+BD81dfJIrYbTLfOMhp7qlQ1J5iML7Awk=; b=Ur+HCDda8VZh/Aj7MAHtEvsc4o6jiRpa+dSbn4bF4glbhMJ0o1WtEODKEgvmssqNSKeRIV 81kCXaofCnTrG9FdjDpsQooqo03BG1k1vdzM6AXKhXKhLiRNbeEa0JfwUc0MBtjFHdCWTh dpeMjwQQMHXjvgPVXZbLXdm2r4up6n4= X-MC-Unique: WwUlaEqVN0CX3HbUOaqMmQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/15] conf: nwfilter: Replace 'virNWFilterHashTableCreate' with 'virHashNew' Date: Thu, 22 Oct 2020 11:34:58 +0200 Message-Id: <11b3fa0ec600ed7a4aab20cb59eb75d742f4fdca.1603358617.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Export the freeing function rather than having a wrapper for the hash creation function. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/conf/domain_nwfilter.c | 2 +- src/conf/nwfilter_ipaddrmap.c | 2 +- src/conf/nwfilter_params.c | 12 +++--------- src/conf/nwfilter_params.h | 2 +- src/conf/virnwfilterbindingdef.c | 2 +- src/libvirt_private.syms | 2 +- src/nwfilter/nwfilter_gentech_driver.c | 6 +++--- tests/nwfilterxml2firewalltest.c | 6 +++--- 8 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_nwfilter.c b/src/conf/domain_nwfilter.c index ef388d5d02..f32122b8a3 100644 --- a/src/conf/domain_nwfilter.c +++ b/src/conf/domain_nwfilter.c @@ -59,7 +59,7 @@ virNWFilterBindingDefForNet(const char *vmname, ret->filter =3D g_strdup(net->filter); - if (!(ret->filterparams =3D virNWFilterHashTableCreate(0))) + if (!(ret->filterparams =3D virHashNew(virNWFilterVarValueHashFree))) goto error; if (net->filterparams && diff --git a/src/conf/nwfilter_ipaddrmap.c b/src/conf/nwfilter_ipaddrmap.c index 672a58be3a..487e7f22bd 100644 --- a/src/conf/nwfilter_ipaddrmap.c +++ b/src/conf/nwfilter_ipaddrmap.c @@ -149,7 +149,7 @@ virNWFilterIPAddrMapGetIPAddr(const char *ifname) int virNWFilterIPAddrMapInit(void) { - ipAddressMap =3D virNWFilterHashTableCreate(0); + ipAddressMap =3D virHashNew(virNWFilterVarValueHashFree); if (!ipAddressMap) return -1; diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c index 1210079954..fd05b45ca3 100644 --- a/src/conf/nwfilter_params.c +++ b/src/conf/nwfilter_params.c @@ -606,19 +606,13 @@ virNWFilterVarCombIterGetVarValue(virNWFilterVarCombI= terPtr ci, return res; } -static void -hashDataFree(void *payload) +void +virNWFilterVarValueHashFree(void *payload) { virNWFilterVarValueFree(payload); } -virHashTablePtr -virNWFilterHashTableCreate(int n) -{ - return virHashCreate(n, hashDataFree); -} - struct addToTableStruct { virHashTablePtr target; int errOccurred; @@ -708,7 +702,7 @@ virNWFilterParseParamAttributes(xmlNodePtr cur) char *nam, *val; virNWFilterVarValuePtr value; - virHashTablePtr table =3D virNWFilterHashTableCreate(0); + virHashTablePtr table =3D virHashNew(virNWFilterVarValueHashFree); if (!table) return NULL; diff --git a/src/conf/nwfilter_params.h b/src/conf/nwfilter_params.h index d51f3f7f9f..4962a86864 100644 --- a/src/conf/nwfilter_params.h +++ b/src/conf/nwfilter_params.h @@ -52,6 +52,7 @@ virNWFilterVarValuePtr virNWFilterVarValueCreateSimple(ch= ar *); virNWFilterVarValuePtr virNWFilterVarValueCreateSimpleCopyValue(const char= *); virNWFilterVarValuePtr virNWFilterVarValueCopy(const virNWFilterVarValue *= ); void virNWFilterVarValueFree(virNWFilterVarValuePtr val); +void virNWFilterVarValueHashFree(void *payload); const char *virNWFilterVarValueGetSimple(const virNWFilterVarValue *val); const char *virNWFilterVarValueGetNthValue(const virNWFilterVarValue *val, unsigned int idx); @@ -67,7 +68,6 @@ int virNWFilterFormatParamAttributes(virBufferPtr buf, virHashTablePtr table, const char *filterref); -virHashTablePtr virNWFilterHashTableCreate(int n); int virNWFilterHashTablePutAll(virHashTablePtr src, virHashTablePtr dest); bool virNWFilterHashTableEqual(virHashTablePtr a, diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbinding= def.c index 81f8e72182..28c1c3938c 100644 --- a/src/conf/virnwfilterbindingdef.c +++ b/src/conf/virnwfilterbindingdef.c @@ -65,7 +65,7 @@ virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src) ret->filter =3D g_strdup(src->filter); - if (!(ret->filterparams =3D virNWFilterHashTableCreate(0))) + if (!(ret->filterparams =3D virHashNew(virNWFilterVarValueHashFree))) goto error; if (virNWFilterHashTablePutAll(src->filterparams, ret->filterparams) <= 0) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 79c8403208..4f9e7f6048 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -927,7 +927,6 @@ virNWFilterIPAddrMapShutdown; # conf/nwfilter_params.h -virNWFilterHashTableCreate; virNWFilterHashTableEqual; virNWFilterHashTablePutAll; virNWFilterVarAccessGetVarName; @@ -948,6 +947,7 @@ virNWFilterVarValueFree; virNWFilterVarValueGetCardinality; virNWFilterVarValueGetNthValue; virNWFilterVarValueGetSimple; +virNWFilterVarValueHashFree; # conf/object_event.h diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index c93f2ed18f..99d2c0fce4 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -199,7 +199,7 @@ static virHashTablePtr virNWFilterCreateVarsFrom(virHashTablePtr vars1, virHashTablePtr vars2) { - virHashTablePtr res =3D virNWFilterHashTableCreate(0); + virHashTablePtr res =3D virHashNew(virNWFilterVarValueHashFree); if (!res) return NULL; @@ -268,7 +268,7 @@ virNWFilterRuleDefToRuleInst(virNWFilterDefPtr def, ruleinst->chainPriority =3D def->chainPriority; ruleinst->def =3D rule; ruleinst->priority =3D rule->priority; - if (!(ruleinst->vars =3D virNWFilterHashTableCreate(0))) + if (!(ruleinst->vars =3D virHashNew(virNWFilterVarValueHashFree))) goto cleanup; if (virNWFilterHashTablePutAll(vars, ruleinst->vars) < 0) goto cleanup; @@ -516,7 +516,7 @@ virNWFilterDoInstantiate(virNWFilterTechDriverPtr techd= river, const char *learning; bool reportIP =3D false; - virHashTablePtr missing_vars =3D virNWFilterHashTableCreate(0); + virHashTablePtr missing_vars =3D virHashNew(virNWFilterVarValueHashFre= e); memset(&inst, 0, sizeof(inst)); diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.c index 755732487a..30f3dab97e 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -149,7 +149,7 @@ static virHashTablePtr virNWFilterCreateVarsFrom(virHashTablePtr vars1, virHashTablePtr vars2) { - virHashTablePtr res =3D virNWFilterHashTableCreate(0); + virHashTablePtr res =3D virHashNew(virNWFilterVarValueHashFree); if (!res) return NULL; @@ -215,7 +215,7 @@ virNWFilterRuleDefToRuleInst(virNWFilterDefPtr def, ruleinst->chainPriority =3D def->chainPriority; ruleinst->def =3D rule; ruleinst->priority =3D rule->priority; - if (!(ruleinst->vars =3D virNWFilterHashTableCreate(0))) + if (!(ruleinst->vars =3D virHashNew(virNWFilterVarValueHashFree))) goto cleanup; if (virNWFilterHashTablePutAll(vars, ruleinst->vars) < 0) goto cleanup; @@ -368,7 +368,7 @@ static int testCompareXMLToArgvFiles(const char *xml, { char *actualargv =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - virHashTablePtr vars =3D virNWFilterHashTableCreate(0); + virHashTablePtr vars =3D virHashNew(virNWFilterVarValueHashFree); virNWFilterInst inst; int ret =3D -1; --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359362; cv=none; d=zohomail.com; s=zohoarc; b=W22eRyy5+Jaj1IhDsMdIN/R11fTgzFx6GDa+hBcLfMgo/22oEoqKNTI8AEivpjWuliT3p/TR3Kq0iUpkdcEwv7gMxnwRFQriELO/h8fWSsFzr171N1Pd5sbfB0qb2pthyM6mE4Tv43GE4/UeO1ew9m3IQfUDJi+EFaPjSxdJmxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359362; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V425lll+DTivxz8w0y/g3rgFJ0hgJgMylHR9ZxYUdFg=; b=ZTqcoVWftcreE78yzrUnqirNRmIV+XAsteG3sBh41Z7JaKBZY84K8Gg7/6KK7zwLNaPzxeERHK661g0Nf1YhKBSTKAwYQwCgDoyVIeyxxGJcyAA6cY/EIy9BFnMKTiYFVrVV9a4pDKtG2C3Dy7M5FINzG5jfcfs7TH/+10TltVg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603359362502767.7405037171651; Thu, 22 Oct 2020 02:36:02 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-69-sQ8_l-6_MMG92m6u-_FF6Q-1; Thu, 22 Oct 2020 05:35:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AF3A1882FA8; Thu, 22 Oct 2020 09:35:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A8836EF6B; Thu, 22 Oct 2020 09:35:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 045B8181A07B; Thu, 22 Oct 2020 09:35:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZKrx024516 for ; Thu, 22 Oct 2020 05:35:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 84B665B4A3; Thu, 22 Oct 2020 09:35:20 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D40DD5B4C0 for ; Thu, 22 Oct 2020 09:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359361; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=V425lll+DTivxz8w0y/g3rgFJ0hgJgMylHR9ZxYUdFg=; b=gnkBtQz/2DHSO73HbP7PCPiA4ec/vP5+y/rm30cFSdGW/mu91N3KjgxDGNPu6dPfnNBlYw fKu4N5uhMTIKTBpxwJhKioaWU/ToCPSkD2vEurm2dHj06t8PfrotNNXNimKwf/J4trLyoG yiEbjpLTr8SzuW8V6m/yFt6IxM2EQNo= X-MC-Unique: sQ8_l-6_MMG92m6u-_FF6Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/15] tests: hash: Prepare for replacement of virHashCreate Date: Thu, 22 Oct 2020 11:34:59 +0200 Message-Id: <48dbe9a2c4858882de8399ee563fbc569551a08a.1603358617.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Most callers pass a random number. We have virHashNew which doesn't give the callers the option to configure the table. Since we are going to switch to virHashNew replace it in tests and remove multiple instances of the 'testHashGrow' case as it doesn't make sense with the new semantics. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- tests/virhashtest.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/tests/virhashtest.c b/tests/virhashtest.c index 7b1b8dd38c..bc93c07d1f 100644 --- a/tests/virhashtest.c +++ b/tests/virhashtest.c @@ -15,12 +15,12 @@ VIR_LOG_INIT("tests.hashtest"); static virHashTablePtr -testHashInit(int size) +testHashInit(void) { virHashTablePtr hash; ssize_t i; - if (!(hash =3D virHashCreate(size, NULL))) + if (!(hash =3D virHashNew(NULL))) return NULL; /* entries are added in reverse order so that they will be linked in @@ -83,13 +83,12 @@ struct testInfo { static int -testHashGrow(const void *data) +testHashGrow(const void *data G_GNUC_UNUSED) { - const struct testInfo *info =3D data; virHashTablePtr hash; int ret =3D -1; - if (!(hash =3D testHashInit(info->count))) + if (!(hash =3D testHashInit())) return -1; if (testHashCheckCount(hash, G_N_ELEMENTS(uuids)) < 0) @@ -111,7 +110,7 @@ testHashUpdate(const void *data G_GNUC_UNUSED) size_t i; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; for (i =3D 0; i < G_N_ELEMENTS(uuids_subset); i++) { @@ -149,7 +148,7 @@ testHashRemove(const void *data G_GNUC_UNUSED) size_t i; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; for (i =3D 0; i < G_N_ELEMENTS(uuids_subset); i++) { @@ -216,7 +215,7 @@ testHashRemoveForEach(const void *data) virHashTablePtr hash; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; if (virHashForEach(hash, (virHashIterator) info->data, hash)) { @@ -243,7 +242,7 @@ testHashSteal(const void *data G_GNUC_UNUSED) size_t i; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; for (i =3D 0; i < G_N_ELEMENTS(uuids_subset); i++) { @@ -297,7 +296,7 @@ testHashRemoveSet(const void *data G_GNUC_UNUSED) int rcount; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; /* seed the generator so that rand() provides reproducible sequence */ @@ -340,7 +339,7 @@ testHashSearch(const void *data G_GNUC_UNUSED) void *entry; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; entry =3D virHashSearch(hash, testHashSearchIter, NULL, NULL); @@ -544,15 +543,10 @@ mymain(void) testHash ## cmd ## data, \ testHashCount ## cmd ## data) -#define DO_TEST_COUNT(name, cmd, count) \ - DO_TEST_FULL(name "(" #count ")", cmd, NULL, count) - #define DO_TEST(name, cmd) \ DO_TEST_FULL(name, cmd, NULL, -1) - DO_TEST_COUNT("Grow", Grow, 1); - DO_TEST_COUNT("Grow", Grow, 10); - DO_TEST_COUNT("Grow", Grow, 42); + DO_TEST("Grow", Grow); DO_TEST("Update", Update); DO_TEST("Remove", Remove); DO_TEST_DATA("Remove in ForEach", RemoveForEach, Some); --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359337; cv=none; d=zohomail.com; s=zohoarc; b=MzTKdqAWuyHV3MvBqf8dQETyrn3ptAPQNlCNiFhb6NhM0O+1nZrEGsT/5paWjAT/0wLyLOuoN2+4x5aCio2m29AI7+ZdUN/eqfW0na+YfsF+WHH5YJJXIPTGh9XqFz4BnpoodkzAgeYorPu3xruFnJphhBHqlnS273HlNAoFp0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359337; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8TTTbFbmN30Rxp1wlb4oCwHzgaqR1RHZ7YpJROdTL9A=; b=HOa9e5TdzjgLB6rQeyVh1bpHTMZqPr2odPciUOzuTjfnIBCmfMNWz6ufArV1/mBmOlS1cw/EiftjtL+tn0xuzG1BzUI1zf5Wn/+e8yW4mcgW5bwo8WK5eM5W0Jw0h2DJ3j8RAM+ojVbvwQ613VPVIj92/qkqdBiJhUSIo0dOgVM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603359337121859.6705726668442; Thu, 22 Oct 2020 02:35:37 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-449-ts-2q7jzN5SA7kpQmxBLNg-1; Thu, 22 Oct 2020 05:35:33 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 97739804B69; Thu, 22 Oct 2020 09:35:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74FDA6EF72; Thu, 22 Oct 2020 09:35:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 40EC01800BB2; Thu, 22 Oct 2020 09:35:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZLEh024531 for ; Thu, 22 Oct 2020 05:35:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id B0D8B5B4A8; Thu, 22 Oct 2020 09:35:21 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 014EC5B4A3 for ; Thu, 22 Oct 2020 09:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359336; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8TTTbFbmN30Rxp1wlb4oCwHzgaqR1RHZ7YpJROdTL9A=; b=D9fScB4Jqw4iucFZeUvv8IhEMpGFxIrYZrng1NXBp/GGjRCwgdPzdgPayWLwzja1jlhJEu m1EFwdby5Ip7WalMe1TGFghLMRlP9ENoBH8T6156Ogsf4rDR29+bVoZIs5vG2hI5JEYSiM LpYTVp8XH+/akhFZKiRlbfClyc1S4CI= X-MC-Unique: ts-2q7jzN5SA7kpQmxBLNg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/15] qemuDomainObjPrivateAlloc: Use virHashNew instead of virHashCreate Date: Thu, 22 Oct 2020 11:35:00 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" virHashCreate will be removed in upcoming patches. This change has an impact on ordering of the blockjob entries in one of the status XML->XML tests. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_domain.c | 2 +- .../blockjob-blockdev-in.xml | 110 +++++++++--------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index eeceb44348..bea43a1aba 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1697,7 +1697,7 @@ qemuDomainObjPrivateAlloc(void *opaque) if (!(priv->devs =3D virChrdevAlloc())) goto error; - if (!(priv->blockjobs =3D virHashCreate(5, virObjectFreeHashData))) + if (!(priv->blockjobs =3D virHashNew(virObjectFreeHashData))) goto error; /* agent commands block by default, user can choose different behavior= */ diff --git a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml b/tests/q= emustatusxml2xmldata/blockjob-blockdev-in.xml index ca6d110179..8ffc91bdcb 100644 --- a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml +++ b/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml @@ -244,64 +244,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -339,6 +284,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -2 --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359356; cv=none; d=zohomail.com; s=zohoarc; b=Q8Au4F/zez+OlUdpuGskdbgqw2/g6ytOUzbJmdSKyb4PvJY2mu2gEqZBC+k+HuYKXTlZkpwUcJdNJnqqHzOEPa8fOB8zexzzCAOLlw1Fp3kfrFJ1v2q2uHjSOqtJK6G8E/J/L7oaK4eLyr975Vd+i22mn4lssPcmPzOz3zHo9gg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359356; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M++T7/RStQ5LBxaAA+321xD4PLfrPfzLiVHitj6PTYs=; b=HP+FS3yhJ+lU81B0r3QzglFi/1N43B47O9PG/qJl5qubyqbTJ3mt+VsogVqch8sRD7e8i/aGjWGYpZA0qKFa+NR7ZbB4OxAlnTGVETIcQuYzJnqPtF2b/rdCaLal9DXOLj24pyM5TIzLGIBx9nWhiuOchiITv9ZIABZqUeBsYxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603359356908546.1974626426901; Thu, 22 Oct 2020 02:35:56 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-487-klAJANxgOpWlFBXpcKeTdA-1; Thu, 22 Oct 2020 05:35:53 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 798FF1084D69; Thu, 22 Oct 2020 09:35:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5111819C78; Thu, 22 Oct 2020 09:35:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1D95A922F6; Thu, 22 Oct 2020 09:35:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZNIY024540 for ; Thu, 22 Oct 2020 05:35:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 012005B4C0; Thu, 22 Oct 2020 09:35:23 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ED5F5B4A8 for ; Thu, 22 Oct 2020 09:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359355; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=M++T7/RStQ5LBxaAA+321xD4PLfrPfzLiVHitj6PTYs=; b=fXSflI2hlAUL+D+IjMRegCp/wDaLcNLGCJ5M2+jTl/F9GJ0PS6g0Y6OxxkSIqKi0j8jZ53 bpOETYg8LH70IXJu4W+vHmUmpgg9KcTMbv9tMuFhGpBKSN1BVKvL5DY/5Z0VGe7tbRUdTh oAGxLQ8d+1/vWTm8/1aNSQU/f4yKv2E= X-MC-Unique: klAJANxgOpWlFBXpcKeTdA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/15] Replace all instances of 'virHashCreate' with 'virHashNew' Date: Thu, 22 Oct 2020 11:35:01 +0200 Message-Id: <1f5e3eddb76adedee33905780884b406f1d6e3ed.1603358617.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It doesn't make much sense to configure the bucket count in the hash table for each case specifically. Replace all calls of virHashCreate with virHashNew which has a pre-set size and remove virHashCreate completely. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/conf/domain_addr.c | 2 +- src/conf/domain_conf.c | 4 ++-- src/conf/virchrdev.c | 2 +- src/conf/virdomainmomentobjlist.c | 2 +- src/conf/virdomainobjlist.c | 4 ++-- src/conf/virinterfaceobj.c | 2 +- src/conf/virnetworkobj.c | 5 ++--- src/conf/virnodedeviceobj.c | 2 +- src/conf/virnwfilterbindingobjlist.c | 2 +- src/conf/virsecretobj.c | 2 +- src/conf/virstorageobj.c | 10 +++++----- src/hyperv/hyperv_wmi.c | 2 +- src/hypervisor/virclosecallbacks.c | 2 +- src/libvirt_private.syms | 1 - src/libxl/libxl_logger.c | 2 +- src/locking/lock_daemon.c | 8 ++------ src/nwfilter/nwfilter_dhcpsnoop.c | 6 +++--- src/nwfilter/nwfilter_ebiptables_driver.c | 4 ++-- src/nwfilter/nwfilter_gentech_driver.c | 2 +- src/nwfilter/nwfilter_learnipaddr.c | 4 ++-- src/qemu/qemu_block.c | 6 +++--- src/qemu/qemu_capabilities.c | 4 ++-- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_interop_config.c | 2 +- src/qemu/qemu_monitor.c | 10 +++++----- src/qemu/qemu_monitor_json.c | 2 +- src/qemu/qemu_qapi.c | 2 +- src/rpc/virnetdaemon.c | 2 +- src/security/security_selinux.c | 4 ++-- src/util/virfilecache.c | 2 +- src/util/virhash.c | 21 --------------------- src/util/virhash.h | 2 -- src/util/viriptables.c | 4 ++-- src/util/virlockspace.c | 6 ++---- src/util/virmacmap.c | 2 +- src/util/virstoragefile.c | 4 ++-- src/util/virsystemd.c | 2 +- tests/qemumonitorjsontest.c | 10 +++++----- tests/qemusecuritymock.c | 4 ++-- tests/testutilsqemu.c | 2 +- tests/virhashtest.c | 8 ++++---- 41 files changed, 69 insertions(+), 100 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 4e47c2547c..de344186ec 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1389,7 +1389,7 @@ virDomainCCWAddressSetCreate(void) addrs =3D g_new0(virDomainCCWAddressSet, 1); - if (!(addrs->defined =3D virHashCreate(10, virHashValueFree))) + if (!(addrs->defined =3D virHashNew(virHashValueFree))) goto error; /* must use cssid =3D 0xfe (254) for virtio-ccw devices */ diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 37efd104f1..f4f017cf83 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5821,7 +5821,7 @@ virDomainDefBootOrderPostParse(virDomainDefPtr def) virHashTablePtr bootHash =3D NULL; int ret =3D -1; - if (!(bootHash =3D virHashCreate(5, NULL))) + if (!(bootHash =3D virHashNew(NULL))) goto cleanup; if (virDomainDeviceInfoIterate(def, virDomainDefCollectBootOrder, boot= Hash) < 0) @@ -6927,7 +6927,7 @@ virDomainDefValidateAliases(const virDomainDef *def, int ret =3D -1; /* We are not storing copies of aliases. Don't free them. */ - if (!(data.aliases =3D virHashCreate(10, NULL))) + if (!(data.aliases =3D virHashNew(NULL))) goto cleanup; if (virDomainDeviceInfoIterateInternal((virDomainDefPtr) def, diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index c50f9ca720..0d2c9503ab 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -266,7 +266,7 @@ virChrdevsPtr virChrdevAlloc(void) /* there will hardly be any devices most of the time, the hash * does not have to be huge */ - if (!(devs->hash =3D virHashCreate(3, virChrdevHashEntryFree))) + if (!(devs->hash =3D virHashNew(virChrdevHashEntryFree))) goto error; return devs; diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index 8a1eb6b734..43c77e6c54 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -275,7 +275,7 @@ virDomainMomentObjListNew(void) virDomainMomentObjListPtr moments; moments =3D g_new0(virDomainMomentObjList, 1); - moments->objs =3D virHashCreate(50, virDomainMomentObjListDataFree); + moments->objs =3D virHashNew(virDomainMomentObjListDataFree); if (!moments->objs) { VIR_FREE(moments); return NULL; diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 46b28cc9a6..9e8757eff9 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -75,8 +75,8 @@ virDomainObjListPtr virDomainObjListNew(void) if (!(doms =3D virObjectRWLockableNew(virDomainObjListClass))) return NULL; - if (!(doms->objs =3D virHashCreate(50, virObjectFreeHashData)) || - !(doms->objsName =3D virHashCreate(50, virObjectFreeHashData))) { + if (!(doms->objs =3D virHashNew(virObjectFreeHashData)) || + !(doms->objsName =3D virHashNew(virObjectFreeHashData))) { virObjectUnref(doms); return NULL; } diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index e08b4b9b0f..1e29e12148 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -142,7 +142,7 @@ virInterfaceObjListNew(void) if (!(interfaces =3D virObjectRWLockableNew(virInterfaceObjListClass))) return NULL; - if (!(interfaces->objsName =3D virHashCreate(10, virObjectFreeHashData= ))) { + if (!(interfaces->objsName =3D virHashNew(virObjectFreeHashData))) { virObjectUnref(interfaces); return NULL; } diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index a2835ebf8e..3e537e512e 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -118,8 +118,7 @@ virNetworkObjNew(void) virBitmapSetBitExpand(obj->classIdMap, 2) < 0) goto error; - if (!(obj->ports =3D virHashCreate(10, - virNetworkObjPortFree))) + if (!(obj->ports =3D virHashNew(virNetworkObjPortFree))) goto error; virObjectLock(obj); @@ -351,7 +350,7 @@ virNetworkObjListNew(void) if (!(nets =3D virObjectRWLockableNew(virNetworkObjListClass))) return NULL; - if (!(nets->objs =3D virHashCreate(50, virObjectFreeHashData))) { + if (!(nets->objs =3D virHashNew(virObjectFreeHashData))) { virObjectUnref(nets); return NULL; } diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 9af80b8036..dcac4c36bb 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -454,7 +454,7 @@ virNodeDeviceObjListNew(void) if (!(devs =3D virObjectRWLockableNew(virNodeDeviceObjListClass))) return NULL; - if (!(devs->objs =3D virHashCreate(50, virObjectFreeHashData))) { + if (!(devs->objs =3D virHashNew(virObjectFreeHashData))) { virObjectUnref(devs); return NULL; } diff --git a/src/conf/virnwfilterbindingobjlist.c b/src/conf/virnwfilterbin= dingobjlist.c index 328b1b8482..6f4ad0bae6 100644 --- a/src/conf/virnwfilterbindingobjlist.c +++ b/src/conf/virnwfilterbindingobjlist.c @@ -66,7 +66,7 @@ virNWFilterBindingObjListNew(void) if (!(bindings =3D virObjectRWLockableNew(virNWFilterBindingObjListCla= ss))) return NULL; - if (!(bindings->objs =3D virHashCreate(50, virObjectFreeHashData))) { + if (!(bindings->objs =3D virHashNew(virObjectFreeHashData))) { virObjectUnref(bindings); return NULL; } diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index d74deb9316..a3ae64ec53 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -119,7 +119,7 @@ virSecretObjListNew(void) if (!(secrets =3D virObjectRWLockableNew(virSecretObjListClass))) return NULL; - if (!(secrets->objs =3D virHashCreate(50, virObjectFreeHashData))) { + if (!(secrets->objs =3D virHashNew(virObjectFreeHashData))) { virObjectUnref(secrets); return NULL; } diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 1c7d615a7a..1edcc3e074 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -172,9 +172,9 @@ virStorageVolObjListNew(void) if (!(vols =3D virObjectRWLockableNew(virStorageVolObjListClass))) return NULL; - if (!(vols->objsKey =3D virHashCreate(10, virObjectFreeHashData)) || - !(vols->objsName =3D virHashCreate(10, virObjectFreeHashData)) || - !(vols->objsPath =3D virHashCreate(10, virObjectFreeHashData))) { + if (!(vols->objsKey =3D virHashNew(virObjectFreeHashData)) || + !(vols->objsName =3D virHashNew(virObjectFreeHashData)) || + !(vols->objsPath =3D virHashNew(virObjectFreeHashData))) { virObjectUnref(vols); return NULL; } @@ -404,8 +404,8 @@ virStoragePoolObjListNew(void) if (!(pools =3D virObjectRWLockableNew(virStoragePoolObjListClass))) return NULL; - if (!(pools->objs =3D virHashCreate(20, virObjectFreeHashData)) || - !(pools->objsName =3D virHashCreate(20, virObjectFreeHashData))) { + if (!(pools->objs =3D virHashNew(virObjectFreeHashData)) || + !(pools->objsName =3D virHashNew(virObjectFreeHashData))) { virObjectUnref(pools); return NULL; } diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 29447b8f0f..f2fb7faeb0 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -332,7 +332,7 @@ hypervCreateEmbeddedParam(hypervPrivate *priv, hypervWm= iClassInfoListPtr info) for (count =3D 0; typeinfo[count].name !=3D NULL; count++) ; - table =3D virHashCreate(count, NULL); + table =3D virHashNew(NULL); if (table =3D=3D NULL) return NULL; diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/vircloseca= llbacks.c index 403af047fb..176dd5c263 100644 --- a/src/hypervisor/virclosecallbacks.c +++ b/src/hypervisor/virclosecallbacks.c @@ -69,7 +69,7 @@ virCloseCallbacksNew(void) if (!(closeCallbacks =3D virObjectLockableNew(virCloseCallbacksClass))) return NULL; - closeCallbacks->list =3D virHashCreate(5, virHashValueFree); + closeCallbacks->list =3D virHashNew(virHashValueFree); if (!closeCallbacks->list) { virObjectUnref(closeCallbacks); return NULL; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4f9e7f6048..36e2c66d93 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2199,7 +2199,6 @@ virHashAddEntry; virHashAtomicNew; virHashAtomicSteal; virHashAtomicUpdate; -virHashCreate; virHashEqual; virHashForEach; virHashFree; diff --git a/src/libxl/libxl_logger.c b/src/libxl/libxl_logger.c index 379d7a8d00..d0ce899fe8 100644 --- a/src/libxl/libxl_logger.c +++ b/src/libxl/libxl_logger.c @@ -153,7 +153,7 @@ libxlLoggerNew(const char *logDir, virLogPriority minLe= vel) } logger.logDir =3D logDir; - if ((logger.files =3D virHashCreate(3, libxlLoggerFileFree)) =3D=3D NU= LL) + if ((logger.files =3D virHashNew(libxlLoggerFileFree)) =3D=3D NULL) return NULL; path =3D g_strdup_printf("%s/libxl-driver.log", logDir); diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 88fa7b7957..f1dabe56cd 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -56,8 +56,6 @@ VIR_LOG_INIT("locking.lock_daemon"); -#define VIR_LOCK_DAEMON_NUM_LOCKSPACES 3 - struct _virLockDaemon { GMutex lock; virNetDaemonPtr dmn; @@ -155,8 +153,7 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool pr= ivileged) virObjectUnref(srv); srv =3D NULL; - if (!(lockd->lockspaces =3D virHashCreate(VIR_LOCK_DAEMON_NUM_LOCKSPAC= ES, - virLockDaemonLockSpaceDataFree= ))) + if (!(lockd->lockspaces =3D virHashNew(virLockDaemonLockSpaceDataFree)= )) goto error; if (!(lockd->defaultLockspace =3D virLockSpaceNew(NULL))) @@ -215,8 +212,7 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object,= bool privileged) g_mutex_init(&lockd->lock); - if (!(lockd->lockspaces =3D virHashCreate(VIR_LOCK_DAEMON_NUM_LOCKSPAC= ES, - virLockDaemonLockSpaceDataFree= ))) + if (!(lockd->lockspaces =3D virHashNew(virLockDaemonLockSpaceDataFree)= )) goto error; if (!(child =3D virJSONValueObjectGet(object, "defaultLockspace"))) { diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index d0992b782c..a9cbaccdad 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -2005,10 +2005,10 @@ virNWFilterDHCPSnoopInit(void) virMutexInit(&virNWFilterSnoopState.activeLock) < 0) return -1; - virNWFilterSnoopState.ifnameToKey =3D virHashCreate(0, NULL); - virNWFilterSnoopState.active =3D virHashCreate(0, NULL); + virNWFilterSnoopState.ifnameToKey =3D virHashNew(NULL); + virNWFilterSnoopState.active =3D virHashNew(NULL); virNWFilterSnoopState.snoopReqs =3D - virHashCreate(0, virNWFilterSnoopReqRelease); + virHashNew(virNWFilterSnoopReqRelease); if (!virNWFilterSnoopState.ifnameToKey || !virNWFilterSnoopState.snoopReqs || diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfil= ter_ebiptables_driver.c index e73aa82eb4..da6f88f135 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -3323,8 +3323,8 @@ ebiptablesApplyNewRules(const char *ifname, { size_t i, j; g_autoptr(virFirewall) fw =3D virFirewallNew(); - g_autoptr(virHashTable) chains_in_set =3D virHashCreate(10, NULL); - g_autoptr(virHashTable) chains_out_set =3D virHashCreate(10, NULL); + g_autoptr(virHashTable) chains_in_set =3D virHashNew(NULL); + g_autoptr(virHashTable) chains_out_set =3D virHashNew(NULL); bool haveEbtables =3D false; bool haveIptables =3D false; bool haveIp6tables =3D false; diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index 99d2c0fce4..073c91550a 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -1008,7 +1008,7 @@ virNWFilterBuildAll(virNWFilterDriverStatePtr driver, VIR_DEBUG("Build all filters newFilters=3D%d", newFilters); if (newFilters) { - if (!(data.skipInterfaces =3D virHashCreate(0, NULL))) + if (!(data.skipInterfaces =3D virHashNew(NULL))) return -1; data.step =3D STEP_APPLY_NEW; diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_le= arnipaddr.c index faf66ac84a..82797d9a64 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -777,11 +777,11 @@ virNWFilterLearnInit(void) VIR_DEBUG("Initializing IP address learning"); threadsTerminate =3D false; - pendingLearnReq =3D virHashCreate(0, freeLearnReqEntry); + pendingLearnReq =3D virHashNew(freeLearnReqEntry); if (!pendingLearnReq) return -1; - ifaceLockMap =3D virHashCreate(0, virHashValueFree); + ifaceLockMap =3D virHashNew(virHashValueFree); if (!ifaceLockMap) { virNWFilterLearnShutdown(); return -1; diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index f1cd12a950..0c2710a7c6 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -234,7 +234,7 @@ qemuBlockNodeNameGetBackingChain(virJSONValuePtr namedn= odes, memset(&data, 0, sizeof(data)); - if (!(namednodestable =3D virHashCreate(50, virJSONValueHashFree))) + if (!(namednodestable =3D virHashNew(virJSONValueHashFree))) return NULL; if (virJSONValueArrayForeachSteal(namednodes, @@ -242,7 +242,7 @@ qemuBlockNodeNameGetBackingChain(virJSONValuePtr namedn= odes, namednodestable) < 0) return NULL; - if (!(disks =3D virHashCreate(50, qemuBlockNodeNameBackingChainDataHas= hEntryFree))) + if (!(disks =3D virHashNew(qemuBlockNodeNameBackingChainDataHashEntryF= ree))) return NULL; data.nodenamestable =3D namednodestable; @@ -370,7 +370,7 @@ qemuBlockGetNodeData(virJSONValuePtr data) { g_autoptr(virHashTable) nodedata =3D NULL; - if (!(nodedata =3D virHashCreate(50, virJSONValueHashFree))) + if (!(nodedata =3D virHashNew(virJSONValueHashFree))) return NULL; if (virJSONValueArrayForeachSteal(data, diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9435333a0e..2249d035fb 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1784,7 +1784,7 @@ virQEMUDomainCapsCacheNew(void) if (!(cache =3D virObjectLockableNew(virQEMUDomainCapsCacheClass))) return NULL; - if (!(cache->cache =3D virHashCreate(5, virObjectFreeHashData))) + if (!(cache->cache =3D virHashNew(virObjectFreeHashData))) return NULL; return g_steal_pointer(&cache); @@ -3114,7 +3114,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, qemuMonitorCPUPropertyPtr nmProp; size_t i; - if (!(hash =3D virHashCreate(0, NULL))) + if (!(hash =3D virHashNew(NULL))) goto cleanup; for (i =3D 0; i < modelInfo->nprops; i++) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index faf892fba3..f1191c1210 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -787,7 +787,7 @@ qemuStateInitialize(bool privileged, if (!(qemu_driver->hostdevMgr =3D virHostdevManagerGetDefault())) goto error; - if (!(qemu_driver->sharedDevices =3D virHashCreate(30, qemuSharedDevic= eEntryFree))) + if (!(qemu_driver->sharedDevices =3D virHashNew(qemuSharedDeviceEntryF= ree))) goto error; if (qemuMigrationDstErrorInit(qemu_driver) < 0) diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c index 975cbf0afd..080674ce2d 100644 --- a/src/qemu/qemu_interop_config.c +++ b/src/qemu/qemu_interop_config.c @@ -125,7 +125,7 @@ qemuInteropFetchConfigs(const char *name, homeConfig =3D g_strdup_printf("%s/qemu/%s", xdgConfig, name); } - if (!(files =3D virHashCreate(10, virHashValueFree))) + if (!(files =3D virHashNew(virHashValueFree))) return -1; if (qemuBuildFileList(files, sysLocation) < 0) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index b66d278ee5..51de72b5bf 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2086,7 +2086,7 @@ qemuMonitorGetBlockInfo(qemuMonitorPtr mon) QEMU_CHECK_MONITOR_NULL(mon); - if (!(table =3D virHashCreate(32, qemuDomainDiskInfoFree))) + if (!(table =3D virHashNew(qemuDomainDiskInfoFree))) return NULL; ret =3D qemuMonitorJSONGetBlockInfo(mon, table); @@ -2137,7 +2137,7 @@ qemuMonitorGetAllBlockStatsInfo(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); - if (!(*ret_stats =3D virHashCreate(10, virHashValueFree))) + if (!(*ret_stats =3D virHashNew(virHashValueFree))) goto error; ret =3D qemuMonitorJSONGetAllBlockStatsInfo(mon, *ret_stats, @@ -2878,7 +2878,7 @@ qemuMonitorGetChardevInfo(qemuMonitorPtr mon, QEMU_CHECK_MONITOR_GOTO(mon, error); - if (!(info =3D virHashCreate(10, qemuMonitorChardevInfoFree))) + if (!(info =3D virHashNew(qemuMonitorChardevInfoFree))) goto error; ret =3D qemuMonitorJSONGetChardevInfo(mon, info); @@ -4289,7 +4289,7 @@ qemuMonitorGetMemoryDeviceInfo(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); - if (!(*info =3D virHashCreate(10, virHashValueFree))) + if (!(*info =3D virHashNew(virHashValueFree))) return -1; if ((ret =3D qemuMonitorJSONGetMemoryDeviceInfo(mon, *info)) < 0) { @@ -4593,7 +4593,7 @@ qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); - if (!(info =3D virHashCreate(10, virHashValueFree))) + if (!(info =3D virHashNew(virHashValueFree))) goto cleanup; if (qemuMonitorJSONGetPRManagerInfo(mon, info) < 0) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 6c763ecc12..91cc0c9046 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5126,7 +5126,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon, } nr_results =3D virJSONValueArraySize(data); - if (!(blockJobs =3D virHashCreate(nr_results, virHashValueFree))) + if (!(blockJobs =3D virHashNew(virHashValueFree))) goto cleanup; for (i =3D 0; i < nr_results; i++) { diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c index 43f367f2a2..5e5fff3019 100644 --- a/src/qemu/qemu_qapi.c +++ b/src/qemu/qemu_qapi.c @@ -517,7 +517,7 @@ virQEMUQAPISchemaConvert(virJSONValuePtr schemareply) g_autoptr(virHashTable) schema =3D NULL; g_autoptr(virJSONValue) schemajson =3D schemareply; - if (!(schema =3D virHashCreate(512, virJSONValueHashFree))) + if (!(schema =3D virHashNew(virJSONValueHashFree))) return NULL; if (virJSONValueArrayForeachSteal(schemajson, diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 37a5662e04..3e2af53e82 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -140,7 +140,7 @@ virNetDaemonNew(void) if (!(dmn =3D virObjectLockableNew(virNetDaemonClass))) return NULL; - if (!(dmn->servers =3D virHashCreate(5, virObjectFreeHashData))) + if (!(dmn->servers =3D virHashNew(virObjectFreeHashData))) goto error; #ifndef WIN32 diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index e40d670e97..733bcf23d9 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -685,7 +685,7 @@ virSecuritySELinuxLXCInitialize(virSecurityManagerPtr m= gr) goto error; } - if (!(data->mcs =3D virHashCreate(10, NULL))) + if (!(data->mcs =3D virHashNew(NULL))) goto error; return 0; @@ -757,7 +757,7 @@ virSecuritySELinuxQEMUInitialize(virSecurityManagerPtr = mgr) VIR_DEBUG("Loaded file context '%s', content context '%s'", data->file_context, data->content_context); - if (!(data->mcs =3D virHashCreate(10, NULL))) + if (!(data->mcs =3D virHashNew(NULL))) goto error; return 0; diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c index 195587e6bd..6d75e2e4fb 100644 --- a/src/util/virfilecache.c +++ b/src/util/virfilecache.c @@ -242,7 +242,7 @@ virFileCacheNew(const char *dir, if (!(cache =3D virObjectNew(virFileCacheClass))) return NULL; - if (!(cache->table =3D virHashCreate(10, virObjectFreeHashData))) + if (!(cache->table =3D virHashNew(virObjectFreeHashData))) goto cleanup; cache->dir =3D g_strdup(dir); diff --git a/src/util/virhash.c b/src/util/virhash.c index 23e12e0255..ce09f8f248 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -190,27 +190,6 @@ virHashNew(virHashDataFree dataFree) } -/** - * virHashCreate: - * @size: the size of the hash table - * @dataFree: callback to free data - * - * Create a new virHashTablePtr. - * - * Returns the newly created object. - */ -virHashTablePtr virHashCreate(ssize_t size, virHashDataFree dataFree) -{ - return virHashCreateFull(size, - dataFree, - virHashStrCode, - virHashStrEqual, - virHashStrCopy, - virHashStrPrintHuman, - virHashStrFree); -} - - virHashAtomicPtr virHashAtomicNew(virHashDataFree dataFree) { diff --git a/src/util/virhash.h b/src/util/virhash.h index baf92996a3..b136455f1f 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -112,8 +112,6 @@ typedef void (*virHashKeyFree)(void *name); * Constructor and destructor. */ virHashTablePtr virHashNew(virHashDataFree dataFree); -virHashTablePtr virHashCreate(ssize_t size, - virHashDataFree dataFree); virHashAtomicPtr virHashAtomicNew(virHashDataFree dataFree); virHashTablePtr virHashCreateFull(ssize_t size, virHashDataFree dataFree, diff --git a/src/util/viriptables.c b/src/util/viriptables.c index b5dd2edbd3..beab42be26 100644 --- a/src/util/viriptables.c +++ b/src/util/viriptables.c @@ -76,9 +76,9 @@ iptablesPrivateChainCreate(virFirewallPtr fw, int ret =3D -1; size_t i; - if (!(chains =3D virHashCreate(50, NULL))) + if (!(chains =3D virHashNew(NULL))) goto cleanup; - if (!(links =3D virHashCreate(50, NULL))) + if (!(links =3D virHashNew(NULL))) goto cleanup; tmp =3D lines; diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index ef370936a3..30d6a19d1d 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -251,8 +251,7 @@ virLockSpacePtr virLockSpaceNew(const char *directory) lockspace->dir =3D g_strdup(directory); - if (!(lockspace->resources =3D virHashCreate(VIR_LOCKSPACE_TABLE_SIZE, - virLockSpaceResourceDataFre= e))) + if (!(lockspace->resources =3D virHashNew(virLockSpaceResourceDataFree= ))) goto error; if (directory) { @@ -299,8 +298,7 @@ virLockSpacePtr virLockSpaceNewPostExecRestart(virJSONV= aluePtr object) return NULL; } - if (!(lockspace->resources =3D virHashCreate(VIR_LOCKSPACE_TABLE_SIZE, - virLockSpaceResourceDataFre= e))) + if (!(lockspace->resources =3D virHashNew(virLockSpaceResourceDataFree= ))) goto error; if (virJSONValueObjectHasKey(object, "directory")) { diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c index 4b5e24718d..94e73f3530 100644 --- a/src/util/virmacmap.c +++ b/src/util/virmacmap.c @@ -299,7 +299,7 @@ virMacMapNew(const char *file) return NULL; virObjectLock(mgr); - if (!(mgr->macs =3D virHashCreate(VIR_MAC_HASH_TABLE_SIZE, NULL))) + if (!(mgr->macs =3D virHashNew(NULL))) goto error; if (file && diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 82388ae544..33db43cd92 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4310,7 +4310,7 @@ virStorageFileCanonicalizePath(const char *path, beginDoubleSlash =3D true; } - if (!(cycle =3D virHashCreate(10, NULL))) + if (!(cycle =3D virHashNew(NULL))) goto cleanup; if (!(components =3D virStringSplitCount(path, "/", 0, &ncomponents))) @@ -5317,7 +5317,7 @@ virStorageFileGetMetadata(virStorageSourcePtr src, src->path, src->format, (unsigned int)uid, (unsigned int)gid, report_broken); - if (!(cycle =3D virHashCreate(5, NULL))) + if (!(cycle =3D virHashNew(NULL))) return -1; if (src->format <=3D VIR_STORAGE_FILE_NONE) { diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 8373ee6509..09f80a1619 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -896,7 +896,7 @@ virSystemdActivationNew(virSystemdActivationMap *map, VIR_DEBUG("Activated with %d FDs", nfds); act =3D g_new0(virSystemdActivation, 1); - if (!(act->fds =3D virHashCreate(10, virSystemdActivationEntryFree))) + if (!(act->fds =3D virHashNew(virSystemdActivationEntryFree))) goto error; fdnames =3D getenv("LISTEN_FDNAMES"); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 0611fdfd34..f50ecdeb3f 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1649,8 +1649,8 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const = void *opaque) if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) return -1; - if (!(blockDevices =3D virHashCreate(32, virHashValueFree)) || - !(expectedBlockDevices =3D virHashCreate(32, virHashValueFree))) + if (!(blockDevices =3D virHashNew(virHashValueFree)) || + !(expectedBlockDevices =3D virHashNew(virHashValueFree))) goto cleanup; info =3D g_new0(struct qemuDomainDiskInfo, 1); @@ -1811,7 +1811,7 @@ testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInf= o(const void *opaque) if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) return -1; - if (!(blockstats =3D virHashCreate(10, virHashValueFree))) + if (!(blockstats =3D virHashNew(virHashValueFree))) goto cleanup; if (qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0) @@ -2018,8 +2018,8 @@ testQemuMonitorJSONqemuMonitorJSONGetChardevInfo(cons= t void *opaque) if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) return -1; - if (!(info =3D virHashCreate(32, qemuMonitorChardevInfoFree)) || - !(expectedInfo =3D virHashCreate(32, NULL))) + if (!(info =3D virHashNew(qemuMonitorChardevInfoFree)) || + !(expectedInfo =3D virHashNew(NULL))) goto cleanup; if (virHashAddEntry(expectedInfo, "charserial1", &info1) < 0 || diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c index 6366432dd4..c1344b3daa 100644 --- a/tests/qemusecuritymock.c +++ b/tests/qemusecuritymock.c @@ -85,12 +85,12 @@ init_hash(void) if (xattr_paths) return; - if (!(xattr_paths =3D virHashCreate(10, virHashValueFree))) { + if (!(xattr_paths =3D virHashNew(virHashValueFree))) { fprintf(stderr, "Unable to create hash table for XATTR paths\n"); abort(); } - if (!(chown_paths =3D virHashCreate(10, virHashValueFree))) { + if (!(chown_paths =3D virHashNew(virHashValueFree))) { fprintf(stderr, "Unable to create hash table for chowned paths\n"); abort(); } diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 5b23888a98..3f50d46d87 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -576,7 +576,7 @@ testQemuGetLatestCaps(void) virHashTablePtr capslatest; size_t i; - if (!(capslatest =3D virHashCreate(4, virHashValueFree))) + if (!(capslatest =3D virHashNew(virHashValueFree))) goto error; VIR_TEST_VERBOSE(""); diff --git a/tests/virhashtest.c b/tests/virhashtest.c index bc93c07d1f..0ba5b9ed31 100644 --- a/tests/virhashtest.c +++ b/tests/virhashtest.c @@ -388,7 +388,7 @@ testHashGetItems(const void *data G_GNUC_UNUSED) char value2[] =3D "2"; char value3[] =3D "3"; - if (!(hash =3D virHashCreate(0, NULL)) || + if (!(hash =3D virHashNew(NULL)) || virHashAddEntry(hash, keya, value3) < 0 || virHashAddEntry(hash, keyc, value1) < 0 || virHashAddEntry(hash, keyb, value2) < 0) { @@ -458,8 +458,8 @@ testHashEqual(const void *data G_GNUC_UNUSED) char value3_u[] =3D "O"; char value4_u[] =3D "P"; - if (!(hash1 =3D virHashCreate(0, NULL)) || - !(hash2 =3D virHashCreate(0, NULL)) || + if (!(hash1 =3D virHashNew(NULL)) || + !(hash2 =3D virHashNew(NULL)) || virHashAddEntry(hash1, keya, value1_l) < 0 || virHashAddEntry(hash1, keyb, value2_l) < 0 || virHashAddEntry(hash1, keyc, value3_l) < 0 || @@ -508,7 +508,7 @@ testHashDuplicate(const void *data G_GNUC_UNUSED) { g_autoptr(virHashTable) hash =3D NULL; - if (!(hash =3D virHashCreate(0, NULL))) + if (!(hash =3D virHashNew(NULL))) return -1; if (virHashAddEntry(hash, "a", NULL) < 0) { --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359495; cv=none; d=zohomail.com; s=zohoarc; b=JRKnYs5ALaSbhFHwPzMSgIomFXZrTADSWJdD5h6tAf9i3+RQRmMaFiGhbvGY89K2f+fWr68G6iosYnhrYPe12Zgr4i6Ii2EJpDl5XpzuVSN/N8SGZ2FFHb/hbco1DJIkS0MLaPqZ6qgC0blEWEaQd/ovLNlNw28PGMYvpZRUjoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359495; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p+HBGIMuSEebIC1zh8JYKc9XAie4zwqZITNU0J9GvMQ=; b=OmqCZ9JLNWHb8KXxG/SmGlPd20T9mgm5KOF+ufgbdeWmn84pNZjSs+g3XXrblEa75EQh4xuR5dMUiHYx/BRhcJjlpnnnSOajxrOBldoJ6/3A7eFVrtxaqjv9BS7IWSix8kcpkN0cO8j/5hh5e/rOp3Rppou0iz2YVQ2RkEj8Znk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603359495269817.3502414823247; Thu, 22 Oct 2020 02:38:15 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-570-VrTun-D5NsS-R_RVptk66Q-1; Thu, 22 Oct 2020 05:36:00 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD94A1009E2B; Thu, 22 Oct 2020 09:35:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8ED2D6EF6B; Thu, 22 Oct 2020 09:35:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 57B8492305; Thu, 22 Oct 2020 09:35:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZOGr024551 for ; Thu, 22 Oct 2020 05:35:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1AAC35B4C0; Thu, 22 Oct 2020 09:35:24 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64CF65B4A8 for ; Thu, 22 Oct 2020 09:35:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359494; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=p+HBGIMuSEebIC1zh8JYKc9XAie4zwqZITNU0J9GvMQ=; b=SHLv4Qnm5OtqkICZkTy6RT7CGkgkhNbWO3QE/PjrryL3hzR5ur+V55k4D+wGNkmJ8kNawY LjweKxzJQIi43InjaVLXkRGaLJSQCRgMQpfRow7vWpXjd8MLVhWiiqJmXEpGt8nb3Da6Zm 13Py8rH6d8psEkARPGTt91YSPGAfI3M= X-MC-Unique: VrTun-D5NsS-R_RVptk66Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/15] util: hash: Remove virHashValueFree Date: Thu, 22 Oct 2020 11:35:02 +0200 Message-Id: <0ea0c6f0154ec431590c1a9a31690c5fcef9b496.1603358617.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use 'g_free' directly. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/conf/domain_addr.c | 2 +- src/hypervisor/virclosecallbacks.c | 2 +- src/libvirt_private.syms | 1 - src/nwfilter/nwfilter_learnipaddr.c | 2 +- src/qemu/qemu_interop_config.c | 2 +- src/qemu/qemu_migration_cookie.c | 2 +- src/qemu/qemu_monitor.c | 6 +++--- src/qemu/qemu_monitor_json.c | 2 +- src/util/virhash.c | 7 ------- src/util/virhash.h | 3 --- tests/qemumonitorjsontest.c | 6 +++--- tests/qemusecuritymock.c | 4 ++-- tests/testutilsqemu.c | 2 +- 13 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index de344186ec..37dad20ade 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1389,7 +1389,7 @@ virDomainCCWAddressSetCreate(void) addrs =3D g_new0(virDomainCCWAddressSet, 1); - if (!(addrs->defined =3D virHashNew(virHashValueFree))) + if (!(addrs->defined =3D virHashNew(g_free))) goto error; /* must use cssid =3D 0xfe (254) for virtio-ccw devices */ diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/vircloseca= llbacks.c index 176dd5c263..a73ab818da 100644 --- a/src/hypervisor/virclosecallbacks.c +++ b/src/hypervisor/virclosecallbacks.c @@ -69,7 +69,7 @@ virCloseCallbacksNew(void) if (!(closeCallbacks =3D virObjectLockableNew(virCloseCallbacksClass))) return NULL; - closeCallbacks->list =3D virHashNew(virHashValueFree); + closeCallbacks->list =3D virHashNew(g_free); if (!closeCallbacks->list) { virObjectUnref(closeCallbacks); return NULL; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 36e2c66d93..926e982e0b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2213,7 +2213,6 @@ virHashSearch; virHashSize; virHashSteal; virHashUpdateEntry; -virHashValueFree; # util/virhashcode.h diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_le= arnipaddr.c index 82797d9a64..6dc535a4fe 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -781,7 +781,7 @@ virNWFilterLearnInit(void) if (!pendingLearnReq) return -1; - ifaceLockMap =3D virHashNew(virHashValueFree); + ifaceLockMap =3D virHashNew(g_free); if (!ifaceLockMap) { virNWFilterLearnShutdown(); return -1; diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c index 080674ce2d..53b251f056 100644 --- a/src/qemu/qemu_interop_config.c +++ b/src/qemu/qemu_interop_config.c @@ -125,7 +125,7 @@ qemuInteropFetchConfigs(const char *name, homeConfig =3D g_strdup_printf("%s/qemu/%s", xdgConfig, name); } - if (!(files =3D virHashNew(virHashValueFree))) + if (!(files =3D virHashNew(g_free))) return -1; if (qemuBuildFileList(files, sysLocation) < 0) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index abe797759d..708c2cced7 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -435,7 +435,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - g_autoptr(virHashTable) stats =3D virHashNew(virHashValueFree); + g_autoptr(virHashTable) stats =3D virHashNew(g_free); bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); size_t i; int rc; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 51de72b5bf..69d81b20c2 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2137,7 +2137,7 @@ qemuMonitorGetAllBlockStatsInfo(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); - if (!(*ret_stats =3D virHashNew(virHashValueFree))) + if (!(*ret_stats =3D virHashNew(g_free))) goto error; ret =3D qemuMonitorJSONGetAllBlockStatsInfo(mon, *ret_stats, @@ -4289,7 +4289,7 @@ qemuMonitorGetMemoryDeviceInfo(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); - if (!(*info =3D virHashNew(virHashValueFree))) + if (!(*info =3D virHashNew(g_free))) return -1; if ((ret =3D qemuMonitorJSONGetMemoryDeviceInfo(mon, *info)) < 0) { @@ -4593,7 +4593,7 @@ qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); - if (!(info =3D virHashNew(virHashValueFree))) + if (!(info =3D virHashNew(g_free))) goto cleanup; if (qemuMonitorJSONGetPRManagerInfo(mon, info) < 0) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 91cc0c9046..2689ad50b9 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5126,7 +5126,7 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon, } nr_results =3D virJSONValueArraySize(data); - if (!(blockJobs =3D virHashNew(virHashValueFree))) + if (!(blockJobs =3D virHashNew(g_free))) goto cleanup; for (i =3D 0; i < nr_results; i++) { diff --git a/src/util/virhash.c b/src/util/virhash.c index ce09f8f248..c781e1d5a5 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -111,13 +111,6 @@ static void virHashStrFree(void *name) } -void -virHashValueFree(void *value) -{ - VIR_FREE(value); -} - - static size_t virHashComputeKey(const virHashTable *table, const void *name) { diff --git a/src/util/virhash.h b/src/util/virhash.h index b136455f1f..2d221dce25 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -202,7 +202,4 @@ ssize_t virHashRemoveSet(virHashTablePtr table, virHash= Searcher iter, const void void *virHashSearch(const virHashTable *table, virHashSearcher iter, const void *data, void **name); -/* Convenience for when VIR_FREE(value) is sufficient as a data freer. */ -void virHashValueFree(void *value); - G_DEFINE_AUTOPTR_CLEANUP_FUNC(virHashTable, virHashFree); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index f50ecdeb3f..da7fd4625a 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1649,8 +1649,8 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const = void *opaque) if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) return -1; - if (!(blockDevices =3D virHashNew(virHashValueFree)) || - !(expectedBlockDevices =3D virHashNew(virHashValueFree))) + if (!(blockDevices =3D virHashNew(g_free)) || + !(expectedBlockDevices =3D virHashNew(g_free))) goto cleanup; info =3D g_new0(struct qemuDomainDiskInfo, 1); @@ -1811,7 +1811,7 @@ testQemuMonitorJSONqemuMonitorJSONGetAllBlockStatsInf= o(const void *opaque) if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) return -1; - if (!(blockstats =3D virHashNew(virHashValueFree))) + if (!(blockstats =3D virHashNew(g_free))) goto cleanup; if (qemuMonitorTestAddItem(test, "query-blockstats", reply) < 0) diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c index c1344b3daa..839be55665 100644 --- a/tests/qemusecuritymock.c +++ b/tests/qemusecuritymock.c @@ -85,12 +85,12 @@ init_hash(void) if (xattr_paths) return; - if (!(xattr_paths =3D virHashNew(virHashValueFree))) { + if (!(xattr_paths =3D virHashNew(g_free))) { fprintf(stderr, "Unable to create hash table for XATTR paths\n"); abort(); } - if (!(chown_paths =3D virHashNew(virHashValueFree))) { + if (!(chown_paths =3D virHashNew(g_free))) { fprintf(stderr, "Unable to create hash table for chowned paths\n"); abort(); } diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 3f50d46d87..4defba0b7b 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -576,7 +576,7 @@ testQemuGetLatestCaps(void) virHashTablePtr capslatest; size_t i; - if (!(capslatest =3D virHashNew(virHashValueFree))) + if (!(capslatest =3D virHashNew(g_free))) goto error; VIR_TEST_VERBOSE(""); --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359380; cv=none; d=zohomail.com; s=zohoarc; b=L79N1m7EM8r3wuZL4ykKo0q8wRPk7zoawtsUlAg9uTdESf7zR8pJ81JCD3IT74IDCuqKBQClaPv3g6MA6R3afgPIwLluZdjyERxtT0mnU8EPhRhSKzhW5EcTMV0Lcier5mKIBmRcYAsgKTjFUczQKcdEi0JyteRHnQ7vAcDk1ac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359380; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=satDynnV4MFfTzRrU7dMHIRmzkRbARRbLyH4l13NNDA=; b=fabtbQLNB+jz48CXiS1CxEiSwQnO7YZTu4toVhGJYxkdXPOvq1tZsWXehO+mn2ofwhHfB4OLU5Tj0XZ+DMDdwkFSXMyih4XxCw2YKR0T/wBsQtepXroeXB11oD0pt/x1uCPu9a+cJqLErdQYXy/RkNeopwjdyc2xeuJwMNsdMl0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603359380146704.4383770590184; Thu, 22 Oct 2020 02:36:20 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-504-hiUMu1mMMZiDCYZMY1V4hQ-1; Thu, 22 Oct 2020 05:36:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF303188C129; Thu, 22 Oct 2020 09:36:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE37E5B4C1; Thu, 22 Oct 2020 09:36:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 84496922F9; Thu, 22 Oct 2020 09:36:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZPHa024566 for ; Thu, 22 Oct 2020 05:35:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 306295B4C0; Thu, 22 Oct 2020 09:35:25 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 876AC5B4A8 for ; Thu, 22 Oct 2020 09:35:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359379; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=satDynnV4MFfTzRrU7dMHIRmzkRbARRbLyH4l13NNDA=; b=B4bFO91tZzT37jpETHf1nl1XHNPq4HJEkbOOnuk/PhtRYLD96g3iq7JZSV6DE7cRj12ie9 RFTwXpAPMDD0UkmigL8Bdc1pFQY0jZ6Ce5QKXCIj5cftdFAhApJLz+NgjQLcAMIzpX0x3f mVkcVesJLMtOtR12tQUNn4O4L6t1rlI= X-MC-Unique: hiUMu1mMMZiDCYZMY1V4hQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/15] util: hash: Remove virHashCreateFull Date: Thu, 22 Oct 2020 11:35:03 +0200 Message-Id: <6fa73ba021e5b0452a7223c8c3a841b3eced8769.1603358617.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The only place we call it is in virHashNew. Move the code to virHashNew and remove virHashCreateFull. Code wishing to use non-strings as hash table keys will be better off using glib's GHashTable directly. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/virhash.c | 53 +++++++++------------------------------------- src/util/virhash.h | 7 ------ 2 files changed, 10 insertions(+), 50 deletions(-) diff --git a/src/util/virhash.c b/src/util/virhash.c index c781e1d5a5..8d56b4bb85 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -118,43 +118,31 @@ virHashComputeKey(const virHashTable *table, const vo= id *name) return value % table->size; } + /** - * virHashCreateFull: - * @size: the size of the hash table + * virHashNew: * @dataFree: callback to free data - * @keyCode: callback to compute hash code - * @keyEqual: callback to compare hash keys - * @keyCopy: callback to copy hash keys - * @keyFree: callback to free keys * * Create a new virHashTablePtr. * * Returns the newly created object. */ -virHashTablePtr virHashCreateFull(ssize_t size, - virHashDataFree dataFree, - virHashKeyCode keyCode, - virHashKeyEqual keyEqual, - virHashKeyCopy keyCopy, - virHashKeyPrintHuman keyPrint, - virHashKeyFree keyFree) +virHashTablePtr +virHashNew(virHashDataFree dataFree) { virHashTablePtr table =3D NULL; - if (size <=3D 0) - size =3D 256; - table =3D g_new0(virHashTable, 1); table->seed =3D virRandomBits(32); - table->size =3D size; + table->size =3D 32; table->nbElems =3D 0; table->dataFree =3D dataFree; - table->keyCode =3D keyCode; - table->keyEqual =3D keyEqual; - table->keyCopy =3D keyCopy; - table->keyPrint =3D keyPrint; - table->keyFree =3D keyFree; + table->keyCode =3D virHashStrCode; + table->keyEqual =3D virHashStrEqual; + table->keyCopy =3D virHashStrCopy; + table->keyPrint =3D virHashStrPrintHuman; + table->keyFree =3D virHashStrFree; table->table =3D g_new0(virHashEntryPtr, table->size); @@ -162,27 +150,6 @@ virHashTablePtr virHashCreateFull(ssize_t size, } -/** - * virHashNew: - * @dataFree: callback to free data - * - * Create a new virHashTablePtr. - * - * Returns the newly created object. - */ -virHashTablePtr -virHashNew(virHashDataFree dataFree) -{ - return virHashCreateFull(32, - dataFree, - virHashStrCode, - virHashStrEqual, - virHashStrCopy, - virHashStrPrintHuman, - virHashStrFree); -} - - virHashAtomicPtr virHashAtomicNew(virHashDataFree dataFree) { diff --git a/src/util/virhash.h b/src/util/virhash.h index 2d221dce25..a9b022f362 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -113,13 +113,6 @@ typedef void (*virHashKeyFree)(void *name); */ virHashTablePtr virHashNew(virHashDataFree dataFree); virHashAtomicPtr virHashAtomicNew(virHashDataFree dataFree); -virHashTablePtr virHashCreateFull(ssize_t size, - virHashDataFree dataFree, - virHashKeyCode keyCode, - virHashKeyEqual keyEqual, - virHashKeyCopy keyCopy, - virHashKeyPrintHuman keyPrint, - virHashKeyFree keyFree); void virHashFree(virHashTablePtr table); ssize_t virHashSize(const virHashTable *table); --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359486; cv=none; d=zohomail.com; s=zohoarc; b=SHidR0+TPEfPRz5j9McFarFd0Es11+eWzwI9fhGkZhKLQBeykYoNpZqOfNX80fgWrA6xSRA80Qi6/dCLDVctXspz1zxPNFX46PHPx+mR5rp7DufaZsgEMtlWvTB+/0YYy/FztK4LtN9B1pVdcCLFwdqAblrsrGBbNDbwtJr+5xg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359486; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zIx6/zFxoUMUnJuxdhwnNFG4w/wzBMkQg7FDP48pd+E=; b=VCYKP8A2tLWj8KUJ267xWcXdv1MDAnzn2duVH9wiFXY/c6e+kf8cZdIuMaMloJBk2Ksaj4xQ6z+bLe3G0RANEsEzjnBgVX564Bfcwvc48zzeJQqTyL50pJCETtjJG+WsaZvr5WHwt2gX0ESntHM/Av8bFwdfbRBdW5C00ruhmdw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 160335948675729.480139990169732; Thu, 22 Oct 2020 02:38:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-135-_vpaPZq6MjWw9Wqutu0EqQ-1; Thu, 22 Oct 2020 05:35:56 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 607371882FA5; Thu, 22 Oct 2020 09:35:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 360651972A; Thu, 22 Oct 2020 09:35:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 017AA922FC; Thu, 22 Oct 2020 09:35:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZQvM024580 for ; Thu, 22 Oct 2020 05:35:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C4745B4A8; Thu, 22 Oct 2020 09:35:26 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D9B05B4C2 for ; Thu, 22 Oct 2020 09:35:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359485; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zIx6/zFxoUMUnJuxdhwnNFG4w/wzBMkQg7FDP48pd+E=; b=Qnu/gmRTmWwOsPKQpw63j9KihpDNfysu36wehb9vUfPkAPqE+MPVJyvz9cp/NQFkYIQYNV Z2KNLFDArwhOGNbLPsnx0TknVSf3eTNQcbMwSZSNgUX+s7IRGnlZq6SCSSJeaDThoQYvo5 6x59Ovfj6wVR6zFFwZRaIMj6vfF3ad8= X-MC-Unique: _vpaPZq6MjWw9Wqutu0EqQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/15] util: hash: Change type of hash table name/key to 'char' Date: Thu, 22 Oct 2020 11:35:04 +0200 Message-Id: <11dd6b02ba075d76a94472f3e7d00459bc9b5449.1603358617.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" All users of virHashTable pass strings as the name/key of the entry. Make this an official requirement by turning the variables to 'const char *'. For any other case it's better to use glib's GHashTable. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/conf/nwfilter_params.c | 2 +- src/conf/virchrdev.c | 2 +- src/conf/virdomainmomentobjlist.c | 6 ++-- src/conf/virdomainobjlist.c | 12 ++++---- src/conf/virinterfaceobj.c | 10 +++--- src/conf/virnetworkobj.c | 16 +++++----- src/conf/virnodedeviceobj.c | 18 +++++------ src/conf/virnwfilterbindingobjlist.c | 4 +-- src/conf/virsecretobj.c | 8 ++--- src/conf/virstorageobj.c | 22 +++++++------- src/hypervisor/virclosecallbacks.c | 2 +- src/locking/lock_daemon.c | 2 +- src/nwfilter/nwfilter_dhcpsnoop.c | 6 ++-- src/nwfilter/nwfilter_gentech_driver.c | 6 ++-- src/qemu/qemu_blockjob.c | 2 +- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_checkpoint.c | 2 +- src/qemu/qemu_domain.c | 6 ++-- src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_process.c | 2 +- src/qemu/qemu_snapshot.c | 4 +-- src/rpc/virnetdaemon.c | 14 ++++----- src/test/test_driver.c | 6 ++-- src/util/virfilecache.c | 2 +- src/util/virhash.c | 42 +++++++++++++------------- src/util/virhash.h | 32 ++++++++++---------- src/util/virlockspace.c | 2 +- src/util/virmacmap.c | 4 +-- tests/qemumonitorjsontest.c | 2 +- tests/qemusecuritymock.c | 8 ++--- tests/virhashtest.c | 10 +++--- 31 files changed, 129 insertions(+), 129 deletions(-) diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c index fd05b45ca3..73160a38a4 100644 --- a/src/conf/nwfilter_params.c +++ b/src/conf/nwfilter_params.c @@ -620,7 +620,7 @@ struct addToTableStruct { static int -addToTable(void *payload, const void *name, void *data) +addToTable(void *payload, const char *name, void *data) { struct addToTableStruct *atts =3D (struct addToTableStruct *)data; virNWFilterVarValuePtr val; diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index 0d2c9503ab..5e5c03d03b 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -279,7 +279,7 @@ virChrdevsPtr virChrdevAlloc(void) * Helper to clear stream callbacks when freeing the hash */ static int virChrdevFreeClearCallbacks(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *data G_GNUC_UNUSED) { virChrdevHashEntry *ent =3D payload; diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index 43c77e6c54..511bf1d415 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -76,7 +76,7 @@ struct moment_act_on_descendant { static int virDomainMomentActOnDescendant(void *payload, - const void *name, + const char *name, void *data) { virDomainMomentObjPtr obj =3D payload; @@ -307,7 +307,7 @@ struct virDomainMomentNameData { static int virDomainMomentObjListCopyNames(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virDomainMomentObjPtr obj =3D payload; @@ -491,7 +491,7 @@ struct moment_set_relation { }; static int virDomainMomentSetRelations(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *data) { virDomainMomentObjPtr obj =3D payload; diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 9e8757eff9..e9a4b271df 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -95,7 +95,7 @@ static void virDomainObjListDispose(void *obj) static int virDomainObjListSearchID(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *data) { virDomainObjPtr obj =3D (virDomainObjPtr)payload; @@ -649,7 +649,7 @@ struct virDomainObjListData { static int virDomainObjListCount(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virDomainObjPtr obj =3D payload; @@ -696,7 +696,7 @@ struct virDomainIDData { static int virDomainObjListCopyActiveIDs(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virDomainObjPtr obj =3D payload; @@ -741,7 +741,7 @@ struct virDomainNameData { static int virDomainObjListCopyInactiveNames(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virDomainObjPtr obj =3D payload; @@ -797,7 +797,7 @@ struct virDomainListIterData { static int virDomainObjListHelper(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { struct virDomainListIterData *data =3D opaque; @@ -925,7 +925,7 @@ struct virDomainListData { static int virDomainObjListCollectIterator(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { struct virDomainListData *data =3D opaque; diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index 1e29e12148..faf047dc5f 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -161,7 +161,7 @@ struct _virInterfaceObjFindMACData { static int virInterfaceObjListFindByMACStringCb(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virInterfaceObjPtr obj =3D payload; @@ -269,7 +269,7 @@ struct _virInterfaceObjListExportData { static int virInterfaceObjListExportCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virInterfaceObjListExportDataPtr data =3D opaque; @@ -361,7 +361,7 @@ struct _virInterfaceObjListCloneData { static int virInterfaceObjListCloneCb(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virInterfaceObjPtr srcObj =3D payload; @@ -480,7 +480,7 @@ struct _virInterfaceObjNumOfInterfacesData { static int virInterfaceObjListNumOfInterfacesCb(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virInterfaceObjPtr obj =3D payload; @@ -522,7 +522,7 @@ struct _virInterfaceObjGetNamesData { static int virInterfaceObjListGetNamesCb(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virInterfaceObjPtr obj =3D payload; diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 3e537e512e..46205b163c 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -402,7 +402,7 @@ virNetworkObjFindByUUID(virNetworkObjListPtr nets, static int virNetworkObjSearchName(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *data) { virNetworkObjPtr obj =3D (virNetworkObjPtr) payload; @@ -1178,7 +1178,7 @@ struct virNetworkObjBridgeInUseHelperData { static int virNetworkObjBridgeInUseHelper(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { int ret; @@ -1355,7 +1355,7 @@ struct _virNetworkObjListExportData { static int virNetworkObjListExportCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virNetworkObjListExportDataPtr data =3D opaque; @@ -1439,7 +1439,7 @@ struct virNetworkObjListForEachHelperData { static int virNetworkObjListForEachHelper(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { struct virNetworkObjListForEachHelperData *data =3D opaque; @@ -1489,7 +1489,7 @@ struct virNetworkObjListGetHelperData { static int virNetworkObjListGetHelper(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { struct virNetworkObjListGetHelperData *data =3D opaque; @@ -1576,7 +1576,7 @@ struct virNetworkObjListPruneHelperData { static int virNetworkObjListPruneHelper(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { const struct virNetworkObjListPruneHelperData *data =3D opaque; @@ -1756,7 +1756,7 @@ struct _virNetworkObjPortListExportData { static int virNetworkObjPortListExportCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virNetworkObjPortListExportDataPtr data =3D opaque; @@ -1834,7 +1834,7 @@ struct _virNetworkObjPortListForEachData { static int virNetworkObjPortForEachCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virNetworkObjPortListForEachData *data =3D opaque; diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index dcac4c36bb..f240abf315 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -199,7 +199,7 @@ virNodeDeviceObjListSearch(virNodeDeviceObjListPtr devs, static int virNodeDeviceObjListFindBySysfsPathCallback(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { virNodeDeviceObjPtr obj =3D (virNodeDeviceObjPtr) payload; @@ -256,7 +256,7 @@ struct virNodeDeviceObjListFindByWWNsData { static int virNodeDeviceObjListFindByWWNsCallback(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { virNodeDeviceObjPtr obj =3D (virNodeDeviceObjPtr) payload; @@ -292,7 +292,7 @@ virNodeDeviceObjListFindByWWNs(virNodeDeviceObjListPtr = devs, static int virNodeDeviceObjListFindByFabricWWNCallback(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { virNodeDeviceObjPtr obj =3D (virNodeDeviceObjPtr) payload; @@ -322,7 +322,7 @@ virNodeDeviceObjListFindByFabricWWN(virNodeDeviceObjLis= tPtr devs, static int virNodeDeviceObjListFindByCapCallback(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { virNodeDeviceObjPtr obj =3D (virNodeDeviceObjPtr) payload; @@ -354,7 +354,7 @@ struct virNodeDeviceObjListFindSCSIHostByWWNsData { static int virNodeDeviceObjListFindSCSIHostByWWNsCallback(const void *payload, - const void *name G_GNUC_UNU= SED, + const char *name G_GNUC_UNU= SED, const void *opaque) { virNodeDeviceObjPtr obj =3D (virNodeDeviceObjPtr) payload; @@ -401,7 +401,7 @@ virNodeDeviceObjListFindSCSIHostByWWNs(virNodeDeviceObj= ListPtr devs, static int virNodeDeviceObjListFindMediatedDeviceByUUIDCallback(const void *payload, - const void *name G_GN= UC_UNUSED, + const char *name G_GN= UC_UNUSED, const void *opaque) { virNodeDeviceObjPtr obj =3D (virNodeDeviceObjPtr) payload; @@ -729,7 +729,7 @@ struct virNodeDeviceCountData { static int virNodeDeviceObjListNumOfDevicesCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virNodeDeviceObjPtr obj =3D payload; @@ -777,7 +777,7 @@ struct virNodeDeviceGetNamesData { static int virNodeDeviceObjListGetNamesCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virNodeDeviceObjPtr obj =3D payload; @@ -884,7 +884,7 @@ struct _virNodeDeviceObjListExportData { static int virNodeDeviceObjListExportCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virNodeDeviceObjPtr obj =3D payload; diff --git a/src/conf/virnwfilterbindingobjlist.c b/src/conf/virnwfilterbin= dingobjlist.c index 6f4ad0bae6..4cbb62abfa 100644 --- a/src/conf/virnwfilterbindingobjlist.c +++ b/src/conf/virnwfilterbindingobjlist.c @@ -345,7 +345,7 @@ struct virNWFilterBindingListIterData { static int virNWFilterBindingObjListHelper(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { struct virNWFilterBindingListIterData *data =3D opaque; @@ -379,7 +379,7 @@ struct virNWFilterBindingListData { static int virNWFilterBindingObjListCollectIterator(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { struct virNWFilterBindingListData *data =3D opaque; diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index a3ae64ec53..146210fbe7 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -197,7 +197,7 @@ virSecretObjListFindByUUID(virSecretObjListPtr secrets, static int virSecretObjSearchName(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { virSecretObjPtr obj =3D (virSecretObjPtr) payload; @@ -410,7 +410,7 @@ struct virSecretCountData { static int virSecretObjListNumOfSecretsCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { struct virSecretCountData *data =3D opaque; @@ -443,7 +443,7 @@ struct virSecretListData { static int virSecretObjListGetUUIDsCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { struct virSecretListData *data =3D opaque; @@ -534,7 +534,7 @@ struct _virSecretObjListExportData { static int virSecretObjListExportCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virSecretObjListExportDataPtr data =3D opaque; diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 1edcc3e074..219594582c 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -421,7 +421,7 @@ struct _virStoragePoolObjListForEachData { static int virStoragePoolObjListForEachCb(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virStoragePoolObjPtr obj =3D payload; @@ -477,7 +477,7 @@ struct _virStoragePoolObjListSearchData { static int virStoragePoolObjListSearchCb(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { virStoragePoolObjPtr obj =3D (virStoragePoolObjPtr) payload; @@ -728,7 +728,7 @@ struct _virStoragePoolObjForEachVolData { static int virStoragePoolObjForEachVolumeCb(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { int ret =3D 0; @@ -767,7 +767,7 @@ struct _virStoragePoolObjSearchVolData { static int virStoragePoolObjSearchVolumeCb(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { virStorageVolObjPtr volobj =3D (virStorageVolObjPtr) payload; @@ -864,7 +864,7 @@ struct _virStorageVolObjCountData { static int virStoragePoolObjNumOfVolumesCb(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virStorageVolObjPtr volobj =3D payload; @@ -913,7 +913,7 @@ struct _virStorageVolObjNameData { static int virStoragePoolObjVolumeGetNamesCb(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virStorageVolObjPtr volobj =3D payload; @@ -983,7 +983,7 @@ struct _virStoragePoolObjVolumeListExportData { static int virStoragePoolObjVolumeListExportCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virStorageVolObjPtr volobj =3D payload; @@ -1430,7 +1430,7 @@ struct _virStoragePoolObjFindDuplicateData { static int virStoragePoolObjSourceFindDuplicateCb(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { virStoragePoolObjPtr obj =3D (virStoragePoolObjPtr) payload; @@ -1832,7 +1832,7 @@ struct _virStoragePoolCountData { static int virStoragePoolObjNumOfStoragePoolsCb(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virStoragePoolObjPtr obj =3D payload; @@ -1884,7 +1884,7 @@ struct _virStoragePoolNameData { static int virStoragePoolObjGetNamesCb(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virStoragePoolObjPtr obj =3D payload; @@ -2027,7 +2027,7 @@ struct _virStoragePoolObjListExportData { static int virStoragePoolObjListExportCallback(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virStoragePoolObjPtr obj =3D payload; diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/vircloseca= llbacks.c index a73ab818da..d87fe84505 100644 --- a/src/hypervisor/virclosecallbacks.c +++ b/src/hypervisor/virclosecallbacks.c @@ -246,7 +246,7 @@ struct virCloseCallbacksData { static int virCloseCallbacksGetOne(void *payload, - const void *key, + const char *key, void *opaque) { struct virCloseCallbacksData *data =3D opaque; diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index f1dabe56cd..8f16dfd064 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -362,7 +362,7 @@ struct virLockDaemonClientReleaseData { static int virLockDaemonClientReleaseLockspace(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virLockSpacePtr lockspace =3D payload; diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index a9cbaccdad..c425af497c 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -1754,7 +1754,7 @@ virNWFilterSnoopLeaseFileSave(virNWFilterSnoopIPLease= Ptr ipl) */ static int virNWFilterSnoopPruneIter(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *data G_GNUC_UNUSED) { virNWFilterSnoopReqPtr req =3D (virNWFilterSnoopReqPtr)payload; @@ -1784,7 +1784,7 @@ virNWFilterSnoopPruneIter(const void *payload, */ static int virNWFilterSnoopSaveIter(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *data) { virNWFilterSnoopReqPtr req =3D payload; @@ -1951,7 +1951,7 @@ virNWFilterSnoopJoinThreads(void) */ static int virNWFilterSnoopRemAllReqIter(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *data G_GNUC_UNUSED) { virNWFilterSnoopReqPtr req =3D (virNWFilterSnoopReqPtr)payload; diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index 073c91550a..ca6455c70d 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -140,12 +140,12 @@ struct printString static int -printString(void *payload G_GNUC_UNUSED, const void *name, void *data) +printString(void *payload G_GNUC_UNUSED, const char *name, void *data) { struct printString *ps =3D data; - if ((STREQ((char *)name, NWFILTER_STD_VAR_IP) && !ps->reportIP) || - (STREQ((char *)name, NWFILTER_STD_VAR_MAC) && !ps->reportMAC)) + if ((STREQ(name, NWFILTER_STD_VAR_IP) && !ps->reportIP) || + (STREQ(name, NWFILTER_STD_VAR_MAC) && !ps->reportMAC)) return 0; if (virBufferUse(&ps->buf) && ps->separator) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index c49c98e547..ed4a32e964 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -481,7 +481,7 @@ qemuBlockJobIsRunning(qemuBlockJobDataPtr job) /* returns 1 for a job we didn't reconnect to */ static int qemuBlockJobRefreshJobsFindInactive(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *data G_GNUC_UNUSED) { const qemuBlockJobData *job =3D payload; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2249d035fb..a67fb785b5 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2156,7 +2156,7 @@ struct virQEMUCapsSearchDomcapsData { static int virQEMUCapsSearchDomcaps(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { virDomainCapsPtr domCaps =3D (virDomainCapsPtr) payload; diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index f45ab29d4c..fb76c211f8 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -744,7 +744,7 @@ struct virQEMUCheckpointReparent { static int qemuCheckpointReparentChildren(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *data) { virDomainMomentObjPtr moment =3D payload; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bea43a1aba..161b369712 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2106,7 +2106,7 @@ qemuDomainPrivateBlockJobFormatCommit(qemuBlockJobDat= aPtr job, static int qemuDomainObjPrivateXMLFormatBlockjobIterator(void *payload, - const void *name G_GNUC_UNUS= ED, + const char *name G_GNUC_UNUS= ED, void *opaque) { struct qemuDomainPrivateBlockJobFormatData *data =3D opaque; @@ -6641,7 +6641,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, /* Hash iterator callback to discard multiple snapshots. */ int qemuDomainMomentDiscardAll(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *data) { virDomainMomentObjPtr moment =3D payload; @@ -10718,7 +10718,7 @@ qemuDomainPausedReasonToSuspendedEvent(virDomainPau= sedReason reason) static int qemuDomainDefHasManagedPRBlockjobIterator(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { qemuBlockJobDataPtr job =3D payload; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 91b3b67cb6..fc69678f9b 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -638,7 +638,7 @@ struct _virQEMUMomentRemove { }; int qemuDomainMomentDiscardAll(void *payload, - const void *name, + const char *name, void *data); int qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr driver, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 89f6fd1499..91db2319fb 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8067,7 +8067,7 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver, static int qemuProcessRefreshLegacyBlockjob(void *payload, - const void *name, + const char *name, void *opaque) { const char *jobname =3D name; diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 47df102817..a6241ab5d4 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -75,7 +75,7 @@ qemuSnapObjFromSnapshot(virDomainObjPtr vm, /* Count how many snapshots in a set are external snapshots. */ static int qemuSnapshotCountExternal(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *data) { virDomainMomentObjPtr snap =3D payload; @@ -2265,7 +2265,7 @@ struct _virQEMUMomentReparent { static int qemuSnapshotChildrenReparent(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *data) { virDomainMomentObjPtr moment =3D payload; diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index 3e2af53e82..ce13f0d927 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -86,7 +86,7 @@ static virClassPtr virNetDaemonClass; static int daemonServerClose(void *payload, - const void *key G_GNUC_UNUSED, + const char *key G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED); static void @@ -228,7 +228,7 @@ struct collectData { static int collectServers(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque) { virNetServerPtr srv =3D virObjectRef(payload); @@ -731,7 +731,7 @@ virNetDaemonAutoShutdownTimer(int timerid G_GNUC_UNUSED, static int daemonServerUpdateServices(void *payload, - const void *key G_GNUC_UNUSED, + const char *key G_GNUC_UNUSED, void *opaque) { bool *enable =3D opaque; @@ -752,7 +752,7 @@ virNetDaemonUpdateServices(virNetDaemonPtr dmn, static int daemonServerProcessClients(void *payload, - const void *key G_GNUC_UNUSED, + const char *key G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED) { virNetServerPtr srv =3D payload; @@ -763,7 +763,7 @@ daemonServerProcessClients(void *payload, static int daemonServerShutdownWait(void *payload, - const void *key G_GNUC_UNUSED, + const char *key G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED) { virNetServerPtr srv =3D payload; @@ -913,7 +913,7 @@ virNetDaemonQuit(virNetDaemonPtr dmn) static int daemonServerClose(void *payload, - const void *key G_GNUC_UNUSED, + const char *key G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED) { virNetServerPtr srv =3D payload; @@ -924,7 +924,7 @@ daemonServerClose(void *payload, static int daemonServerHasClients(void *payload, - const void *key G_GNUC_UNUSED, + const char *key G_GNUC_UNUSED, void *opaque) { bool *clients =3D opaque; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index bb26fc247c..5c02a8ebb0 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8592,7 +8592,7 @@ struct _testMomentRemoveData { static int testDomainSnapshotDiscardAll(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *data) { virDomainMomentObjPtr snap =3D payload; @@ -8612,7 +8612,7 @@ struct _testMomentReparentData { static int testDomainMomentReparentChildren(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *data) { virDomainMomentObjPtr moment =3D payload; @@ -8906,7 +8906,7 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snaps= hot, static int testDomainCheckpointDiscardAll(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *data) { virDomainMomentObjPtr chk =3D payload; diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c index 6d75e2e4fb..cfb1d1d247 100644 --- a/src/util/virfilecache.c +++ b/src/util/virfilecache.c @@ -337,7 +337,7 @@ virFileCacheLookupByFunc(virFileCachePtr cache, virObjectLock(cache); - data =3D virHashSearch(cache->table, iter, iterData, (void **)&name); + data =3D virHashSearch(cache->table, iter, iterData, &name); virFileCacheValidate(cache, name, &data); virObjectRef(data); diff --git a/src/util/virhash.c b/src/util/virhash.c index 8d56b4bb85..f386839d6b 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -43,7 +43,7 @@ typedef struct _virHashEntry virHashEntry; typedef virHashEntry *virHashEntryPtr; struct _virHashEntry { struct _virHashEntry *next; - void *name; + char *name; void *payload; }; @@ -82,37 +82,37 @@ static int virHashAtomicOnceInit(void) VIR_ONCE_GLOBAL_INIT(virHashAtomic); -static uint32_t virHashStrCode(const void *name, uint32_t seed) +static uint32_t virHashStrCode(const char *name, uint32_t seed) { return virHashCodeGen(name, strlen(name), seed); } -static bool virHashStrEqual(const void *namea, const void *nameb) +static bool virHashStrEqual(const char *namea, const char *nameb) { return STREQ(namea, nameb); } -static void *virHashStrCopy(const void *name) +static char *virHashStrCopy(const char *name) { return g_strdup(name); } static char * -virHashStrPrintHuman(const void *name) +virHashStrPrintHuman(const char *name) { return g_strdup(name); } -static void virHashStrFree(void *name) +static void virHashStrFree(char *name) { VIR_FREE(name); } static size_t -virHashComputeKey(const virHashTable *table, const void *name) +virHashComputeKey(const virHashTable *table, const char *name) { uint32_t value =3D table->keyCode(name, table->seed); return value % table->size; @@ -272,7 +272,7 @@ virHashFree(virHashTablePtr table) } static int -virHashAddOrUpdateEntry(virHashTablePtr table, const void *name, +virHashAddOrUpdateEntry(virHashTablePtr table, const char *name, void *userdata, bool is_update) { @@ -337,7 +337,7 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const vo= id *name, * Returns 0 the addition succeeded and -1 in case of error. */ int -virHashAddEntry(virHashTablePtr table, const void *name, void *userdata) +virHashAddEntry(virHashTablePtr table, const char *name, void *userdata) { return virHashAddOrUpdateEntry(table, name, userdata, false); } @@ -355,7 +355,7 @@ virHashAddEntry(virHashTablePtr table, const void *name= , void *userdata) * Returns 0 the addition succeeded and -1 in case of error. */ int -virHashUpdateEntry(virHashTablePtr table, const void *name, +virHashUpdateEntry(virHashTablePtr table, const char *name, void *userdata) { return virHashAddOrUpdateEntry(table, name, userdata, true); @@ -363,7 +363,7 @@ virHashUpdateEntry(virHashTablePtr table, const void *n= ame, int virHashAtomicUpdate(virHashAtomicPtr table, - const void *name, + const char *name, void *userdata) { int ret; @@ -378,7 +378,7 @@ virHashAtomicUpdate(virHashAtomicPtr table, static virHashEntryPtr virHashGetEntry(const virHashTable *table, - const void *name) + const char *name) { size_t key; virHashEntryPtr entry; @@ -406,7 +406,7 @@ virHashGetEntry(const virHashTable *table, * Returns a pointer to the userdata */ void * -virHashLookup(const virHashTable *table, const void *name) +virHashLookup(const virHashTable *table, const char *name) { virHashEntryPtr entry =3D virHashGetEntry(table, name); @@ -428,7 +428,7 @@ virHashLookup(const virHashTable *table, const void *na= me) */ bool virHashHasEntry(const virHashTable *table, - const void *name) + const char *name) { return !!virHashGetEntry(table, name); } @@ -444,7 +444,7 @@ virHashHasEntry(const virHashTable *table, * * Returns a pointer to the userdata */ -void *virHashSteal(virHashTablePtr table, const void *name) +void *virHashSteal(virHashTablePtr table, const char *name) { void *data =3D virHashLookup(table, name); if (data) { @@ -458,7 +458,7 @@ void *virHashSteal(virHashTablePtr table, const void *n= ame) void * virHashAtomicSteal(virHashAtomicPtr table, - const void *name) + const char *name) { void *data; @@ -500,7 +500,7 @@ virHashSize(const virHashTable *table) * Returns 0 if the removal succeeded and -1 in case of error or not found. */ int -virHashRemoveEntry(virHashTablePtr table, const void *name) +virHashRemoveEntry(virHashTablePtr table, const char *name) { virHashEntryPtr entry; virHashEntryPtr *nextptr; @@ -615,7 +615,7 @@ virHashRemoveSet(virHashTablePtr table, static int _virHashRemoveAllIter(const void *payload G_GNUC_UNUSED, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *data G_GNUC_UNUSED) { return 1; @@ -654,7 +654,7 @@ virHashRemoveAll(virHashTablePtr table) void *virHashSearch(const virHashTable *ctable, virHashSearcher iter, const void *data, - void **name) + char **name) { size_t i; @@ -685,7 +685,7 @@ struct getKeysIter }; static int virHashGetKeysIterator(void *payload, - const void *key, void *data) + const char *key, void *data) { struct getKeysIter *iter =3D data; @@ -728,7 +728,7 @@ struct virHashEqualData virHashValueComparator compar; }; -static int virHashEqualSearcher(const void *payload, const void *name, +static int virHashEqualSearcher(const void *payload, const char *name, const void *data) { struct virHashEqualData *vhed =3D (void *)data; diff --git a/src/util/virhash.h b/src/util/virhash.h index a9b022f362..78c7459390 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -40,7 +40,7 @@ typedef void (*virHashDataFree) (void *payload); * * Returns -1 to stop the iteration, e.g. in case of an error */ -typedef int (*virHashIterator) (void *payload, const void *name, void *dat= a); +typedef int (*virHashIterator) (void *payload, const char *name, void *dat= a); /** * virHashSearcher: * @payload: the data in the hash @@ -51,7 +51,7 @@ typedef int (*virHashIterator) (void *payload, const void= *name, void *data); * Returns 1 if the hash entry is desired, 0 to move * to next entry */ -typedef int (*virHashSearcher) (const void *payload, const void *name, +typedef int (*virHashSearcher) (const void *payload, const char *name, const void *data); /** @@ -64,7 +64,7 @@ typedef int (*virHashSearcher) (const void *payload, cons= t void *name, * * Returns the hash code */ -typedef uint32_t (*virHashKeyCode)(const void *name, +typedef uint32_t (*virHashKeyCode)(const char *name, uint32_t seed); /** * virHashKeyEqual: @@ -75,7 +75,7 @@ typedef uint32_t (*virHashKeyCode)(const void *name, * * Returns true if the keys are equal, false otherwise */ -typedef bool (*virHashKeyEqual)(const void *namea, const void *nameb); +typedef bool (*virHashKeyEqual)(const char *namea, const char *nameb); /** * virHashKeyCopy: * @name: the hash key @@ -86,7 +86,7 @@ typedef bool (*virHashKeyEqual)(const void *namea, const = void *nameb); * Returns a copy of @name which will eventually be passed to the * 'virHashKeyFree' callback at the end of its lifetime. */ -typedef void *(*virHashKeyCopy)(const void *name); +typedef char *(*virHashKeyCopy)(const char *name); /** * virHashKeyPrintHuman: * @name: the hash key @@ -97,7 +97,7 @@ typedef void *(*virHashKeyCopy)(const void *name); * Returns a string representation of the key for use in error messages. C= aller * promises to always free the returned string. */ -typedef char *(*virHashKeyPrintHuman) (const void *name); +typedef char *(*virHashKeyPrintHuman) (const char *name); /** * virHashKeyFree: @@ -106,7 +106,7 @@ typedef char *(*virHashKeyPrintHuman) (const void *name= ); * Free any memory associated with the hash * key @name */ -typedef void (*virHashKeyFree)(void *name); +typedef void (*virHashKeyFree)(char *name); /* * Constructor and destructor. @@ -120,19 +120,19 @@ ssize_t virHashSize(const virHashTable *table); * Add a new entry to the hash table. */ int virHashAddEntry(virHashTablePtr table, - const void *name, void *userdata); + const char *name, void *userdata); int virHashUpdateEntry(virHashTablePtr table, - const void *name, + const char *name, void *userdata); int virHashAtomicUpdate(virHashAtomicPtr table, - const void *name, + const char *name, void *userdata); /* * Remove an entry from the hash table. */ int virHashRemoveEntry(virHashTablePtr table, - const void *name); + const char *name); /* * Remove all entries from the hash table. @@ -142,15 +142,15 @@ ssize_t virHashRemoveAll(virHashTablePtr table); /* * Retrieve the userdata. */ -void *virHashLookup(const virHashTable *table, const void *name); -bool virHashHasEntry(const virHashTable *table, const void *name); +void *virHashLookup(const virHashTable *table, const char *name); +bool virHashHasEntry(const virHashTable *table, const char *name); /* * Retrieve & remove the userdata. */ -void *virHashSteal(virHashTablePtr table, const void *name); +void *virHashSteal(virHashTablePtr table, const char *name); void *virHashAtomicSteal(virHashAtomicPtr table, - const void *name); + const char *name); /* * Get the hash table's key/value pairs and have them optionally sorted. @@ -193,6 +193,6 @@ bool virHashEqual(const virHashTable *table1, int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data= ); ssize_t virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, cons= t void *data); void *virHashSearch(const virHashTable *table, virHashSearcher iter, - const void *data, void **name); + const void *data, char **name); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virHashTable, virHashFree); diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index 30d6a19d1d..2731d46dfc 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -683,7 +683,7 @@ struct virLockSpaceRemoveData { static int virLockSpaceRemoveResourcesForOwner(const void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, const void *opaque) { virLockSpaceResourcePtr res =3D (virLockSpaceResourcePtr)payload; diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c index 94e73f3530..2d203e72af 100644 --- a/src/util/virmacmap.c +++ b/src/util/virmacmap.c @@ -52,7 +52,7 @@ static virClassPtr virMacMapClass; static int virMacMapHashFree(void *payload, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED) { g_strfreev(payload); @@ -197,7 +197,7 @@ virMacMapLoadFile(virMacMapPtr mgr, static int virMACMapHashDumper(void *payload, - const void *name, + const char *name, void *data) { virJSONValuePtr obj =3D virJSONValueNewObject(); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index da7fd4625a..61935134af 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2732,7 +2732,7 @@ testQemuMonitorCPUInfo(const void *opaque) static int testBlockNodeNameDetectFormat(void *payload, - const void *name, + const char *name, void *opaque) { qemuBlockNodeNameBackingChainDataPtr entry =3D payload; diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c index 839be55665..543a5f7f3f 100644 --- a/tests/qemusecuritymock.c +++ b/tests/qemusecuritymock.c @@ -381,7 +381,7 @@ struct _checkOwnerData { static int checkOwner(void *payload, - const void *name, + const char *name, void *opaque) { checkOwnerData *data =3D opaque; @@ -392,7 +392,7 @@ checkOwner(void *payload, !virStringListHasString(data->paths, name)) { fprintf(stderr, "Path %s wasn't restored back to its original owner\n", - (const char *) name); + name); data->chown_fail =3D true; } @@ -402,7 +402,7 @@ checkOwner(void *payload, static int printXATTR(void *payload, - const void *name, + const char *name, void *data) { bool *xattr_fail =3D data; @@ -413,7 +413,7 @@ printXATTR(void *payload, /* Hash table key consists of "$path:$xattr_name", xattr * value is then the value stored in the hash table. */ - printf("key=3D%s val=3D%s\n", (const char *) name, (const char *) payl= oad); + printf("key=3D%s val=3D%s\n", name, (const char *) payload); return 0; } diff --git a/tests/virhashtest.c b/tests/virhashtest.c index 0ba5b9ed31..ad50aae003 100644 --- a/tests/virhashtest.c +++ b/tests/virhashtest.c @@ -46,7 +46,7 @@ testHashInit(void) static int testHashCheckForEachCount(void *payload G_GNUC_UNUSED, - const void *name G_GNUC_UNUSED, + const char *name G_GNUC_UNUSED, void *data G_GNUC_UNUSED) { size_t *count =3D data; @@ -175,7 +175,7 @@ const int testHashCountRemoveForEachSome =3D static int testHashRemoveForEachSome(void *payload G_GNUC_UNUSED, - const void *name, + const char *name, void *data) { virHashTablePtr hash =3D data; @@ -198,7 +198,7 @@ const int testHashCountRemoveForEachAll =3D 0; static int testHashRemoveForEachAll(void *payload G_GNUC_UNUSED, - const void *name, + const char *name, void *data) { virHashTablePtr hash =3D data; @@ -266,7 +266,7 @@ testHashSteal(const void *data G_GNUC_UNUSED) static int testHashRemoveSetIter(const void *payload G_GNUC_UNUSED, - const void *name, + const char *name, const void *data) { int *count =3D (int *) data; @@ -326,7 +326,7 @@ const int testSearchIndex =3D G_N_ELEMENTS(uuids_subset= ) / 2; static int testHashSearchIter(const void *payload G_GNUC_UNUSED, - const void *name, + const char *name, const void *data G_GNUC_UNUSED) { return STREQ(uuids_subset[testSearchIndex], name); --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359433; cv=none; d=zohomail.com; s=zohoarc; b=ZjU9LQ/uTz0kA+f+PgZoXBhywG7qtgOTUZXPw/aovtHOg93v8j2NBJRNUqrTwCXWF/c1nDpewPTtGOQ+zUEX4KVjz8MCw9Bt6Guo3gxwzDK0m17hm6Uj1tEYCa4xZ+AG9LAIlUYEj50rwnRusKGMUxNPAEjZlYFh1gHqpbvCnyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359433; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vpt3DY23b1rQllZbwQusdUvsMc/HpSwNPU54fpfK4cI=; b=eg0OZ6+KfQCcOY69VQnP2/Rl9GzoocwaEofOCj45zl9CfojmoeQsqJfl8A8413DtSlP/MfEaT5ZLDFGNYb3cvPXzDKivfVMZE+zUKptKTNMJMIYNfdJHcTrR43ZsswT7t5EAr1o7IA1OgFqE/RZ0kkj6Kb/mmStl30tyHUBQvk4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603359433071962.087911031176; Thu, 22 Oct 2020 02:37:13 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-561-5Dz5yaXINWqH1_K9Uf4QTw-1; Thu, 22 Oct 2020 05:35:59 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00FF65F9D6; Thu, 22 Oct 2020 09:35:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3F8A6EF6B; Thu, 22 Oct 2020 09:35:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A001844A43; Thu, 22 Oct 2020 09:35:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZVqE024608 for ; Thu, 22 Oct 2020 05:35:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id C29B15B4A8; Thu, 22 Oct 2020 09:35:31 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24E925B4C2 for ; Thu, 22 Oct 2020 09:35:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359432; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vpt3DY23b1rQllZbwQusdUvsMc/HpSwNPU54fpfK4cI=; b=PwtdKAY3P9htbOvltp0/FUSP+K85EPwsOcXyt6yL1XM2ENivcn6nTvd3QDhoZgQKo/Lxe2 k+LA7JYaa0F2a2SGV7ai/uHPpbqkZgxVVH5SeU0RZgtEgF/rzmLOvscwfsiWWTBmocHQCm WNJJT8Mjx4iNghVc0eIF6w9UvAkELsI= X-MC-Unique: 5Dz5yaXINWqH1_K9Uf4QTw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/15] util: virhash: Remove key handling callbacks Date: Thu, 22 Oct 2020 11:35:05 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Since we use virHashTable for string-keyed values only, we can remove all the callbacks which allowed universal keys. Code which wishes to use non-string keys should use glib's GHashTable. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/virhash.c | 68 +++++++--------------------------------------- src/util/virhash.h | 54 ------------------------------------ 2 files changed, 10 insertions(+), 112 deletions(-) diff --git a/src/util/virhash.c b/src/util/virhash.c index f386839d6b..7a20b28379 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -56,11 +56,6 @@ struct _virHashTable { size_t size; size_t nbElems; virHashDataFree dataFree; - virHashKeyCode keyCode; - virHashKeyEqual keyEqual; - virHashKeyCopy keyCopy; - virHashKeyPrintHuman keyPrint; - virHashKeyFree keyFree; }; struct _virHashAtomic { @@ -81,40 +76,10 @@ static int virHashAtomicOnceInit(void) VIR_ONCE_GLOBAL_INIT(virHashAtomic); - -static uint32_t virHashStrCode(const char *name, uint32_t seed) -{ - return virHashCodeGen(name, strlen(name), seed); -} - -static bool virHashStrEqual(const char *namea, const char *nameb) -{ - return STREQ(namea, nameb); -} - -static char *virHashStrCopy(const char *name) -{ - return g_strdup(name); -} - - -static char * -virHashStrPrintHuman(const char *name) -{ - return g_strdup(name); -} - - -static void virHashStrFree(char *name) -{ - VIR_FREE(name); -} - - static size_t virHashComputeKey(const virHashTable *table, const char *name) { - uint32_t value =3D table->keyCode(name, table->seed); + uint32_t value =3D virHashCodeGen(name, strlen(name), table->seed); return value % table->size; } @@ -138,11 +103,6 @@ virHashNew(virHashDataFree dataFree) table->size =3D 32; table->nbElems =3D 0; table->dataFree =3D dataFree; - table->keyCode =3D virHashStrCode; - table->keyEqual =3D virHashStrEqual; - table->keyCopy =3D virHashStrCopy; - table->keyPrint =3D virHashStrPrintHuman; - table->keyFree =3D virHashStrFree; table->table =3D g_new0(virHashEntryPtr, table->size); @@ -260,8 +220,7 @@ virHashFree(virHashTablePtr table) if (table->dataFree) table->dataFree(iter->payload); - if (table->keyFree) - table->keyFree(iter->name); + g_free(iter->name); VIR_FREE(iter); iter =3D next; } @@ -287,20 +246,15 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const = char *name, /* Check for duplicate entry */ for (entry =3D table->table[key]; entry; entry =3D entry->next) { - if (table->keyEqual(entry->name, name)) { + if (STREQ(entry->name, name)) { if (is_update) { if (table->dataFree) table->dataFree(entry->payload); entry->payload =3D userdata; return 0; } else { - g_autofree char *keystr =3D NULL; - - if (table->keyPrint) - keystr =3D table->keyPrint(name); - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Duplicate hash table key '%s'"), NULLSTR= (keystr)); + _("Duplicate hash table key '%s'"), name); return -1; } } @@ -309,7 +263,7 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const ch= ar *name, } entry =3D g_new0(virHashEntry, 1); - entry->name =3D table->keyCopy(name); + entry->name =3D g_strdup(name); entry->payload =3D userdata; if (last) @@ -388,7 +342,7 @@ virHashGetEntry(const virHashTable *table, key =3D virHashComputeKey(table, name); for (entry =3D table->table[key]; entry; entry =3D entry->next) { - if (table->keyEqual(entry->name, name)) + if (STREQ(entry->name, name)) return entry; } @@ -510,11 +464,10 @@ virHashRemoveEntry(virHashTablePtr table, const char = *name) nextptr =3D table->table + virHashComputeKey(table, name); for (entry =3D *nextptr; entry; entry =3D entry->next) { - if (table->keyEqual(entry->name, name)) { + if (STREQ(entry->name, name)) { if (table->dataFree) table->dataFree(entry->payload); - if (table->keyFree) - table->keyFree(entry->name); + g_free(entry->name); *nextptr =3D entry->next; VIR_FREE(entry); table->nbElems--; @@ -601,8 +554,7 @@ virHashRemoveSet(virHashTablePtr table, count++; if (table->dataFree) table->dataFree(entry->payload); - if (table->keyFree) - table->keyFree(entry->name); + g_free(entry->name); *nextptr =3D entry->next; VIR_FREE(entry); table->nbElems--; @@ -669,7 +621,7 @@ void *virHashSearch(const virHashTable *ctable, for (entry =3D table->table[i]; entry; entry =3D entry->next) { if (iter(entry->payload, entry->name, data)) { if (name) - *name =3D table->keyCopy(entry->name); + *name =3D g_strdup(entry->name); return entry->payload; } } diff --git a/src/util/virhash.h b/src/util/virhash.h index 78c7459390..d7cea75c35 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -54,60 +54,6 @@ typedef int (*virHashIterator) (void *payload, const cha= r *name, void *data); typedef int (*virHashSearcher) (const void *payload, const char *name, const void *data); -/** - * virHashKeyCode: - * @name: the hash key - * @seed: random seed - * - * Compute the hash code corresponding to the key @name, using - * @seed to perturb the hashing algorithm - * - * Returns the hash code - */ -typedef uint32_t (*virHashKeyCode)(const char *name, - uint32_t seed); -/** - * virHashKeyEqual: - * @namea: the first hash key - * @nameb: the second hash key - * - * Compare two hash keys for equality - * - * Returns true if the keys are equal, false otherwise - */ -typedef bool (*virHashKeyEqual)(const char *namea, const char *nameb); -/** - * virHashKeyCopy: - * @name: the hash key - * - * Create a copy of the hash key, duplicating - * memory allocation where applicable - * - * Returns a copy of @name which will eventually be passed to the - * 'virHashKeyFree' callback at the end of its lifetime. - */ -typedef char *(*virHashKeyCopy)(const char *name); -/** - * virHashKeyPrintHuman: - * @name: the hash key - * - * Get a human readable version of the key for error messages. Caller - * will free the returned string. - * - * Returns a string representation of the key for use in error messages. C= aller - * promises to always free the returned string. - */ -typedef char *(*virHashKeyPrintHuman) (const char *name); - -/** - * virHashKeyFree: - * @name: the hash key - * - * Free any memory associated with the hash - * key @name - */ -typedef void (*virHashKeyFree)(char *name); - /* * Constructor and destructor. */ --=20 2.26.2 From nobody Mon May 6 13:32:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603359435; cv=none; d=zohomail.com; s=zohoarc; b=dS6/3EyIA7rNwUvymXpxbKwlKQJoFOR3Zyx0P9IHPMQLj6pn0STHNshoyrmZNGDHt8qHNoz9k0yulkJW5wsQKoAYME3yfQDgwMLPaRDo0/sKTKi/b73Eg1Eqf14pLJdZ5JciGS46kHnMZtP6vJTQjit9LgaEbN4Gjv7YeSlkZkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359435; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Hi4nk+g3kDeqSipve4Sa2V5VeVekTu7EjQvZCxAManM=; b=b1SZdf9D6PbK1Xf+iYjZ4fx+cJ60/mBDoiEDO0Mu8AtdERrG5CijXECpJDUvG2cbQO0Cs/qd1EmRgOdux2PPmwtPo9KrLbqsqcC2sPAckIz/NLpcE/SgYZk0nPTx3T15pxfNL/XCzUMHNgSV3W4YCZ8IfAS78HKXTdjV0WeTrS8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603359435533301.6135426393239; Thu, 22 Oct 2020 02:37:15 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-548-HaT7b_AHOJOJiN36IOt3pw-1; Thu, 22 Oct 2020 05:36:15 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7DDB81018F77; Thu, 22 Oct 2020 09:36:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53CF755774; Thu, 22 Oct 2020 09:36:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1AE5A181A71F; Thu, 22 Oct 2020 09:36:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZWmY024616 for ; Thu, 22 Oct 2020 05:35:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id DFFA45B4C0; Thu, 22 Oct 2020 09:35:32 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 371705B4A8 for ; Thu, 22 Oct 2020 09:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359434; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Hi4nk+g3kDeqSipve4Sa2V5VeVekTu7EjQvZCxAManM=; b=a3tSdjuDcIMtlHmPJiAiuSdqAcuviKUIU9MnKEJkRnUOxFMAXBiLm3KHZKotq/M3kCY8jX zFIJ8YmBNYOoh22kKosoTNsah1wLskvq0yTqdxSjeMUY2CjGC2c993Nb2sFCrTd23XnujL BSTzAxGMo9Z2m01qX4mGCq5rVe1LI0k= X-MC-Unique: HaT7b_AHOJOJiN36IOt3pw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/15] virHashRemoveAll: Don't return number of removed items Date: Thu, 22 Oct 2020 11:35:06 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Nobody uses the return value. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/virhash.c | 8 ++------ src/util/virhash.h | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/util/virhash.c b/src/util/virhash.c index 7a20b28379..301e485e69 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -579,15 +579,11 @@ _virHashRemoveAllIter(const void *payload G_GNUC_UNUS= ED, * * Free the hash @table's contents. The userdata is * deallocated with the function provided at creation time. - * - * Returns the number of items removed on success, -1 on failure */ -ssize_t +void virHashRemoveAll(virHashTablePtr table) { - return virHashRemoveSet(table, - _virHashRemoveAllIter, - NULL); + virHashRemoveSet(table, _virHashRemoveAllIter, NULL); } /** diff --git a/src/util/virhash.h b/src/util/virhash.h index d7cea75c35..029e6e83b7 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -83,7 +83,7 @@ int virHashRemoveEntry(virHashTablePtr table, /* * Remove all entries from the hash table. */ -ssize_t virHashRemoveAll(virHashTablePtr table); +void virHashRemoveAll(virHashTablePtr table); /* * Retrieve the userdata. --=20 2.26.2