diff options
| author | Patrick Steinhardt <ps@pks.im> | 2025-01-20 17:17:22 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-01-21 14:20:29 -0800 |
| commit | 5ac65f0d6b867ff031fda03779c2f2613f022b10 (patch) | |
| tree | 4a27077b5eedc1ae09c81cc10277c79ccba22074 /reftable/record.c | |
| parent | 072e3aa3a5c29ca1b68a7aaf570a0a8e7ab67127 (diff) | |
| download | git-5ac65f0d6b867ff031fda03779c2f2613f022b10.tar.gz | |
reftable/basics: adjust `common_prefix_size()` to return `size_t`
The `common_prefix_size()` function computes the length of the common
prefix between two buffers. As such its return value will always be an
unsigned integer, as the length cannot be negative. Regardless of that,
the function returns a signed integer, which is nonsensical and causes a
couple of -Wsign-compare warnings all over the place.
Adjust the function to return a `size_t` instead.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/record.c')
| -rw-r--r-- | reftable/record.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/reftable/record.c b/reftable/record.c index a55ce76aeb..4a3e019528 100644 --- a/reftable/record.c +++ b/reftable/record.c @@ -144,9 +144,9 @@ int reftable_encode_key(int *restart, struct string_view dest, uint8_t extra) { struct string_view start = dest; - int prefix_len = common_prefix_size(&prev_key, &key); + size_t prefix_len = common_prefix_size(&prev_key, &key); uint64_t suffix_len = key.len - prefix_len; - int n = put_var_int(&dest, (uint64_t)prefix_len); + int n = put_var_int(&dest, prefix_len); if (n < 0) return -1; string_view_consume(&dest, n); |
