diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-04-03 08:03:56 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-04-03 09:16:49 -0700 |
| commit | 3e7b36d129a5972e20cab4e55c43a8628b4d2c9c (patch) | |
| tree | 045798d48a16043bb5f62ca9b7f801abcfb92cfa /reftable/basics_test.c | |
| parent | 11c821f2f2a31e70fb5cc449f9a29401c333aad2 (diff) | |
reftable/basics: fix return type of `binsearch()` to be `size_t`
The `binsearch()` function can be used to find the first element for
which a callback functions returns a truish value. But while the array
size is of type `size_t`, the function in fact returns an `int` that is
supposed to index into that array.
Fix the function signature to return a `size_t`. This conversion does
not change any semantics given that the function would only ever return
a value in the range `[0, sz]` anyway.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/basics_test.c')
| -rw-r--r-- | reftable/basics_test.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/reftable/basics_test.c b/reftable/basics_test.c index 1fcd229725..dc1c87c5df 100644 --- a/reftable/basics_test.c +++ b/reftable/basics_test.c @@ -34,15 +34,15 @@ static void test_binsearch(void) int i = 0; for (i = 1; i < 11; i++) { - int res; + size_t res; + args.key = i; res = binsearch(sz, &binsearch_func, &args); if (res < sz) { EXPECT(args.key < arr[res]); - if (res > 0) { + if (res > 0) EXPECT(args.key >= arr[res - 1]); - } } else { EXPECT(args.key == 10 || args.key == 11); } |
