zlib.c: use size_t for size

Signed-off-by: Martin Koegler <martin.koegler@chello.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Martin Koegler
2018-10-14 03:16:36 +01:00
committed by Junio C Hamano
parent 5a0cc8aca7
commit 5efde212fc
7 changed files with 24 additions and 23 deletions

View File

@ -269,12 +269,12 @@ static void copy_pack_data(struct hashfile *f,
off_t len) off_t len)
{ {
unsigned char *in; unsigned char *in;
unsigned long avail; size_t avail;
while (len) { while (len) {
in = use_pack(p, w_curs, offset, &avail); in = use_pack(p, w_curs, offset, &avail);
if (avail > len) if (avail > len)
avail = (unsigned long)len; avail = xsize_t(len);
hashwrite(f, in, avail); hashwrite(f, in, avail);
offset += avail; offset += avail;
len -= avail; len -= avail;
@ -1478,8 +1478,8 @@ static void check_object(struct object_entry *entry)
struct pack_window *w_curs = NULL; struct pack_window *w_curs = NULL;
const unsigned char *base_ref = NULL; const unsigned char *base_ref = NULL;
struct object_entry *base_entry; struct object_entry *base_entry;
unsigned long used, used_0; size_t used, used_0;
unsigned long avail; size_t avail;
off_t ofs; off_t ofs;
unsigned char *buf, c; unsigned char *buf, c;
enum object_type type; enum object_type type;
@ -1966,7 +1966,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,
struct pack_window *w_curs; struct pack_window *w_curs;
unsigned char *buf; unsigned char *buf;
enum object_type type; enum object_type type;
unsigned long used, avail, size; unsigned long used, size;
size_t avail;
if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) { if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
read_lock(); read_lock();

10
cache.h
View File

@ -20,10 +20,10 @@
#include <zlib.h> #include <zlib.h>
typedef struct git_zstream { typedef struct git_zstream {
z_stream z; z_stream z;
unsigned long avail_in; size_t avail_in;
unsigned long avail_out; size_t avail_out;
unsigned long total_in; size_t total_in;
unsigned long total_out; size_t total_out;
unsigned char *next_in; unsigned char *next_in;
unsigned char *next_out; unsigned char *next_out;
} git_zstream; } git_zstream;
@ -40,7 +40,7 @@ void git_deflate_end(git_zstream *);
int git_deflate_abort(git_zstream *); int git_deflate_abort(git_zstream *);
int git_deflate_end_gently(git_zstream *); int git_deflate_end_gently(git_zstream *);
int git_deflate(git_zstream *, int flush); int git_deflate(git_zstream *, int flush);
unsigned long git_deflate_bound(git_zstream *, unsigned long); size_t git_deflate_bound(git_zstream *, size_t);
/* The length in bytes and in hex digits of an object name (SHA-1 value). */ /* The length in bytes and in hex digits of an object name (SHA-1 value). */
#define GIT_SHA1_RAWSZ 20 #define GIT_SHA1_RAWSZ 20

View File

@ -33,7 +33,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
uint32_t data_crc = crc32(0, NULL, 0); uint32_t data_crc = crc32(0, NULL, 0);
do { do {
unsigned long avail; size_t avail;
void *data = use_pack(p, w_curs, offset, &avail); void *data = use_pack(p, w_curs, offset, &avail);
if (avail > len) if (avail > len)
avail = len; avail = len;
@ -68,7 +68,7 @@ static int verify_packfile(struct packed_git *p,
the_hash_algo->init_fn(&ctx); the_hash_algo->init_fn(&ctx);
do { do {
unsigned long remaining; size_t remaining;
unsigned char *in = use_pack(p, w_curs, offset, &remaining); unsigned char *in = use_pack(p, w_curs, offset, &remaining);
offset += remaining; offset += remaining;
if (!pack_sig_ofs) if (!pack_sig_ofs)

View File

@ -579,7 +579,7 @@ static int in_window(struct pack_window *win, off_t offset)
unsigned char *use_pack(struct packed_git *p, unsigned char *use_pack(struct packed_git *p,
struct pack_window **w_cursor, struct pack_window **w_cursor,
off_t offset, off_t offset,
unsigned long *left) size_t *left)
{ {
struct pack_window *win = *w_cursor; struct pack_window *win = *w_cursor;
@ -1098,7 +1098,7 @@ int unpack_object_header(struct packed_git *p,
unsigned long *sizep) unsigned long *sizep)
{ {
unsigned char *base; unsigned char *base;
unsigned long left; size_t left;
unsigned long used; unsigned long used;
enum object_type type; enum object_type type;

View File

@ -78,7 +78,7 @@ extern void close_pack_index(struct packed_git *);
extern uint32_t get_pack_fanout(struct packed_git *p, uint32_t value); extern uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);
extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *); extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, size_t *);
extern void close_pack_windows(struct packed_git *); extern void close_pack_windows(struct packed_git *);
extern void close_pack(struct packed_git *); extern void close_pack(struct packed_git *);
extern void close_all_packs(struct raw_object_store *o); extern void close_all_packs(struct raw_object_store *o);

View File

@ -67,11 +67,11 @@ static void *do_xmalloc(size_t size, int gentle)
ret = malloc(1); ret = malloc(1);
if (!ret) { if (!ret) {
if (!gentle) if (!gentle)
die("Out of memory, malloc failed (tried to allocate %lu bytes)", die("Out of memory, malloc failed (tried to allocate %" PRIuMAX " bytes)",
(unsigned long)size); (uintmax_t)size);
else { else {
error("Out of memory, malloc failed (tried to allocate %lu bytes)", error("Out of memory, malloc failed (tried to allocate %" PRIuMAX " bytes)",
(unsigned long)size); (uintmax_t)size);
return NULL; return NULL;
} }
} }

8
zlib.c
View File

@ -29,7 +29,7 @@ static const char *zerr_to_string(int status)
*/ */
/* #define ZLIB_BUF_MAX ((uInt)-1) */ /* #define ZLIB_BUF_MAX ((uInt)-1) */
#define ZLIB_BUF_MAX ((uInt) 1024 * 1024 * 1024) /* 1GB */ #define ZLIB_BUF_MAX ((uInt) 1024 * 1024 * 1024) /* 1GB */
static inline uInt zlib_buf_cap(unsigned long len) static inline uInt zlib_buf_cap(size_t len)
{ {
return (ZLIB_BUF_MAX < len) ? ZLIB_BUF_MAX : len; return (ZLIB_BUF_MAX < len) ? ZLIB_BUF_MAX : len;
} }
@ -46,8 +46,8 @@ static void zlib_pre_call(git_zstream *s)
static void zlib_post_call(git_zstream *s) static void zlib_post_call(git_zstream *s)
{ {
unsigned long bytes_consumed; size_t bytes_consumed;
unsigned long bytes_produced; size_t bytes_produced;
bytes_consumed = s->z.next_in - s->next_in; bytes_consumed = s->z.next_in - s->next_in;
bytes_produced = s->z.next_out - s->next_out; bytes_produced = s->z.next_out - s->next_out;
@ -150,7 +150,7 @@ int git_inflate(git_zstream *strm, int flush)
#define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11) #define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
#endif #endif
unsigned long git_deflate_bound(git_zstream *strm, unsigned long size) size_t git_deflate_bound(git_zstream *strm, size_t size)
{ {
return deflateBound(&strm->z, size); return deflateBound(&strm->z, size);
} }