[GSOC][PATCH v2 3/6] apply: do a typecast to eliminate warnings
- From
- Zejun Zhao <jelly.zhao.42@gmail.com>
- Date
- Feb 9, 2025, 08:12 UTC
- Message-ID
- <20250209081216.241350-4-jelly.zhao.42@gmail.com>
- In-Reply-To
- <20250209081216.241350-1-jelly.zhao.42@gmail.com>
`git_hdr_len` is an `int` variable that can be negative and is used to compare against a `len` of `size_t`, which will trigger -Wsign-comparison warnings
Cast `git_hdr_len` to `size_t` after an above-zero check.
Signed-off-by: Zejun Zhao <jelly.zhao.42@gmail.com> --- apply.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apply.c b/apply.c index b4ae74a5fb..605a0aa2e3 100644 --- a/apply.c +++ b/apply.c @@ -1592,7 +1592,7 @@ static int find_header(struct apply_state *state, size, patch); if (git_hdr_len < 0) return -128; - if (git_hdr_len <= len) + if ((size_t) git_hdr_len <= len) continue; *hdrsize = git_hdr_len; return offset;
-- 2.43.0