Re: [PATCH 2/2] Detect errors from the 'sendkey' command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/25/2011 10:49 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange"<berrange@xxxxxxxxxx>

On success, the 'sendkey' command does not return any data, so
any data in the reply should be considered to be an error
message

* src/qemu/qemu_monitor_text.c: Treat non-"" reply data as an
   error message for 'sendkey' command
---
  src/qemu/qemu_monitor_text.c |   15 ++++++++++++---
  1 files changed, 12 insertions(+), 3 deletions(-)

ACK.

@@ -2880,13 +2881,21 @@ int qemuMonitorTextSendKey(qemuMonitorPtr mon,
          qemuReportError(VIR_ERR_OPERATION_FAILED,
                           _("failed to send key using command '%s'"),
                           cmd);
-        VIR_FREE(cmd);
-        return -1;
+        goto cleanup;
+    }
+
+    if (STRNEQ(reply, "")) {

I would have written this as:

if (*reply) {

but I think the compiler is sufficiently smart to optimize strcmp(expr,"") into a test for the first byte of expr (and if not, that would be a missed optimization in gcc).

--
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]