]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: fix text block info parsing
authorEric Blake <eblake@redhat.com>
Thu, 13 Oct 2011 00:27:20 +0000 (18:27 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 13 Oct 2011 19:44:02 +0000 (13:44 -0600)
Detected by Coverity.  p (the pointer to the string) is always true;
when in reality, we wanted to know whether the integer value of the
just-parsed string is '0' or '1'.  Logic bug since commit b1b5b51.

* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetBlockInfo): Set
results to proper value.

src/qemu/qemu_monitor_text.c

index 1eb9846ac24525a1ae9f4ddb937ecc5cc5a35488..2f31d990e9b035d67ba8e61f1fcb99fe95aa3999 100644 (file)
@@ -817,19 +817,19 @@ int qemuMonitorTextGetBlockInfo(qemuMonitorPtr mon,
                     if (virStrToLong_i(p, &dummy, 10, &tmp) == -1)
                         VIR_DEBUG("error reading removable: %s", p);
                     else
-                        info->removable = p != NULL;
+                        info->removable = (tmp != 0);
                 } else if (STRPREFIX(p, "locked=")) {
                     p += strlen("locked=");
                     if (virStrToLong_i(p, &dummy, 10, &tmp) == -1)
                         VIR_DEBUG("error reading locked: %s", p);
                     else
-                        info->locked = p ? true : false;
+                        info->locked = (tmp != 0);
                 } else if (STRPREFIX(p, "tray_open=")) {
                     p += strlen("tray_open=");
                     if (virStrToLong_i(p, &dummy, 10, &tmp) == -1)
                         VIR_DEBUG("error reading tray_open: %s", p);
                     else
-                        info->tray_open = p ? true : false;
+                        info->tray_open = (tmp != 0);
                 } else {
                     /* ignore because we don't parse all options */
                 }