Commit 1c3fac4d5e18beacb07865354b10a0bc282a49a7

Sebastian Schuberth 2011-09-08T14:31:37

Add casts to get rid of some warnings when filling zlib structures

diff --git a/src/filebuf.c b/src/filebuf.c
index 70245b5..e8c5087 100644
--- a/src/filebuf.c
+++ b/src/filebuf.c
@@ -117,18 +117,18 @@ static int write_deflate(git_filebuf *file, void *source, size_t len)
 
 	if (len > 0 || file->flush_mode == Z_FINISH) {
 		zs->next_in = source;
-		zs->avail_in = len;
+		zs->avail_in = (uInt)len;
 
 		do {
-			int have;
+			size_t have;
 
 			zs->next_out = file->z_buf;
-			zs->avail_out = file->buf_size;
+			zs->avail_out = (uInt)file->buf_size;
 
 			result = deflate(zs, file->flush_mode);
 			assert(result != Z_STREAM_ERROR);
 
-			have = file->buf_size - zs->avail_out;
+			have = file->buf_size - (size_t)zs->avail_out;
 
 			if (p_write(file->fd, file->z_buf, have) < GIT_SUCCESS)
 				return git__throw(GIT_EOSERR, "Failed to write to file");
diff --git a/src/odb_loose.c b/src/odb_loose.c
index a3a4e5b..e6aecc6 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -183,19 +183,19 @@ static void init_stream(z_stream *s, void *out, size_t len)
 {
 	memset(s, 0, sizeof(*s));
 	s->next_out  = out;
-	s->avail_out = len;
+	s->avail_out = (uInt)len;
 }
 
 static void set_stream_input(z_stream *s, void *in, size_t len)
 {
 	s->next_in  = in;
-	s->avail_in = len;
+	s->avail_in = (uInt)len;
 }
 
 static void set_stream_output(z_stream *s, void *out, size_t len)
 {
 	s->next_out  = out;
-	s->avail_out = len;
+	s->avail_out = (uInt)len;
 }
 
 
@@ -243,10 +243,10 @@ static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen)
 	memset(&zs, 0x0, sizeof(zs));
 
 	zs.next_out  = out;
-	zs.avail_out = outlen;
+	zs.avail_out = (uInt)outlen;
 
 	zs.next_in  = in;
-	zs.avail_in = inlen;
+	zs.avail_in = (uInt)inlen;
 
 	if (inflateInit(&zs) < Z_OK)
 		return git__throw(GIT_ERROR, "Failed to inflate buffer");
diff --git a/src/pack.c b/src/pack.c
index d882516..d5e069a 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -404,7 +404,7 @@ int packfile_unpack_compressed(
 
 	memset(&stream, 0, sizeof(stream));
 	stream.next_out = buffer;
-	stream.avail_out = size + 1;
+	stream.avail_out = (uInt)size + 1;
 
 	st = inflateInit(&stream);
 	if (st != Z_OK) {