From nobody Sat May 4 05:11:59 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=1603107368; cv=none; d=zohomail.com; s=zohoarc; b=LweJClu6OuFt0Wik3NcKLjlky4g9AM7x1XhiCaL8nbzaxL5ZdpRMxNyoY+ksSksu/dbaSo5KXGobxYLvQzme0ovJMuKACi3RSXIoP4Ty29u6gjM/yh2bozamn+OThf+gj7TwA6ppMadznZhv8iugYgtxey9JihpNi8Bxn7vwREE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603107368; 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=d/8gY8I2AsE0kTnb5VRAcorO5H2V/50JtrDL7n0LrQY=; b=iIM+q2XvCF+XAjGk1aEt4tLlh/DfqOFxGAv0urNYxsddIVrIKsbXtb7k5myZR2ZXhbH7nXVVX2zlZl4ieBILy/hnDCSvy6WVbe6g8ilDDheji+pFyDD6yPsA9fRduiW+z2IaqAI2W1ZCm4jMvJnoKBTaqlVcdKSM9EaQTOMRYIs= 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 160310736804931.184968564391397; Mon, 19 Oct 2020 04:36:08 -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-551-4vHbFJOuO8OtdNpRt_RYGQ-1; Mon, 19 Oct 2020 07:36:04 -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 72D891019624; Mon, 19 Oct 2020 11:35:58 +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 482F419C71; Mon, 19 Oct 2020 11:35:58 +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 E6D7D180C5A2; Mon, 19 Oct 2020 11:35:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09JBZGHa024879 for ; Mon, 19 Oct 2020 07:35:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF86655781; Mon, 19 Oct 2020 11:35:16 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E98255761 for ; Mon, 19 Oct 2020 11:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603107367; 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=d/8gY8I2AsE0kTnb5VRAcorO5H2V/50JtrDL7n0LrQY=; b=STdTRpQxjL00LtLr7IIoN06A8vkHE4k0xvu+nO3XYzwmuphYcxCU6e5e9ZNf6jcbHYyb2L BAg2aDXtKmSRNBuUyY1P67AcGD87R6b8Omtx4XBS5qHWm1uLiV4ODS4knrOyXPCz7eUuX5 nX9Fhx4H2OiKlqcSEmN+yQPFsZ4wSMg= X-MC-Unique: 4vHbFJOuO8OtdNpRt_RYGQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] hyperv: Accept const @value in hypervSetEmbeddedProperty() Date: Mon, 19 Oct 2020 13:35:05 +0200 Message-Id: <2a0ea1454839e6864a9b70be6dabd2bf91b32e7f.1603107255.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" The hypervSetEmbeddedProperty() function is used to update a value for given property in a list of properties created by hypervCreateEmbeddedParam(). The list is nothing fancy - it's a virHashTable that has NULL as dataFree callback =3D> the table does not own the value. This is not that obvious since hypervSetEmbeddedProperty() accepts a non-const pointer. This fact makes it unnecessary hard to consume, e.g. if we wanted to pass a stack allocated string. Signed-off-by: Michal Privoznik --- src/hyperv/hyperv_wmi.c | 20 ++++++++++++++++++-- src/hyperv/hyperv_wmi.h | 5 +++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 41579858de..742a46bc28 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -351,10 +351,26 @@ hypervCreateEmbeddedParam(hypervPrivate *priv, hyperv= WmiClassInfoListPtr info) return NULL; } =20 + +/** + * hypervSetEmbeddedProperty: + * @table: hash table allocated earlier by hypervCreateEmbeddedParam() + * @name: name of the property + * @value: value of the property + * + * For given table of properties, set property of @name to @value. + * Please note, that the hash table does NOT become owner of the @value and + * thus caller must ensure the pointer validity. + * + * Returns: 0 on success, + * -1 otherwise. + */ int -hypervSetEmbeddedProperty(virHashTablePtr table, const char *name, char *v= alue) +hypervSetEmbeddedProperty(virHashTablePtr table, + const char *name, + const char *value) { - return virHashUpdateEntry(table, name, value); + return virHashUpdateEntry(table, name, (void*) value); } =20 /* diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index fb19a7f375..fa8e48a70e 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -146,8 +146,9 @@ int hypervAddEprParam(hypervInvokeParamsListPtr params,= const char *name, virHashTablePtr hypervCreateEmbeddedParam(hypervPrivate *priv, hypervWmiClassInfoListPtr info); =20 -int hypervSetEmbeddedProperty(virHashTablePtr table, const char *name, - char *value); +int hypervSetEmbeddedProperty(virHashTablePtr table, + const char *name, + const char *value); =20 int hypervAddEmbeddedParam(hypervInvokeParamsListPtr params, hypervPrivate *priv, --=20 2.26.2 From nobody Sat May 4 05:11:59 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=1603107370; cv=none; d=zohomail.com; s=zohoarc; b=P8K8g/9ZVsmnpTHediEqUsKXk2rRcWV4HFg9SUO53/u21HGsAB+hI8gpAqDA3y9/FNbHGmhqRkQftI307mc7UmYuNwbsWuwqwvFCD0bXCTW6u4ZDnl8NkVskkyGVD4a9ufX9SJzDCuvJVuC67JxBjSSVZmAJni/rX6H8/y+15qQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603107370; 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=G+QrpTrslP+URSkDFlO4f1LFBTkt/qgkVthHySGP27w=; b=gLg8dQNvrHBIuaoPNRNnUyoB2oHIHGVV3n40w7Xuu1/QeRCHGC6iCJQT7BhvFTXmb512xywW3mgqMYSq+THuuYASdMxg0PsNVXttofrdGbN6oxuM6uu3H488bkkJJe4kB4CfHoOSptBuMHfimR9Cehc7pK418TYvFpn7Dzwo4Us= 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 1603107370583139.5603638372363; Mon, 19 Oct 2020 04:36:10 -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-322-hj628Z3vN0avkDZqocpBcA-1; Mon, 19 Oct 2020 07:36:07 -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 F275A1019629; Mon, 19 Oct 2020 11:36:01 +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 CF8125B4B2; Mon, 19 Oct 2020 11:36:01 +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 8FE5A8C7A1; Mon, 19 Oct 2020 11:36:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09JBZH41024888 for ; Mon, 19 Oct 2020 07:35:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id B500055770; Mon, 19 Oct 2020 11:35:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2619F55761 for ; Mon, 19 Oct 2020 11:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603107369; 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=G+QrpTrslP+URSkDFlO4f1LFBTkt/qgkVthHySGP27w=; b=hVuhmwmUxi9Ts4MJnaj6ruk56FjBu8L8iTxsooZRRAz5h+wQ+o+U1Yw/jKBt5dtkTzkb93 VT0C7yA11COOsit3HhlmT/tmsBI6890FQLCFjsyuSdn6FKm0sH5k3Mrh2+5KlqB2b0N9in DDlvTvL3c1EJbMRtWjiPH6SIYp9qhyc= X-MC-Unique: hj628Z3vN0avkDZqocpBcA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] hyperv: Use g_auto() for virHashTable in hypervCreateEmbeddedParam Date: Mon, 19 Oct 2020 13:35:06 +0200 Message-Id: <5187e4c31a7e0242ec56f1b36937949669e7dfd6.1603107255.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" This will allow us to drop 'error' label later. Signed-off-by: Michal Privoznik --- src/hyperv/hyperv_wmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 742a46bc28..2faa2f396f 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -318,7 +318,7 @@ hypervCreateEmbeddedParam(hypervPrivate *priv, hypervWm= iClassInfoListPtr info) { size_t i; int count =3D 0; - virHashTablePtr table =3D NULL; + g_autoptr(virHashTable) table =3D NULL; XmlSerializerInfo *typeinfo =3D NULL; XmlSerializerInfo *item =3D NULL; hypervWmiClassInfoPtr classInfo =3D NULL; @@ -344,10 +344,9 @@ hypervCreateEmbeddedParam(hypervPrivate *priv, hypervW= miClassInfoListPtr info) goto error; } =20 - return table; + return g_steal_pointer(&table); =20 error: - virHashFree(table); return NULL; } =20 --=20 2.26.2 From nobody Sat May 4 05:11:59 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=1603107373; cv=none; d=zohomail.com; s=zohoarc; b=TTsSlsBLbDRI6UowTz68orkwC5U3Xtg5vZWydZnjKKXlYKCo81BJeL6BwWD4cYeR/P2TsQDEzaFg2hvcm5Gq5IC5KeSV7jTpgq0qSMX+fbhduVzpisOZUkfk75p9fCDLtVG7I1cCVCWP0cDFSvtsL5vQO8CHhubfnEmUI11ZCnY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603107373; 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=romKNihgNM8+p2J9CN5fw91fEJBcJoBX1t9hXRMe7Xo=; b=bHNuJTQLrgm173p6ecHyO6eqepy0mJhYPoXvanhHZKG26OPOZOau3miRF6UnlHQoQnYC93cg0n/U8XhTGqdB2/WDRxm/0KsppKmNGk8WC3N8/0vGPZ7fhsePB+VcctzcykxSaD2W/tKukrvdHdpNWsSqZo17vgrv+L97+xeCvoQ= 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 1603107373972928.5563866768214; Mon, 19 Oct 2020 04:36: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-196-tFVEswJ1M5Wd1vkRooNPWQ-1; Mon, 19 Oct 2020 07:36:10 -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 E0BD685C737; Mon, 19 Oct 2020 11:36:04 +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 BCF9B6EF68; Mon, 19 Oct 2020 11:36:04 +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 8499B8C7A8; Mon, 19 Oct 2020 11:36:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09JBZI7x024896 for ; Mon, 19 Oct 2020 07:35:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id AA98F55784; Mon, 19 Oct 2020 11:35:18 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D15255761 for ; Mon, 19 Oct 2020 11:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603107372; 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=romKNihgNM8+p2J9CN5fw91fEJBcJoBX1t9hXRMe7Xo=; b=fi6LEjf1srNCVbCnNBwP25L4hhkrP4QIlwqTUGfRzz+HzVEaNnqZAMa0WCtetK801fH2Xb TjS4JyELJacgZl/kxXeI8hkfsERxHKlFjTAiKiPm+t7i5sD351zeeGK9aDedRDYn+WKs2I ncKDWiTyucT79mHFEwThRdvNihJJU8g= X-MC-Unique: tFVEswJ1M5Wd1vkRooNPWQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] hyperv: Drop needles error label in hypervCreateEmbeddedParam() Date: Mon, 19 Oct 2020 13:35:07 +0200 Message-Id: <8f6316249861e03d2b38f4641c9a957ea79ecbb0.1603107255.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" Signed-off-by: Michal Privoznik --- src/hyperv/hyperv_wmi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 2faa2f396f..489bb03a9b 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -325,7 +325,7 @@ hypervCreateEmbeddedParam(hypervPrivate *priv, hypervWm= iClassInfoListPtr info) =20 /* Get the typeinfo out of the class info list */ if (hypervGetWmiClassInfo(priv, info, &classInfo) < 0) - goto error; + return NULL; =20 typeinfo =3D classInfo->serializerInfo; =20 @@ -335,19 +335,16 @@ hypervCreateEmbeddedParam(hypervPrivate *priv, hyperv= WmiClassInfoListPtr info) =20 table =3D virHashCreate(count, NULL); if (table =3D=3D NULL) - goto error; + return NULL; =20 for (i =3D 0; typeinfo[i].name !=3D NULL; i++) { item =3D &typeinfo[i]; =20 if (virHashAddEntry(table, item->name, NULL) < 0) - goto error; + return NULL; } =20 return g_steal_pointer(&table); - - error: - return NULL; } =20 =20 --=20 2.26.2 From nobody Sat May 4 05:11:59 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=1603107376; cv=none; d=zohomail.com; s=zohoarc; b=DqsqjCKzbCIbpnyerFLoh7bpo8ENOg7mqAt60V5p/AdEGZBmtZNG3gbNjX+y2YtpO4UPGslbXkCnf9gPL/1+yaVzwCyB4FW6b6oeLfuY3C/I3MOlOIMPsr3a+xuj5TPsXBfZ+kyYr+P182kaQ7xDVm4+E6goFb2//6uC8er1ZU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603107376; 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=phqOqw6sxzlSHjamg8NScU2er2uREnPYE5egmfNf6XI=; b=RIyvqHMHaschGapZPtARUp9yBPnAG2jOI04uu1DuX0M33lVBeO/wAHHvcq2BTn1VWDOLa+bU6jcVNd2+C1rHzrmWTLT4ooYn/5RNn7fpBKlE5pVf9O0sKAGwBZGPFUm8s3ZKIawD0yZpRyXPHoziYLjTvDETvPiCTesz0ApZ9W4= 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 1603107376211759.8983524160159; Mon, 19 Oct 2020 04:36:16 -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-516-xPCbThO2NEmbejbS8UuHnw-1; Mon, 19 Oct 2020 07:36:13 -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 E0D1018BE166; Mon, 19 Oct 2020 11:36:07 +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 B943B55784; Mon, 19 Oct 2020 11:36:07 +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 8233B1826D36; Mon, 19 Oct 2020 11:36:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09JBZJsD024906 for ; Mon, 19 Oct 2020 07:35:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id A616F55784; Mon, 19 Oct 2020 11:35:19 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.139]) by smtp.corp.redhat.com (Postfix) with ESMTP id 171FB55761 for ; Mon, 19 Oct 2020 11:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603107375; 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=phqOqw6sxzlSHjamg8NScU2er2uREnPYE5egmfNf6XI=; b=aCA6VnsCNiwmmxYXSxMlWfGApKCb2TGXpzj0If9cMimbpUvmYlEe2+T/vqKBanoyHldn1+ aMxqZkK/A4hnxOx1vP479QMXYgH2KI4DbpG6IRtAWohUUHIdUV4fkt6CALTUlrW/7vGAvL 9G7e90YVL6ZwbEOOUIgPNhnZ6LVttiE= X-MC-Unique: xPCbThO2NEmbejbS8UuHnw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] hyverv: hypervCreateEmbeddedParam: Rework items counting Date: Mon, 19 Oct 2020 13:35:08 +0200 Message-Id: <75821e8a154a0cbb30b801ca029e934bb19bcce6.1603107255.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" It's not necessarily clear, why we need to create the hash table as big as number of fields we want to store, but nevertheless, the code can be written a bit better. The @count should be type of size_t and could be used directly in the loop that counts the fields. Signed-off-by: Michal Privoznik --- src/hyperv/hyperv_wmi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 489bb03a9b..8bebf02a50 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -317,10 +317,9 @@ virHashTablePtr hypervCreateEmbeddedParam(hypervPrivate *priv, hypervWmiClassInfoListPtr i= nfo) { size_t i; - int count =3D 0; + size_t count; g_autoptr(virHashTable) table =3D NULL; XmlSerializerInfo *typeinfo =3D NULL; - XmlSerializerInfo *item =3D NULL; hypervWmiClassInfoPtr classInfo =3D NULL; =20 /* Get the typeinfo out of the class info list */ @@ -330,15 +329,15 @@ hypervCreateEmbeddedParam(hypervPrivate *priv, hyperv= WmiClassInfoListPtr info) typeinfo =3D classInfo->serializerInfo; =20 /* loop through the items to find out how many fields there are */ - for (i =3D 0; typeinfo[i].name !=3D NULL; i++) {} - count =3D i; + for (count =3D 0; typeinfo[count].name !=3D NULL; count++) + ; =20 table =3D virHashCreate(count, NULL); if (table =3D=3D NULL) return NULL; =20 for (i =3D 0; typeinfo[i].name !=3D NULL; i++) { - item =3D &typeinfo[i]; + XmlSerializerInfo *item =3D &typeinfo[i]; =20 if (virHashAddEntry(table, item->name, NULL) < 0) return NULL; --=20 2.26.2