Merge branch 'jk/write-in-full-fix'
Many codepaths did not diagnose write failures correctly when disks go full, due to their misuse of write_in_full() helper function, which have been corrected. * jk/write-in-full-fix: read_pack_header: handle signed/unsigned comparison in read result config: flip return value of store_write_*() notes-merge: use ssize_t for write_in_full() return value pkt-line: check write_in_full() errors against "< 0" convert less-trivial versions of "write_in_full() != len" avoid "write_in_full(fd, buf, len) != len" pattern get-tar-commit-id: check write_in_full() return against 0 config: avoid "write_in_full(fd, buf, len) < len" pattern
This commit is contained in:
@ -1549,7 +1549,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,
|
||||
|
||||
written = len <= maxlen ? write_in_full(fd, logrec, len) : -1;
|
||||
free(logrec);
|
||||
if (written != len)
|
||||
if (written < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
@ -1628,8 +1628,8 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
|
||||
return -1;
|
||||
}
|
||||
fd = get_lock_file_fd(&lock->lk);
|
||||
if (write_in_full(fd, oid_to_hex(oid), GIT_SHA1_HEXSZ) != GIT_SHA1_HEXSZ ||
|
||||
write_in_full(fd, &term, 1) != 1 ||
|
||||
if (write_in_full(fd, oid_to_hex(oid), GIT_SHA1_HEXSZ) < 0 ||
|
||||
write_in_full(fd, &term, 1) < 0 ||
|
||||
close_ref_gently(lock) < 0) {
|
||||
strbuf_addf(err,
|
||||
"couldn't write '%s'", get_lock_file_path(&lock->lk));
|
||||
@ -3006,8 +3006,8 @@ static int files_reflog_expire(struct ref_store *ref_store,
|
||||
rollback_lock_file(&reflog_lock);
|
||||
} else if (update &&
|
||||
(write_in_full(get_lock_file_fd(&lock->lk),
|
||||
oid_to_hex(&cb.last_kept_oid), GIT_SHA1_HEXSZ) != GIT_SHA1_HEXSZ ||
|
||||
write_str_in_full(get_lock_file_fd(&lock->lk), "\n") != 1 ||
|
||||
oid_to_hex(&cb.last_kept_oid), GIT_SHA1_HEXSZ) < 0 ||
|
||||
write_str_in_full(get_lock_file_fd(&lock->lk), "\n") < 1 ||
|
||||
close_ref_gently(lock) < 0)) {
|
||||
status |= error("couldn't write %s",
|
||||
get_lock_file_path(&lock->lk));
|
||||
|
Reference in New Issue
Block a user