Re: [PATCH 2/6] chcpu: convert to use lib/path.c

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

 



>  int
> +path_writestr(const char *str, const char *path, ...)
> +{
> +	int fd, result;
> +	va_list ap;
> +
> +	va_start(ap, path);
> +	fd = path_vopen(O_WRONLY, path, ap);
> +	va_end(ap);
> +	result = write(fd, str, strlen(str));
> +	close(fd);
> +	return result;
> +}

Hmm, this is not ok. The patch below is needed on top. Sorry...


Subject: [PATCH] lib,path: use write_all()

From: Heiko Carstens <heiko.carstens@xxxxxxxxxx>

Since write() doesn't necessarily write the complete buffer with
one call we better use write_all() which takes care of this.

Signed-off-by: Heiko Carstens <heiko.carstens@xxxxxxxxxx>
---
 lib/path.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/path.c b/lib/path.c
index e2bb398..54b8942 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <errno.h>
 
+#include "writeall.h"
 #include "cpuset.h"
 #include "path.h"
 #include "nls.h"
@@ -132,7 +133,7 @@ path_writestr(const char *str, const char *path, ...)
 	va_start(ap, path);
 	fd = path_vopen(O_WRONLY, path, ap);
 	va_end(ap);
-	result = write(fd, str, strlen(str));
+	result = write_all(fd, str, strlen(str));
 	close(fd);
 	return result;
 }
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux