Skip to content

Commit ffe6643

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 57adf71 commit ffe6643

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

reftable/block.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ license that can be found in the LICENSE file or at
1515
#include "system.h"
1616
#include <zlib.h>
1717

18-
int header_size(int version)
18+
size_t header_size(int version)
1919
{
2020
switch (version) {
2121
case 1:
@@ -26,7 +26,7 @@ int header_size(int version)
2626
abort();
2727
}
2828

29-
int footer_size(int version)
29+
size_t footer_size(int version)
3030
{
3131
switch (version) {
3232
case 1:

reftable/block.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ void block_iter_reset(struct block_iter *it);
137137
void block_iter_close(struct block_iter *it);
138138

139139
/* size of file header, depending on format version */
140-
int header_size(int version);
140+
size_t header_size(int version);
141141

142142
/* size of file footer, depending on format version */
143-
int footer_size(int version);
143+
size_t footer_size(int version);
144144

145145
/* returns a block to its source. */
146146
void reftable_block_done(struct reftable_block *ret);

t/unit-tests/t-reftable-readwrite.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static void t_write_empty_table(void)
643643
check_int(err, ==, REFTABLE_EMPTY_TABLE_ERROR);
644644
reftable_writer_free(w);
645645

646-
check_int(buf.len, ==, header_size(1) + footer_size(1));
646+
check_uint(buf.len, ==, header_size(1) + footer_size(1));
647647

648648
block_source_from_buf(&source, &buf);
649649

0 commit comments

Comments
 (0)