The same operation will become useful in other places so rename the
function to be more generic and move it to the top so that it can be
reused earlier in the file.
---
src/qemu/qemu_block.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 22de70657..3afcbde94 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -27,6 +27,24 @@
#define VIR_FROM_THIS VIR_FROM_QEMU
+static int
+qemuBlockNamedNodesArrayToHash(size_t pos ATTRIBUTE_UNUSED,
+ virJSONValuePtr item,
+ void *opaque)
+{
+ virHashTablePtr table = opaque;
+ const char *name;
+
+ if (!(name = virJSONValueObjectGetString(item, "node-name")))
+ return 1;
+
+ if (virHashAddEntry(table, name, item) < 0)
+ return -1;
+
+ return 0;
+}
+
+
static void
qemuBlockNodeNameBackingChainDataFree(qemuBlockNodeNameBackingChainDataPtr data)
{
@@ -384,24 +402,6 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
}
-static int
-qemuBlockFillNodeData(size_t pos ATTRIBUTE_UNUSED,
- virJSONValuePtr item,
- void *opaque)
-{
- virHashTablePtr table = opaque;
- const char *name;
-
- if (!(name = virJSONValueObjectGetString(item, "node-name")))
- return 1;
-
- if (virHashAddEntry(table, name, item) < 0)
- return -1;
-
- return 0;
-}
-
-
/**
* qemuBlockGetNodeData:
* @data: JSON object returned from query-named-block-nodes
@@ -419,7 +419,7 @@ qemuBlockGetNodeData(virJSONValuePtr data)
if (!(ret = virHashCreate(50, virJSONValueHashFree)))
return NULL;
- if (virJSONValueArrayForeachSteal(data, qemuBlockFillNodeData, ret) < 0)
+ if (virJSONValueArrayForeachSteal(data, qemuBlockNamedNodesArrayToHash, ret) < 0)
goto error;
return ret;
--
2.13.2