]> xenbits.xensource.com Git - libvirt.git/commitdiff
Don't assume buffered output echoes the command.
authorMiloslav Trmač <mitr@redhat.com>
Tue, 21 Jul 2009 09:33:24 +0000 (11:33 +0200)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 1 Sep 2009 17:36:59 +0000 (18:36 +0100)
The if ((nlptr...)) implicitly assumes commptr != NULL (and that "buf"
starts with "cmd").  Make the assumption explicit, it will be broken in
a future patch.

* src/qemu_driver.c: Don't assume buffered monitor output echoes the
  command.

src/qemu_driver.c

index 3ebe8020e287ff4f2ecb2e9675193f0cbad2a77e..ad7b80a8eda9b376260b5ae2650c88d9e3068c9e 100644 (file)
@@ -2473,10 +2473,11 @@ qemudMonitorCommandExtra(const virDomainObjPtr vm,
                  * occurence, and inbetween the command and the newline starting
                  * the response
                  */
-                if ((commptr = strstr(buf, cmd)))
+                if ((commptr = strstr(buf, cmd))) {
                     memmove(buf, commptr, strlen(commptr)+1);
-                if ((nlptr = strchr(buf, '\n')))
-                    memmove(buf+strlen(cmd), nlptr, strlen(nlptr)+1);
+                    if ((nlptr = strchr(buf, '\n')))
+                        memmove(buf+strlen(cmd), nlptr, strlen(nlptr)+1);
+                }
 
                 break;
             }