Skip to content

Commit a4b2bb5

Browse files
Philip Oakleydscho
Philip Oakley
authored andcommitted
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 <[email protected]>
1 parent fc00458 commit a4b2bb5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

http-push.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static void start_put(struct transfer_request *request)
370370

371371
/* Set it up */
372372
git_deflate_init(&stream, zlib_compression_level);
373-
size = git_deflate_bound(&stream, len + hdrlen);
373+
size = git_deflate_bound(&stream, len + (size_t) hdrlen);
374374
strbuf_init(&request->buffer.buf, size);
375375
request->buffer.posn = 0;
376376

zlib.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static const char *zerr_to_string(int status)
3131
#define ZLIB_BUF_MAX ((uInt) 1024 * 1024 * 1024) /* 1GB */
3232
static inline uInt zlib_buf_cap(size_t len)
3333
{
34-
return (ZLIB_BUF_MAX < len) ? ZLIB_BUF_MAX : len;
34+
return ((size_t) ZLIB_BUF_MAX < len) ? ZLIB_BUF_MAX : (uInt) len;
3535
}
3636

3737
static void zlib_pre_call(git_zstream *s)
@@ -116,7 +116,7 @@ int git_inflate(git_zstream *strm, int flush)
116116
zlib_pre_call(strm);
117117
/* Never say Z_FINISH unless we are feeding everything */
118118
status = inflate(&strm->z,
119-
(strm->z.avail_in != strm->avail_in)
119+
((size_t) strm->z.avail_in != strm->avail_in)
120120
? 0 : flush);
121121
if (status == Z_MEM_ERROR)
122122
die("inflate: out of memory");
@@ -242,7 +242,7 @@ int git_deflate(git_zstream *strm, int flush)
242242

243243
/* Never say Z_FINISH unless we are feeding everything */
244244
status = deflate(&strm->z,
245-
(strm->z.avail_in != strm->avail_in)
245+
((size_t) strm->z.avail_in != strm->avail_in)
246246
? 0 : flush);
247247
if (status == Z_MEM_ERROR)
248248
die("deflate: out of memory");

0 commit comments

Comments
 (0)