]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reftable/block: adapt header and footer size to return a `size_t`
authorPatrick Steinhardt <ps@pks.im>
Mon, 20 Jan 2025 16:17:24 +0000 (17:17 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 Jan 2025 22:20:29 +0000 (14:20 -0800)
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>
reftable/block.c
reftable/block.h
t/unit-tests/t-reftable-readwrite.c

index 2380aabb2f36a039fe629230309346c190fe5458..12750852574ac051aa269c4531b066f59676e008 100644 (file)
@@ -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:
index 5f67ed74c5e9a82d286d7fc1c8f24ac1925a47bf..bef2b8a4c5c31edf26c18d586d9ec1abfe1906d9 100644 (file)
@@ -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);
index 6b75a419b9d3bbfb720a3c39f741f940dfcd56aa..2e553154ea8fd85346bcf084599bb583af07a91d 100644 (file)
@@ -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);