virCPUx86DataSorter already compares two virCPUx86DataItem structs.
Let's add a tiny wrapper around it called virCPUx86DataCmp and use it
instead of open coded comparisons.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/cpu/cpu_x86.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 41067617df..74d157d780 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -306,6 +306,13 @@ virCPUx86DataSorter(const void *a, const void *b)
return 0;
}
+static int
+virCPUx86DataItemCmp(const virCPUx86DataItem *item1,
+ const virCPUx86DataItem *item2)
+{
+ return virCPUx86DataSorter(item1, item2);
+}
+
/* skips all zero CPUID leaves */
static virCPUx86DataItemPtr
@@ -334,9 +341,9 @@ virCPUx86DataGet(const virCPUx86Data *data,
size_t i;
for (i = 0; i < data->len; i++) {
- if (data->items[i].cpuid.eax_in == item->cpuid.eax_in &&
- data->items[i].cpuid.ecx_in == item->cpuid.ecx_in)
- return data->items + i;
+ virCPUx86DataItemPtr di = data->items + i;
+ if (virCPUx86DataItemCmp(di, item) == 0)
+ return di;
}
return NULL;
--
2.21.0