From: Peter Krempa Date: Thu, 3 May 2018 09:38:23 +0000 (+0200) Subject: tests: qemumonitor: Simplify handling of end of file in full file test X-Git-Tag: v4.5.0-rc1~143 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcea889b134e01f41e692ab0886efc0af0647835;p=thirdparty%2Flibvirt.git tests: qemumonitor: Simplify handling of end of file in full file test On EOF, the loop can be terminated right away since most of it is skipped anyways and the handling of the last command is repeated after the loop. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 789eb72196..4bfe629909 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -1417,9 +1417,12 @@ qemuMonitorTestNewFromFileFull(const char *fileName, tmp = jsonstr; command = tmp; while ((tmp = strchr(tmp, '\n'))) { - bool eof = !tmp[1]; line++; + /* eof */ + if (!tmp[1]) + break; + if (*(tmp + 1) != '\n') { *tmp = ' '; tmp++; @@ -1435,21 +1438,16 @@ qemuMonitorTestNewFromFileFull(const char *fileName, response = NULL; } - if (!eof) { - /* Move the @tmp and @singleReply. */ - tmp += 2; + /* Move the @tmp and @singleReply. */ + tmp += 2; - if (!command) { - commandln = line; - command = tmp; - } else { - response = tmp; - } + if (!command) { + commandln = line; + command = tmp; + } else { + response = tmp; } } - - if (eof) - break; } if (command) {