]> git.ipfire.org Git - thirdparty/git.git/commit
gpg-interface: address -Wsign-comparison warnings
authorPatrick Steinhardt <ps@pks.im>
Fri, 6 Dec 2024 10:27:27 +0000 (11:27 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Dec 2024 11:20:04 +0000 (20:20 +0900)
commit87318f2b6ed371814cb53c91a458b336f175b325
treec0aaa2fe3390fc8b658216c2758075ab1e4285d4
parent7d200af27f41b8732dcb1a6c01ff73b7b7b0ecc1
gpg-interface: address -Wsign-comparison warnings

There are a couple of -Wsign-comparison warnings in "gpg-interface.c".
Most of them are trivial and simply using signed integers to loop
towards an upper unsigned bound.

But in `parse_signed_buffer()` we have one case where the different
signedness of the two values of a ternary expression results in a
warning. Given that:

  - `size` will always be bigger than `len` due to the loop condition.

  - `eol` will always be after `buf + len` because it is found via
    memchr(3p) starting from `buf + len`.

We know that both values will always be natural integers.

Squelch the warning by casting the left-hand side to `size_t`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gpg-interface.c