OSDN Git Service

qga: fix false negative argument passing
authorGonglei <arei.gonglei@huawei.com>
Sat, 15 Nov 2014 10:06:42 +0000 (18:06 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 17 Nov 2014 10:41:25 +0000 (11:41 +0100)
Function send_response(s, &qdict->base) returns a negative number
when any failures occured. But strerror()'s parameter cannot be
negative. Let's change the testing condition and pass '-ret' to
strerr().

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qga/main.c

index 227f2bd..9939a2b 100644 (file)
@@ -603,8 +603,8 @@ static void process_event(JSONMessageParser *parser, QList *tokens)
             error_free(err);
         }
         ret = send_response(s, QOBJECT(qdict));
-        if (ret) {
-            g_warning("error sending error response: %s", strerror(ret));
+        if (ret < 0) {
+            g_warning("error sending error response: %s", strerror(-ret));
         }
     }