[tip:tools/kvm] kvm tools: Simply write_in_full() check semantics

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

 



Commit-ID:  1cf7f482b481942fb533d83a56057a2b564bb057
Gitweb:     http://git.kernel.org/tip/1cf7f482b481942fb533d83a56057a2b564bb057
Author:     Asias He <asias.hejun@xxxxxxxxx>
AuthorDate: Mon, 9 Jan 2012 17:19:26 +0800
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Mon, 9 Jan 2012 21:02:28 +0200

kvm tools: Simply write_in_full() check semantics

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@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/kvm-ipc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/kvm-ipc.c b/tools/kvm/kvm-ipc.c
index 5b65882..6a0bd21 100644
--- a/tools/kvm/kvm-ipc.c
+++ b/tools/kvm/kvm-ipc.c
@@ -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)
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux