]> git.ipfire.org Git - thirdparty/git.git/commit
rm: fix sign comparison warnings
authorArnav Bhate <bhatearnav@gmail.com>
Sat, 29 Mar 2025 06:03:14 +0000 (11:33 +0530)
committerJunio C Hamano <gitster@pobox.com>
Sat, 29 Mar 2025 08:04:40 +0000 (01:04 -0700)
commitd2fc29380acb5bba36cbc7a12907630a5308b6b1
tree05910ea66fa8e5182b2d08e4391bfcbcf5183a6d
parent683c54c999c301c2cd6f715c411407c413b1d84e
rm: fix sign comparison warnings

There are multiple places in loops, where a signed and an
unsigned data type are compared. Git uses a mix of signed and unsigned
types to store lengths of arrays. This sometimes leads to using a signed
index for an array whose length is stored in an unsigned variable or
vice versa.

get_ours_cache_pos is a special case where i, though derived from a
signed variable is never negative. Move this part to the caller side
and make i an unsigned argument of the function. Rename i to
pos to make it descriptive, now that it is a function argument.

Replace signed data types with unsigned data types and vice versa
wherever necessary. Where both signed and unsigned data types have been
used, define a new variable in the scope of the for loop for use as the
iterator. Remove #define DISABLE_SIGN_COMPARE_WARNINGS.

Signed-off-by: Arnav Bhate <bhatearnav@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rm.c