]> git.ipfire.org Git - thirdparty/git.git/commit - pack-write.c
avoid looking at errno for short read_in_full() returns
authorJeff King <peff@peff.net>
Wed, 27 Sep 2017 06:01:07 +0000 (02:01 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Sep 2017 06:45:24 +0000 (15:45 +0900)
commit90dca6710e6e5aad5d78d0cd006c3adadb65524d
tree60d3225445c7321ca07f4a154db46e4e02fda125
parent61d36330b422237b6be9581cdbade07782ab61a8
avoid looking at errno for short read_in_full() returns

When a caller tries to read a particular set of bytes via
read_in_full(), there are three possible outcomes:

  1. An error, in which case -1 is returned and errno is
     set.

  2. A short read, in which fewer bytes are returned and
     errno is unspecified (we never saw a read error, so we
     may have some random value from whatever syscall failed
     last).

  3. The full read completed successfully.

Many callers handle cases 1 and 2 together by just checking
the result against the requested size. If their combined
error path looks at errno (e.g., by calling die_errno), they
may report a nonsense value.

Let's fix these sites by having them distinguish between the
two error cases. That avoids the random errno confusion, and
lets us give more detailed error messages.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-write.c
sha1_file.c