]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Decrease scope of variables in qemuConnectGetAllDomainStats()
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 18 Oct 2021 08:52:47 +0000 (10:52 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 18 Oct 2021 10:09:39 +0000 (12:09 +0200)
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 <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/qemu/qemu_driver.c

index 9bcba4b9a45f8222c171cd73b09c83999035bbdb..b9cc8f8379c7f0547f609512b9579474d4895480 100644 (file)
@@ -18811,14 +18811,12 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
     virQEMUDriver *driver = conn->privateData;
     virErrorPtr orig_err = NULL;
     virDomainObj **vms = NULL;
-    virDomainObj *vm;
     size_t nvms;
     virDomainStatsRecordPtr *tmpstats = NULL;
     bool enforce = !!(flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS);
     int nstats = 0;
     size_t i;
     int ret = -1;
-    unsigned int domflags = 0;
     unsigned int lflags = flags & (VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE |
                                    VIR_CONNECT_LIST_DOMAINS_FILTERS_PERSISTENT |
                                    VIR_CONNECT_LIST_DOMAINS_FILTERS_STATE);
@@ -18848,12 +18846,11 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
     tmpstats = g_new0(virDomainStatsRecordPtr, nvms + 1);
 
     for (i = 0; i < nvms; i++) {
+        virDomainObj *vm = vms[i];
         virDomainStatsRecordPtr tmp = NULL;
         unsigned int privflags = 0;
         unsigned int requestedStats = stats;
-
-        domflags = 0;
-        vm = vms[i];
+        unsigned int domflags = 0;
 
         virObjectLock(vm);