[libvirt PATCH 3/8] tests: qemuxmlconftest: Introduce testQemuConfMarkUsed

Ján Tomko via Devel posted 8 patches 3 weeks, 4 days ago
[libvirt PATCH 3/8] tests: qemuxmlconftest: Introduce testQemuConfMarkUsed
Posted by Ján Tomko via Devel 3 weeks, 4 days ago
From: Ján Tomko <jtomko@redhat.com>

Make the code readable enough to not need a comment.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 tests/qemuxmlconftest.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index a7e32a5a99..dea75d805f 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -598,6 +598,15 @@ testInfoCheckDuplicate(testQemuInfo *info)
 }
 
 
+static void
+testQemuConfMarkUsed(testQemuInfo *info,
+                     const char *file)
+{
+    if (file)
+        ignore_value(g_hash_table_remove(info->conf->existingTestCases, file));
+}
+
+
 /**
  * testQemuConfXMLCommon: Prepare common test data (e.g. parse input XML)
  * for a test case.
@@ -630,14 +639,10 @@ testQemuConfXMLCommon(testQemuInfo *info,
     if (info->prepared)
         goto cleanup;
 
-    /* mark test case as used */
-    ignore_value(g_hash_table_remove(info->conf->existingTestCases, info->infile));
-    if (info->outfile)
-        ignore_value(g_hash_table_remove(info->conf->existingTestCases, info->outfile));
-    if (info->errfile)
-        ignore_value(g_hash_table_remove(info->conf->existingTestCases, info->errfile));
-    if (info->out_xml_inactive)
-        ignore_value(g_hash_table_remove(info->conf->existingTestCases, info->out_xml_inactive));
+    testQemuConfMarkUsed(info, info->infile);
+    testQemuConfMarkUsed(info, info->outfile);
+    testQemuConfMarkUsed(info, info->errfile);
+    testQemuConfMarkUsed(info, info->out_xml_inactive);
 
     if (testQemuInfoInitArgs((testQemuInfo *) info) < 0)
         goto cleanup;
-- 
2.50.1