From 93822c2239a336e5cb583549071c59202ef6c5b2 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Mon, 8 Jan 2007 15:58:23 +0000 Subject: short i/o: fix calls to write to use xwrite or write_in_full We have a number of badly checked write() calls. Often we are expecting write() to write exactly the size we requested or fail, this fails to handle interrupts or short writes. Switch to using the new write_in_full(). Otherwise we at a minimum need to check for EINTR and EAGAIN, where this is appropriate use xwrite(). Note, the changes to config handling are much larger and handled in the next patch in the sequence. Signed-off-by: Andy Whitcroft Signed-off-by: Junio C Hamano --- read-cache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'read-cache.c') diff --git a/read-cache.c b/read-cache.c index 29cf9abe64..8ecd826e9c 100644 --- a/read-cache.c +++ b/read-cache.c @@ -870,7 +870,7 @@ static int ce_write_flush(SHA_CTX *context, int fd) unsigned int buffered = write_buffer_len; if (buffered) { SHA1_Update(context, write_buffer, buffered); - if (write(fd, write_buffer, buffered) != buffered) + if (write_in_full(fd, write_buffer, buffered) != buffered) return -1; write_buffer_len = 0; } @@ -919,7 +919,7 @@ static int ce_flush(SHA_CTX *context, int fd) /* Flush first if not enough space for SHA1 signature */ if (left + 20 > WRITE_BUFFER_SIZE) { - if (write(fd, write_buffer, left) != left) + if (write_in_full(fd, write_buffer, left) != left) return -1; left = 0; } @@ -927,7 +927,7 @@ static int ce_flush(SHA_CTX *context, int fd) /* Append the SHA1 signature at the end */ SHA1_Final(write_buffer + left, context); left += 20; - return (write(fd, write_buffer, left) != left) ? -1 : 0; + return (write_in_full(fd, write_buffer, left) != left) ? -1 : 0; } static void ce_smudge_racily_clean_entry(struct cache_entry *ce) -- cgit v1.2.3