tests: qemumonitor: Optimize control flow when concatenating replies

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>
This commit is contained in:
Peter Krempa 2018-05-03 11:43:34 +02:00
parent dcea889b13
commit 1025264ec5

View 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++;
continue;
}
/* Cut off a single reply. */
*(tmp + 1) = '\0';
if (response) {
if (qemuMonitorTestFullAddItem(ret, fileName, command,
response, commandln) < 0)
goto error;
command = NULL;
response = NULL;
}
/* Move the @tmp and @singleReply. */
tmp += 2;
if (!command) {
commandln = line;
command = tmp;
} else {
/* Cut off a single reply. */
*(tmp + 1) = '\0';
if (response) {
if (qemuMonitorTestFullAddItem(ret, fileName, command,
response, commandln) < 0)
goto error;
command = NULL;
response = NULL;
}
/* Move the @tmp and @singleReply. */
tmp += 2;
if (!command) {
commandln = line;
command = tmp;
} else {
response = tmp;
}
response = tmp;
}
}