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>
This commit is contained in:

committed by
Junio C Hamano

parent
01cab97679
commit
3b6a8db3b0
19
cache.h
19
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);
|
||||
|
Reference in New Issue
Block a user