diff mbox series

[v3,3/6] apply: do a typecast to eliminate warnings

Message ID 20250216072843.72385-4-jelly.zhao.42@gmail.com (mailing list archive)
State New
Headers show
Series apply: address -Wsign-comparison warnings | expand

Commit Message

Zejun Zhao Feb. 16, 2025, 7:28 a.m. UTC
`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 mbox series

Patch

diff --git a/apply.c b/apply.c
index 4aa47a22b9..ac3e599bdf 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;