aboutsummaryrefslogtreecommitdiffstats
path: root/reftable/basics.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-01-20 17:17:22 +0100
committerJunio C Hamano <gitster@pobox.com>2025-01-21 14:20:29 -0800
commit5ac65f0d6b867ff031fda03779c2f2613f022b10 (patch)
tree4a27077b5eedc1ae09c81cc10277c79ccba22074 /reftable/basics.c
parent072e3aa3a5c29ca1b68a7aaf570a0a8e7ab67127 (diff)
downloadgit-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/basics.c')
-rw-r--r--reftable/basics.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/reftable/basics.c b/reftable/basics.c
index fe2b83ff83..10b234ea55 100644
--- a/reftable/basics.c
+++ b/reftable/basics.c
@@ -263,14 +263,12 @@ int names_equal(const char **a, const char **b)
return a[i] == b[i];
}
-int common_prefix_size(struct reftable_buf *a, struct reftable_buf *b)
+size_t common_prefix_size(struct reftable_buf *a, struct reftable_buf *b)
{
- int p = 0;
- for (; p < a->len && p < b->len; p++) {
+ size_t p = 0;
+ for (; p < a->len && p < b->len; p++)
if (a->buf[p] != b->buf[p])
break;
- }
-
return p;
}