Skip to content

Commit 5b60f72

Browse files
e9925248dscho
authored andcommitted
zlib.c: use size_t for size
Signed-off-by: Martin Koegler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Torsten Bögershausen <[email protected]> Helped-by: SZEDER Gábor <[email protected]> Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9c8cba6 commit 5b60f72

File tree

7 files changed

+24
-23
lines changed

7 files changed

+24
-23
lines changed

builtin/pack-objects.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,12 @@ static void copy_pack_data(struct hashfile *f,
271271
off_t len)
272272
{
273273
unsigned char *in;
274-
unsigned long avail;
274+
size_t avail;
275275

276276
while (len) {
277277
in = use_pack(p, w_curs, offset, &avail);
278278
if (avail > len)
279-
avail = (unsigned long)len;
279+
avail = xsize_t(len);
280280
hashwrite(f, in, avail);
281281
offset += avail;
282282
len -= avail;
@@ -1533,8 +1533,8 @@ static void check_object(struct object_entry *entry)
15331533
struct pack_window *w_curs = NULL;
15341534
const unsigned char *base_ref = NULL;
15351535
struct object_entry *base_entry;
1536-
unsigned long used, used_0;
1537-
unsigned long avail;
1536+
size_t used, used_0;
1537+
size_t avail;
15381538
off_t ofs;
15391539
unsigned char *buf, c;
15401540
enum object_type type;
@@ -1989,7 +1989,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,
19891989
struct pack_window *w_curs;
19901990
unsigned char *buf;
19911991
enum object_type type;
1992-
unsigned long used, avail, size;
1992+
unsigned long used, size;
1993+
size_t avail;
19931994

19941995
if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
19951996
packing_data_lock(&to_pack);

cache.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
#include <zlib.h>
2222
typedef struct git_zstream {
2323
z_stream z;
24-
unsigned long avail_in;
25-
unsigned long avail_out;
26-
unsigned long total_in;
27-
unsigned long total_out;
24+
size_t avail_in;
25+
size_t avail_out;
26+
size_t total_in;
27+
size_t total_out;
2828
unsigned char *next_in;
2929
unsigned char *next_out;
3030
} git_zstream;
@@ -41,7 +41,7 @@ void git_deflate_end(git_zstream *);
4141
int git_deflate_abort(git_zstream *);
4242
int git_deflate_end_gently(git_zstream *);
4343
int git_deflate(git_zstream *, int flush);
44-
unsigned long git_deflate_bound(git_zstream *, unsigned long);
44+
size_t git_deflate_bound(git_zstream *, size_t);
4545

4646
/* The length in bytes and in hex digits of an object name (SHA-1 value). */
4747
#define GIT_SHA1_RAWSZ 20

pack-check.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
3333
uint32_t data_crc = crc32(0, NULL, 0);
3434

3535
do {
36-
unsigned long avail;
36+
size_t avail;
3737
void *data = use_pack(p, w_curs, offset, &avail);
3838
if (avail > len)
3939
avail = len;
@@ -69,7 +69,7 @@ static int verify_packfile(struct repository *r,
6969

7070
the_hash_algo->init_fn(&ctx);
7171
do {
72-
unsigned long remaining;
72+
size_t remaining;
7373
unsigned char *in = use_pack(p, w_curs, offset, &remaining);
7474
offset += remaining;
7575
if (!pack_sig_ofs)

packfile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ static int in_window(struct pack_window *win, off_t offset)
603603
unsigned char *use_pack(struct packed_git *p,
604604
struct pack_window **w_cursor,
605605
off_t offset,
606-
unsigned long *left)
606+
size_t *left)
607607
{
608608
struct pack_window *win = *w_cursor;
609609

@@ -1115,7 +1115,7 @@ int unpack_object_header(struct packed_git *p,
11151115
unsigned long *sizep)
11161116
{
11171117
unsigned char *base;
1118-
unsigned long left;
1118+
size_t left;
11191119
unsigned long used;
11201120
enum object_type type;
11211121

packfile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int close_pack_fd(struct packed_git *p);
8787

8888
uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);
8989

90-
unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
90+
unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, size_t *);
9191
void close_pack_windows(struct packed_git *);
9292
void close_pack(struct packed_git *);
9393
void close_object_store(struct raw_object_store *o);

wrapper.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ static void *do_xmalloc(size_t size, int gentle)
6767
ret = malloc(1);
6868
if (!ret) {
6969
if (!gentle)
70-
die("Out of memory, malloc failed (tried to allocate %lu bytes)",
71-
(unsigned long)size);
70+
die("Out of memory, malloc failed (tried to allocate %" PRIuMAX " bytes)",
71+
(uintmax_t)size);
7272
else {
73-
error("Out of memory, malloc failed (tried to allocate %lu bytes)",
74-
(unsigned long)size);
73+
error("Out of memory, malloc failed (tried to allocate %" PRIuMAX " bytes)",
74+
(uintmax_t)size);
7575
return NULL;
7676
}
7777
}

zlib.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static const char *zerr_to_string(int status)
2929
*/
3030
/* #define ZLIB_BUF_MAX ((uInt)-1) */
3131
#define ZLIB_BUF_MAX ((uInt) 1024 * 1024 * 1024) /* 1GB */
32-
static inline uInt zlib_buf_cap(unsigned long len)
32+
static inline uInt zlib_buf_cap(size_t len)
3333
{
3434
return (ZLIB_BUF_MAX < len) ? ZLIB_BUF_MAX : len;
3535
}
@@ -46,8 +46,8 @@ static void zlib_pre_call(git_zstream *s)
4646

4747
static void zlib_post_call(git_zstream *s)
4848
{
49-
unsigned long bytes_consumed;
50-
unsigned long bytes_produced;
49+
size_t bytes_consumed;
50+
size_t bytes_produced;
5151

5252
bytes_consumed = s->z.next_in - s->next_in;
5353
bytes_produced = s->z.next_out - s->next_out;
@@ -150,7 +150,7 @@ int git_inflate(git_zstream *strm, int flush)
150150
#define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
151151
#endif
152152

153-
unsigned long git_deflate_bound(git_zstream *strm, unsigned long size)
153+
size_t git_deflate_bound(git_zstream *strm, size_t size)
154154
{
155155
return deflateBound(&strm->z, size);
156156
}

0 commit comments

Comments
 (0)