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

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

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

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

* 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(-)


@@ -2880,13 +2881,21 @@ int qemuMonitorTextSendKey(qemuMonitorPtr mon,
                           _("failed to send key using command '%s'"),
-        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 redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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