[PATCH 4/4] virCapabilitiesHostNUMAFormat: Bring variables into loops

Michal Privoznik mprivozn at redhat.com
Mon May 17 12:44:18 UTC 2021


Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/conf/capabilities.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 1dae6d38cc..915cd3149e 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -807,8 +807,6 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf,
                               virCapsHostNUMA *caps)
 {
     size_t i;
-    size_t j;
-    char *siblings;
 
     if (!caps)
         return 0;
@@ -819,6 +817,8 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf,
     virBufferAdjustIndent(buf, 2);
     for (i = 0; i < caps->cells->len; i++) {
         virCapsHostNUMACell *cell = g_ptr_array_index(caps->cells, i);
+        size_t j;
+
         virBufferAsprintf(buf, "<cell id='%d'>\n", cell->num);
         virBufferAdjustIndent(buf, 2);
 
@@ -847,10 +847,12 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf,
 
         virBufferAsprintf(buf, "<cpus num='%d'>\n", cell->ncpus);
         virBufferAdjustIndent(buf, 2);
-        for (j = 0; j < cell->ncpus; j++) {
+        for (j = 0; j < cell->ncpus; ++j) {
             virBufferAsprintf(buf, "<cpu id='%d'", cell->cpus[j].id);
 
             if (cell->cpus[j].siblings) {
+                g_autofree char * siblings = NULL;
+
                 if (!(siblings = virBitmapFormat(cell->cpus[j].siblings)))
                     return -1;
 
@@ -860,7 +862,6 @@ virCapabilitiesHostNUMAFormat(virBuffer *buf,
                                   cell->cpus[j].die_id,
                                   cell->cpus[j].core_id,
                                   siblings);
-                VIR_FREE(siblings);
             }
             virBufferAddLit(buf, "/>\n");
         }
-- 
2.26.3




More information about the libvir-list mailing list