]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/patch-id: fix type of `get_one_patchid()`
authorPatrick Steinhardt <ps@pks.im>
Fri, 6 Dec 2024 10:27:29 +0000 (11:27 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Dec 2024 11:20:05 +0000 (20:20 +0900)
commitefb38ad49fb2dd7bf6e732df0c59f3c1aeba2f76
treeb25430a3ffe7f797f0274da2bb0e97c71b251e8a
parent6411a0a896d0ca00effa9b7a67ea0655257b9832
builtin/patch-id: fix type of `get_one_patchid()`

In `get_one_patchid()` we assign either the result of `strlen()` or
`remove_space()` to `len`. But while the former correctly returns a
`size_t`, the latter returns an `int` to indicate the length of the
stripped string even though it cannot ever return a negative value. This
causes a warning with "-Wsign-conversion".

In fact, even `get_one_patchid()` itself is also using an integer as
return value even though it always returns the length of the patch, and
this bubbles up to other callers.

Adapt the function and its helpers to use `size_t` for string lengths
consistently.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/patch-id.c