summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d145144)
raw | patch | inline | side by side (parent: d145144)
author | Linus Torvalds <torvalds@osdl.org> | |
Thu, 11 Jan 2007 21:04:11 +0000 (13:04 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 11 Jan 2007 21:19:18 +0000 (13:19 -0800) |
Signed-off-by: Junio C Hamano <junkio@cox.net>
write_or_die.c | patch | blob | history |
diff --git a/write_or_die.c b/write_or_die.c
index a119e1d208445093dd1d2869729eca9435aa020e..7f99a22aed43afd8ca06d3eafef8d3e836b15107 100644 (file)
--- a/write_or_die.c
+++ b/write_or_die.c
{
const char *p = buf;
ssize_t total = 0;
- ssize_t written = 0;
while (count > 0) {
- written = xwrite(fd, p, count);
- if (written <= 0) {
- if (total)
- return total;
- else
- return written;
+ size_t written = xwrite(fd, p, count);
+ if (written < 0)
+ return -1;
+ if (!written) {
+ errno = ENOSPC;
+ return -1;
}
count -= written;
p += written;