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