]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-file.c: return -1, not "status" from unpack_loose_header()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 1 Oct 2021 09:16:46 +0000 (11:16 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Oct 2021 22:06:00 +0000 (15:06 -0700)
Return a -1 when git_inflate() fails instead of whatever Z_* status
we'd get from zlib.c. This makes no difference to any error we report,
but makes it more obvious that we don't care about the specific zlib
error codes here.

See d21f8426907 (unpack_sha1_header(): detect malformed object header,
2016-09-25) for the commit that added the "return status" code. As far
as I can tell there was never a real reason (e.g. different reporting)
for carrying down the "status" as opposed to "-1".

At the time that d21f8426907 was written there was a corresponding
"ret < Z_OK" check right after the unpack_sha1_header() call (the
"unpack_sha1_header()" function was later rename to our current
"unpack_loose_header()").

However, that check was removed in c84a1f3ed4d (sha1_file: refactor
read_object, 2017-06-21) without changing the corresponding return
code.

So let's do the minor cleanup of also changing this function to return
a -1.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-file.c

index 9210e2e6fe47383f1ba5e828db1cb52b87650b43..3a7fe4fe96d24e1f640daaeb0e7b5fb9ef6f05de 100644 (file)
@@ -1239,7 +1239,7 @@ int unpack_loose_header(git_zstream *stream,
                                               buffer, bufsiz);
 
        if (status < Z_OK)
-               return status;
+               return -1;
 
        /* Make sure we have the terminating NUL */
        if (!memchr(buffer, '\0', stream->next_out - (unsigned char *)buffer))