Skip to content

Commit

Permalink
zlib.c,http_push.c: explicit cast comparisons of potential 32bit long…
Browse files Browse the repository at this point in the history
… 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]>
  • Loading branch information
Philip Oakley authored and dscho committed Jun 4, 2019
1 parent fc00458 commit a4b2bb5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit a4b2bb5

Please sign in to comment.