git/refs
Karthik Nayak 65855751d1 ref-cache: use 'size_t' instead of int for length
The commit 090eb5336c (refs: selectively set prefix in the seek
functions, 2025-07-15) modified the ref-cache iterator to support
seeking to a specified marker without setting the prefix.

The commit adds and uses an integer 'len' to capture the length of the
seek marker to compare with the entries of a given directory. Since the
type of the variable is 'int', this is met with a typecast of converting
a `strlen` to 'int' so it can be assigned to the 'len' variable.

This is whole operation is a bit wrong:
1. Since the 'len' variable is eventually used in a 'strncmp', it should
have been of type 'size_t'.
2. This also truncates the value provided from 'strlen' to an int, which
could cause a large refname to produce a negative number.

Let's do the correct thing here and simply use 'size_t' for `len`.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2025-07-28 14:16:36 -07:00
..
debug.c refs: selectively set prefix in the seek functions 2025-07-15 11:54:20 -07:00
files-backend.c refs: selectively set prefix in the seek functions 2025-07-15 11:54:20 -07:00
iterator.c refs: selectively set prefix in the seek functions 2025-07-15 11:54:20 -07:00
packed-backend.c refs: selectively set prefix in the seek functions 2025-07-15 11:54:20 -07:00
packed-backend.h refs/files: use heuristic to decide whether to repack with `--auto` 2024-09-04 08:03:24 -07:00
ref-cache.c ref-cache: use 'size_t' instead of int for length 2025-07-28 14:16:36 -07:00
ref-cache.h ref-cache: remove unused function 'find_ref_entry()' 2025-07-15 11:54:19 -07:00
refs-internal.h refs: selectively set prefix in the seek functions 2025-07-15 11:54:20 -07:00
reftable-backend.c refs: selectively set prefix in the seek functions 2025-07-15 11:54:20 -07:00