[GSOC][PATCH v2 3/6] apply: do a typecast to eliminate warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



`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@xxxxxxxxx>
---
 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





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux