From nobody Sun Apr 28 08:12:15 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=1634547314; cv=none; d=zohomail.com; s=zohoarc; b=cPOrq6rrNqL0Dd+KGyUnPZiOMOeGgxnAcvgfTQrtFsE0iUDH71eIMyjOGOQ8eoy4sUKswO5HivcB5bbQn5Cjd61Atdsqw4uKBYtaPZWp5R5OBXkAKcXvUr7PIwEhCmTPBBCq80y6YwCe897gnSUq9gV0UGNekv0+dAQreO7/qPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634547314; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=A5ijpoKZ627KrpjcF/QTZaWJgAw7PYvJt5+rcBNTb18=; b=CU/aVU6BajXWrgdjCdMRZYbXSRVRFUYPLek+RVhqftHHEkZ25ofZsrfxqm/ze083vw/BpaWSA4gjsDNadVr0njtqQL1lMkDYDn/PIgB3vUVaWqhXi4OOyRL155AP0c+vDbfOa3bLq0PKxdZrfj26n+iIL0yGjbiI7Rc6gNBv0LE= 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) 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 1634547314094140.23778950589838; Mon, 18 Oct 2021 01:55:14 -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-553-JN47qMzQMZG4El5Jy_pnrw-1; Mon, 18 Oct 2021 04:55:11 -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 711A1801FCE; Mon, 18 Oct 2021 08:55:06 +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 AB31A5F4E0; Mon, 18 Oct 2021 08:55:05 +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 E6B3A1806D03; Mon, 18 Oct 2021 08:55:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19I8t2Pl025421 for ; Mon, 18 Oct 2021 04:55:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D9F7196E5; Mon, 18 Oct 2021 08:55:02 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id A33B919C79 for ; Mon, 18 Oct 2021 08:54:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634547313; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=A5ijpoKZ627KrpjcF/QTZaWJgAw7PYvJt5+rcBNTb18=; b=ZdHMWlmNhY69XkE51d7hRUKVUxCF1/11iBv129StXnGOH7quHFxhER4/iRVHB+WgIO2acD co13TV/eqr8bvcGiMx9VzslBXxS9AlLqq3O6vUX7rmmNtPfBXdzcDM1W/HwsMmxhnS4HAL 0PmhXhZfN7WJ+FhRoCWDydSu5Zd9AsA= X-MC-Unique: JN47qMzQMZG4El5Jy_pnrw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu: Decrease scope of variables in qemuConnectGetAllDomainStats() Date: Mon, 18 Oct 2021 10:54:55 +0200 Message-Id: <4d562ecb89f1c9b67c55abde1bc178e032af0c3f.1634547295.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1634547314833100001 Content-Type: text/plain; charset="utf-8" There are two variables (@vm and @domflags) in qemuConnectGetAllDomainStats= () that are used only within the for() loop but declared for entire function. Bring them into the loop to make it obvious they are not used outside of it. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/qemu/qemu_driver.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9bcba4b9a4..b9cc8f8379 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18811,14 +18811,12 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, virQEMUDriver *driver =3D conn->privateData; virErrorPtr orig_err =3D NULL; virDomainObj **vms =3D NULL; - virDomainObj *vm; size_t nvms; virDomainStatsRecordPtr *tmpstats =3D NULL; bool enforce =3D !!(flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_= STATS); int nstats =3D 0; size_t i; int ret =3D -1; - unsigned int domflags =3D 0; unsigned int lflags =3D flags & (VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTI= VE | VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSIS= TENT | VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE); @@ -18848,12 +18846,11 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, tmpstats =3D g_new0(virDomainStatsRecordPtr, nvms + 1); =20 for (i =3D 0; i < nvms; i++) { + virDomainObj *vm =3D vms[i]; virDomainStatsRecordPtr tmp =3D NULL; unsigned int privflags =3D 0; unsigned int requestedStats =3D stats; - - domflags =3D 0; - vm =3D vms[i]; + unsigned int domflags =3D 0; =20 virObjectLock(vm); =20 --=20 2.32.0