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 <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
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++;
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) {