From nobody Mon Feb 9 00:55:41 2026 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