Skip to content

Commit 5efde21

Browse files
e9925248gitster
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 5a0cc8a commit 5efde21

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
@@ -269,12 +269,12 @@ static void copy_pack_data(struct hashfile *f,
269269
off_t len)
270270
{
271271
unsigned char *in;
272-
unsigned long avail;
272+
size_t avail;
273273

274274
while (len) {
275275
in = use_pack(p, w_curs, offset, &avail);
276276
if (avail > len)
277-
avail = (unsigned long)len;
277+
avail = xsize_t(len);
278278
hashwrite(f, in, avail);
279279
offset += avail;
280280
len -= avail;
@@ -1478,8 +1478,8 @@ static void check_object(struct object_entry *entry)
14781478
struct pack_window *w_curs = NULL;
14791479
const unsigned char *base_ref = NULL;
14801480
struct object_entry *base_entry;
1481-
unsigned long used, used_0;
1482-
unsigned long avail;
1481+
size_t used, used_0;
1482+
size_t avail;
14831483
off_t ofs;
14841484
unsigned char *buf, c;
14851485
enum object_type type;
@@ -1966,7 +1966,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,
19661966
struct pack_window *w_curs;
19671967
unsigned char *buf;
19681968
enum object_type type;
1969-
unsigned long used, avail, size;
1969+
unsigned long used, size;
1970+
size_t avail;
19701971

19711972
if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
19721973
read_lock();

cache.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
#include <zlib.h>
2121
typedef struct git_zstream {
2222
z_stream z;
23-
unsigned long avail_in;
24-
unsigned long avail_out;
25-
unsigned long total_in;
26-
unsigned long total_out;
23+
size_t avail_in;
24+
size_t avail_out;
25+
size_t total_in;
26+
size_t total_out;
2727
unsigned char *next_in;
2828
unsigned char *next_out;
2929
} git_zstream;
@@ -40,7 +40,7 @@ void git_deflate_end(git_zstream *);
4040
int git_deflate_abort(git_zstream *);
4141
int git_deflate_end_gently(git_zstream *);
4242
int git_deflate(git_zstream *, int flush);
43-
unsigned long git_deflate_bound(git_zstream *, unsigned long);
43+
size_t git_deflate_bound(git_zstream *, size_t);
4444

4545
/* The length in bytes and in hex digits of an object name (SHA-1 value). */
4646
#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;
@@ -68,7 +68,7 @@ static int verify_packfile(struct packed_git *p,
6868

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

packfile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ static int in_window(struct pack_window *win, off_t offset)
579579
unsigned char *use_pack(struct packed_git *p,
580580
struct pack_window **w_cursor,
581581
off_t offset,
582-
unsigned long *left)
582+
size_t *left)
583583
{
584584
struct pack_window *win = *w_cursor;
585585

@@ -1098,7 +1098,7 @@ int unpack_object_header(struct packed_git *p,
10981098
unsigned long *sizep)
10991099
{
11001100
unsigned char *base;
1101-
unsigned long left;
1101+
size_t left;
11021102
unsigned long used;
11031103
enum object_type type;
11041104

packfile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ extern void close_pack_index(struct packed_git *);
7878

7979
extern uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);
8080

81-
extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
81+
extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, size_t *);
8282
extern void close_pack_windows(struct packed_git *);
8383
extern void close_pack(struct packed_git *);
8484
extern void close_all_packs(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)