]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: qemumonitor: Optimize control flow when concatenating replies
authorPeter Krempa <pkrempa@redhat.com>
Thu, 3 May 2018 09:43:34 +0000 (11:43 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 Jun 2018 08:27:50 +0000 (10:27 +0200)
The test file can be broken up by newlines and is automatically
concatenated back. Fix the control flow so that the concatenation code
'continues' the loop rather than branching out.

Also add an anotation to the concatenation code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
tests/qemumonitortestutils.c

index 4bfe629909e6370ed5cafbfa9d612c2095f39254..d857c381a4f3ee2dd9b74e745d27afbd824eaa33 100644 (file)
@@ -1423,30 +1423,32 @@ qemuMonitorTestNewFromFileFull(const char *fileName,
         if (!tmp[1])
             break;
 
+        /* concatenate block which was broken up for readability */
         if (*(tmp + 1) != '\n') {
             *tmp = ' ';
             tmp++;
-        } else {
-            /* Cut off a single reply. */
-            *(tmp + 1) = '\0';
+            continue;
+        }
 
-            if (response) {
-                if (qemuMonitorTestFullAddItem(ret, fileName, command,
-                                               response, commandln) < 0)
-                    goto error;
-                command = NULL;
-                response = NULL;
-            }
+        /* Cut off a single reply. */
+        *(tmp + 1) = '\0';
 
-            /* Move the @tmp and @singleReply. */
-            tmp += 2;
+        if (response) {
+            if (qemuMonitorTestFullAddItem(ret, fileName, command,
+                                           response, commandln) < 0)
+                goto error;
+            command = NULL;
+            response = NULL;
+        }
 
-            if (!command) {
-                commandln = line;
-                command = tmp;
-            } else {
-                response = tmp;
-            }
+        /* Move the @tmp and @singleReply. */
+        tmp += 2;
+
+        if (!command) {
+            commandln = line;
+            command = tmp;
+        } else {
+            response = tmp;
         }
     }