diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-01-20 17:17:24 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-01-21 14:20:29 -0800 |
| commit | ffe664366890f252ad14e87c987c57e080182bca (patch) | |
| tree | 04708a7a692673fd9c3bc74cf61c6d53dceb8059 | |
| parent | 57adf71b93efa9f9b4db5147e9fa1235f0a1d5ba (diff) | |
| download | git-ffe664366890f252ad14e87c987c57e080182bca.tar.gz | |
reftable/block: adapt header and footer size to return a `size_t`
The functions `header_size()` and `footer_size()` return a positive
integer representing the size of the header and footer, respectively,
dependent on the version of the reftable format. Similar to the
preceding commit, these functions return a signed integer though, which
is nonsensical given that there is no way for these functions to return
negative.
Adapt the functions to return a `size_t` instead to fix a couple of sign
comparison warnings.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
| -rw-r--r-- | reftable/block.c | 4 | ||||
| -rw-r--r-- | reftable/block.h | 4 | ||||
| -rw-r--r-- | t/unit-tests/t-reftable-readwrite.c | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/reftable/block.c b/reftable/block.c index 2380aabb2f..1275085257 100644 --- a/reftable/block.c +++ b/reftable/block.c @@ -15,7 +15,7 @@ https://developers.google.com/open-source/licenses/bsd #include "system.h" #include <zlib.h> -int header_size(int version) +size_t header_size(int version) { switch (version) { case 1: @@ -26,7 +26,7 @@ int header_size(int version) abort(); } -int footer_size(int version) +size_t footer_size(int version) { switch (version) { case 1: diff --git a/reftable/block.h b/reftable/block.h index 5f67ed74c5..bef2b8a4c5 100644 --- a/reftable/block.h +++ b/reftable/block.h @@ -137,10 +137,10 @@ void block_iter_reset(struct block_iter *it); void block_iter_close(struct block_iter *it); /* size of file header, depending on format version */ -int header_size(int version); +size_t header_size(int version); /* size of file footer, depending on format version */ -int footer_size(int version); +size_t footer_size(int version); /* returns a block to its source. */ void reftable_block_done(struct reftable_block *ret); diff --git a/t/unit-tests/t-reftable-readwrite.c b/t/unit-tests/t-reftable-readwrite.c index 6b75a419b9..2e553154ea 100644 --- a/t/unit-tests/t-reftable-readwrite.c +++ b/t/unit-tests/t-reftable-readwrite.c @@ -643,7 +643,7 @@ static void t_write_empty_table(void) check_int(err, ==, REFTABLE_EMPTY_TABLE_ERROR); reftable_writer_free(w); - check_int(buf.len, ==, header_size(1) + footer_size(1)); + check_uint(buf.len, ==, header_size(1) + footer_size(1)); block_source_from_buf(&source, &buf); |
