summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-10-01 11:16:49 +0200
committerJunio C Hamano <gitster@pobox.com>2021-10-01 15:06:00 -0700
commit3b6a8db3b03adb118bfafb90bbc710068dbd6d14 (patch)
tree395cc70b50eaf08cbd321a8fd2a76b9244b298fd /cache.h
parent01cab9767929c6c3faf4f4ad3b348639655f04fd (diff)
object-file.c: use "enum" return type for unpack_loose_header()
In a preceding commit we changed and documented unpack_loose_header() from its previous behavior of returning any negative value or zero, to only -1 or 0. Let's add an "enum unpack_loose_header_result" type and use it for these return values, and have the compiler assert that we're exhaustively covering all of them. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/cache.h b/cache.h
index 11d2482e30..f738275663 100644
--- a/cache.h
+++ b/cache.h
@@ -1307,7 +1307,10 @@ int git_open_cloexec(const char *name, int flags);
* unpack_loose_header() initializes the data stream needed to unpack
* a loose object header.
*
- * Returns 0 on success. Returns negative values on error.
+ * Returns:
+ *
+ * - ULHR_OK on success
+ * - ULHR_BAD on error
*
* It will only parse up to MAX_HEADER_LEN bytes unless an optional
* "hdrbuf" argument is non-NULL. This is intended for use with
@@ -1315,9 +1318,17 @@ int git_open_cloexec(const char *name, int flags);
* reporting. The full header will be extracted to "hdrbuf" for use
* with parse_loose_header().
*/
-int unpack_loose_header(git_zstream *stream, unsigned char *map,
- unsigned long mapsize, void *buffer,
- unsigned long bufsiz, struct strbuf *hdrbuf);
+enum unpack_loose_header_result {
+ ULHR_OK,
+ ULHR_BAD,
+};
+enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
+ unsigned char *map,
+ unsigned long mapsize,
+ void *buffer,
+ unsigned long bufsiz,
+ struct strbuf *hdrbuf);
+
struct object_info;
int parse_loose_header(const char *hdr, struct object_info *oi,
unsigned int flags);