From a4b2bb588bb9680e4ac2ce979cbf954f582cb9df Mon Sep 17 00:00:00 2001 From: Philip Oakley Date: Mon, 11 Mar 2019 16:15:02 +0000 Subject: [PATCH] zlib.c,http_push.c: explicit cast comparisons of potential 32bit long to size_t On Windows, long may only be 32 bits and their use for pointer sized comparison is potentially implemenation defined. Make explicit the appropriate type conversion. Ensure they are up-cast to size_t Signed-off-by: Philip Oakley --- http-push.c | 2 +- zlib.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/http-push.c b/http-push.c index db5abaacb974f6..e1f200d8b7e136 100644 --- a/http-push.c +++ b/http-push.c @@ -370,7 +370,7 @@ static void start_put(struct transfer_request *request) /* Set it up */ git_deflate_init(&stream, zlib_compression_level); - size = git_deflate_bound(&stream, len + hdrlen); + size = git_deflate_bound(&stream, len + (size_t) hdrlen); strbuf_init(&request->buffer.buf, size); request->buffer.posn = 0; diff --git a/zlib.c b/zlib.c index 197a1acc7b0db9..1d7316b38a72b2 100644 --- a/zlib.c +++ b/zlib.c @@ -31,7 +31,7 @@ static const char *zerr_to_string(int status) #define ZLIB_BUF_MAX ((uInt) 1024 * 1024 * 1024) /* 1GB */ static inline uInt zlib_buf_cap(size_t len) { - return (ZLIB_BUF_MAX < len) ? ZLIB_BUF_MAX : len; + return ((size_t) ZLIB_BUF_MAX < len) ? ZLIB_BUF_MAX : (uInt) len; } static void zlib_pre_call(git_zstream *s) @@ -116,7 +116,7 @@ int git_inflate(git_zstream *strm, int flush) zlib_pre_call(strm); /* Never say Z_FINISH unless we are feeding everything */ status = inflate(&strm->z, - (strm->z.avail_in != strm->avail_in) + ((size_t) strm->z.avail_in != strm->avail_in) ? 0 : flush); if (status == Z_MEM_ERROR) die("inflate: out of memory"); @@ -242,7 +242,7 @@ int git_deflate(git_zstream *strm, int flush) /* Never say Z_FINISH unless we are feeding everything */ status = deflate(&strm->z, - (strm->z.avail_in != strm->avail_in) + ((size_t) strm->z.avail_in != strm->avail_in) ? 0 : flush); if (status == Z_MEM_ERROR) die("deflate: out of memory");