]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Simply write_in_full() check semantics
authorAsias He <asias.hejun@gmail.com>
Mon, 9 Jan 2012 09:19:26 +0000 (17:19 +0800)
committerPekka Enberg <penberg@kernel.org>
Mon, 9 Jan 2012 19:02:28 +0000 (21:02 +0200)
write_in_full() would not return until count byes has been written or
error has occurred.

So

   if (write_in_full(fd, buf, count) < 0)
goto err;

is enough.

And

   if (write_in_full(fd, buf, count) != count)
goto err;

is not necessary.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/kvm-ipc.c

index 5b6588229429002f1bcfe053a8a16ae125560d6b..6a0bd215a8175659d2b4a9a963cc474ab1031bd9 100644 (file)
@@ -37,7 +37,7 @@ int kvm_ipc__send(int fd, u32 type)
 {
        struct kvm_ipc_head head = {.type = type, .len = 0,};
 
-       if (write_in_full(fd, &head, sizeof(head)) != sizeof(head))
+       if (write_in_full(fd, &head, sizeof(head)) < 0)
                return -1;
 
        return 0;
@@ -47,7 +47,7 @@ int kvm_ipc__send_msg(int fd, u32 type, u32 len, u8 *msg)
 {
        struct kvm_ipc_head head = {.type = type, .len = len,};
 
-       if (write_in_full(fd, &head, sizeof(head)) != sizeof(head))
+       if (write_in_full(fd, &head, sizeof(head)) < 0)
                return -1;
 
        if (write_in_full(fd, msg, len) < 0)