convert less-trivial versions of "write_in_full() != len"
The prior commit converted many sites to check the return value of write_in_full() for negativity, rather than a mismatch with the input length. This patch covers similar cases, but where the return value is stored in an intermediate variable. These should get the same treatment, but they need to be reviewed more carefully since it would be a bug if the return value is stored in an unsigned type (which indeed, it is in one of the cases). Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
06f46f237a
commit
564bde9ae6
5
entry.c
5
entry.c
@ -244,7 +244,8 @@ static int write_entry(struct cache_entry *ce,
|
||||
char *new;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
unsigned long size;
|
||||
size_t wrote, newsize = 0;
|
||||
ssize_t wrote;
|
||||
size_t newsize = 0;
|
||||
struct stat st;
|
||||
const struct submodule *sub;
|
||||
|
||||
@ -319,7 +320,7 @@ static int write_entry(struct cache_entry *ce,
|
||||
fstat_done = fstat_output(fd, state, &st);
|
||||
close(fd);
|
||||
free(new);
|
||||
if (wrote != size)
|
||||
if (wrote < 0)
|
||||
return error("unable to write file %s", path);
|
||||
break;
|
||||
case S_IFGITLINK:
|
||||
|
||||
Reference in New Issue
Block a user