render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
c480ed
From 14c5258d4227930fdadcd0bc9de3cae547b56b70 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <14c5258d4227930fdadcd0bc9de3cae547b56b70@dist-git>
c480ed
From: Jiri Denemark <jdenemar@redhat.com>
c480ed
Date: Fri, 21 Jun 2019 09:26:07 +0200
c480ed
Subject: [PATCH] cpu_x86: Turn virCPUx86DataIteratorInit into a function
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
Until now, this was a macro usable for direct initialization when a
c480ed
variable is defined. Turning the macro into a function makes it more
c480ed
general.
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
(cherry picked from commit b8e086a570b14b1f83fc07e25df6da758abe7706)
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
c480ed
c480ed
Conflicts:
c480ed
	src/cpu/cpu_x86.c
c480ed
            - commit c9ed87a6103fd4f09e0714f3a2b94c4c975477cd was not
c480ed
              backported
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Message-Id: <eb52120d5047b6581f645dc334a327530261f5ed.1561068591.git.jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/cpu/cpu_x86.c | 35 ++++++++++++++++++++++++-----------
c480ed
 1 file changed, 24 insertions(+), 11 deletions(-)
c480ed
c480ed
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
c480ed
index ead962ae06..75527fd28f 100644
c480ed
--- a/src/cpu/cpu_x86.c
c480ed
+++ b/src/cpu/cpu_x86.c
c480ed
@@ -187,8 +187,13 @@ struct _virCPUx86DataIterator {
c480ed
 };
c480ed
 
c480ed
 
c480ed
-#define virCPUx86DataIteratorInit(data) \
c480ed
-    { data, -1 }
c480ed
+static void
c480ed
+virCPUx86DataIteratorInit(virCPUx86DataIteratorPtr iterator,
c480ed
+                          const virCPUx86Data *data)
c480ed
+{
c480ed
+    virCPUx86DataIterator iter = { data, -1 };
c480ed
+    *iterator = iter;
c480ed
+}
c480ed
 
c480ed
 
c480ed
 static bool
c480ed
@@ -538,9 +543,10 @@ static int
c480ed
 x86DataAdd(virCPUx86Data *data1,
c480ed
            const virCPUx86Data *data2)
c480ed
 {
c480ed
-    virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data2);
c480ed
+    virCPUx86DataIterator iter;
c480ed
     virCPUx86DataItemPtr item;
c480ed
 
c480ed
+    virCPUx86DataIteratorInit(&iter, data2);
c480ed
     while ((item = virCPUx86DataNext(&iter))) {
c480ed
         if (virCPUx86DataAddItem(data1, item) < 0)
c480ed
             return -1;
c480ed
@@ -554,10 +560,11 @@ static void
c480ed
 x86DataSubtract(virCPUx86Data *data1,
c480ed
                 const virCPUx86Data *data2)
c480ed
 {
c480ed
-    virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data1);
c480ed
+    virCPUx86DataIterator iter;
c480ed
     virCPUx86DataItemPtr item1;
c480ed
     virCPUx86DataItemPtr item2;
c480ed
 
c480ed
+    virCPUx86DataIteratorInit(&iter, data1);
c480ed
     while ((item1 = virCPUx86DataNext(&iter))) {
c480ed
         item2 = virCPUx86DataGet(data2, item1);
c480ed
         virCPUx86DataItemClearBits(item1, item2);
c480ed
@@ -569,10 +576,11 @@ static void
c480ed
 x86DataIntersect(virCPUx86Data *data1,
c480ed
                  const virCPUx86Data *data2)
c480ed
 {
c480ed
-    virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data1);
c480ed
+    virCPUx86DataIterator iter;
c480ed
     virCPUx86DataItemPtr item1;
c480ed
     virCPUx86DataItemPtr item2;
c480ed
 
c480ed
+    virCPUx86DataIteratorInit(&iter, data1);
c480ed
     while ((item1 = virCPUx86DataNext(&iter))) {
c480ed
         item2 = virCPUx86DataGet(data2, item1);
c480ed
         if (item2)
c480ed
@@ -586,8 +594,9 @@ x86DataIntersect(virCPUx86Data *data1,
c480ed
 static bool
c480ed
 x86DataIsEmpty(virCPUx86Data *data)
c480ed
 {
c480ed
-    virCPUx86DataIterator iter = virCPUx86DataIteratorInit(data);
c480ed
+    virCPUx86DataIterator iter;
c480ed
 
c480ed
+    virCPUx86DataIteratorInit(&iter, data);
c480ed
     return !virCPUx86DataNext(&iter);
c480ed
 }
c480ed
 
c480ed
@@ -596,11 +605,11 @@ static bool
c480ed
 x86DataIsSubset(const virCPUx86Data *data,
c480ed
                 const virCPUx86Data *subset)
c480ed
 {
c480ed
-
c480ed
-    virCPUx86DataIterator iter = virCPUx86DataIteratorInit((virCPUx86Data *)subset);
c480ed
+    virCPUx86DataIterator iter;
c480ed
     const virCPUx86DataItem *item;
c480ed
     const virCPUx86DataItem *itemSubset;
c480ed
 
c480ed
+    virCPUx86DataIteratorInit(&iter, subset);
c480ed
     while ((itemSubset = virCPUx86DataNext(&iter))) {
c480ed
         if (!(item = virCPUx86DataGet(data, itemSubset)) ||
c480ed
             !virCPUx86DataItemMatchMasked(item, itemSubset))
c480ed
@@ -1313,11 +1322,13 @@ x86ModelCompare(virCPUx86ModelPtr model1,
c480ed
                 virCPUx86ModelPtr model2)
c480ed
 {
c480ed
     virCPUx86CompareResult result = EQUAL;
c480ed
-    virCPUx86DataIterator iter1 = virCPUx86DataIteratorInit(&model1->data);
c480ed
-    virCPUx86DataIterator iter2 = virCPUx86DataIteratorInit(&model2->data);
c480ed
+    virCPUx86DataIterator iter1;
c480ed
+    virCPUx86DataIterator iter2;
c480ed
     virCPUx86DataItemPtr item1;
c480ed
     virCPUx86DataItemPtr item2;
c480ed
 
c480ed
+    virCPUx86DataIteratorInit(&iter1, &model1->data);
c480ed
+    virCPUx86DataIteratorInit(&iter2, &model2->data);
c480ed
     while ((item1 = virCPUx86DataNext(&iter1))) {
c480ed
         virCPUx86CompareResult match = SUPERSET;
c480ed
 
c480ed
@@ -1623,10 +1634,12 @@ virCPUx86GetMap(void)
c480ed
 static char *
c480ed
 virCPUx86DataFormat(const virCPUData *data)
c480ed
 {
c480ed
-    virCPUx86DataIterator iter = virCPUx86DataIteratorInit(&data->data.x86);
c480ed
+    virCPUx86DataIterator iter;
c480ed
     virCPUx86DataItemPtr item;
c480ed
     virBuffer buf = VIR_BUFFER_INITIALIZER;
c480ed
 
c480ed
+    virCPUx86DataIteratorInit(&iter, &data->data.x86);
c480ed
+
c480ed
     virBufferAddLit(&buf, "<cpudata arch='x86'>\n");
c480ed
     while ((item = virCPUx86DataNext(&iter))) {
c480ed
         virCPUx86CPUIDPtr cpuid;
c480ed
-- 
c480ed
2.22.0
c480ed