]> git.ipfire.org Git - thirdparty/git.git/commit
bulk-checkin: fix sign compare warnings
authorTuomas Ahola <taahol@utu.fi>
Mon, 24 Mar 2025 21:47:03 +0000 (23:47 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Mar 2025 22:55:28 +0000 (15:55 -0700)
commit133d065dd6af135d53bce590f52b885c70c9a09b
treef283a9cc37de858c65fb42924617e1e7681b282f
parent683c54c999c301c2cd6f715c411407c413b1d84e
bulk-checkin: fix sign compare warnings

In file bulk-checkin.c, three warnings are emitted by
"-Wsign-compare", two of which are caused by trivial loop iterator
type mismatches.  For the third case, the type of `rsize` from

ssize_t rsize = size < sizeof(ibuf) ? size : sizeof(ibuf);

can be changed to size_t as both options of the ternary expression are
unsigned and the signedness of the variable isn't really needed
anywhere.

To prevent `read_result != rsize` making a clash, it is to be noted
that `read_result` is checked not to hold negative values.  Therefore
casting the variable to size_t is a safe operation and enough to
remove the sign-compare warning.

Fix issues accordingly, and remove `DISABLE_SIGN_COMPARE_WARNINGS` to
enable "-Wsign-compare" for the file.

Signed-off-by: Tuomas Ahola <taahol@utu.fi>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bulk-checkin.c