aboutsummaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2007-01-11 20:23:00 -0800
committerJunio C Hamano <junkio@cox.net>2007-01-11 21:02:58 -0800
commitd34cf19b8987ae0f0806e257edf877238d044747 (patch)
tree62c54c75d209587d44efc0528bd04d7cd8a8f472 /sha1_file.c
parent9bbaa6cc6848b68b8bef681c2a22b57bbec3e914 (diff)
downloadgit-d34cf19b8987ae0f0806e257edf877238d044747.tar.gz
git-d34cf19b8987ae0f0806e257edf877238d044747.tar.xz
Clean up write_in_full() users
With the new-and-improved write_in_full() semantics, where a partial write simply always returns a real error (and always sets 'errno' when that happens, including for the disk full case), a lot of the callers of write_in_full() were just unnecessarily complex. In particular, there's no reason to ever check for a zero length or return: if the length was zero, we'll return zero, otherwise, if a disk full resulted in the actual write() system call returning zero the write_in_full() logic would have correctly turned that into a negative return value, with 'errno' set to ENOSPC. I really wish every "write_in_full()" user would just check against "<0" now, but this fixes the nasty and stupid ones. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 18dd89b50..2a5be53fa 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1618,14 +1618,7 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
static int write_buffer(int fd, const void *buf, size_t len)
{
- ssize_t size;
-
- if (!len)
- return 0;
- size = write_in_full(fd, buf, len);
- if (!size)
- return error("file write: disk full");
- if (size < 0)
+ if (write_in_full(fd, buf, len) < 0)
return error("file write error (%s)", strerror(errno));
return 0;
}