Skip to content

Commit 2d128cd

Browse files
committed
Merge branch 'mk/use-size-t-in-zlib' into pu
The wrapper to call into zlib followed our long tradition to use "unsigned long" for sizes of regions in memory, which have been updated to use "size_t". * mk/use-size-t-in-zlib: zlib.c: use size_t for size
2 parents 90354d9 + 5efde21 commit 2d128cd

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

builtin/pack-objects.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,12 @@ static void copy_pack_data(struct hashfile *f,
276276
off_t len)
277277
{
278278
unsigned char *in;
279-
unsigned long avail;
279+
size_t avail;
280280

281281
while (len) {
282282
in = use_pack(p, w_curs, offset, &avail);
283283
if (avail > len)
284-
avail = (unsigned long)len;
284+
avail = xsize_t(len);
285285
hashwrite(f, in, avail);
286286
offset += avail;
287287
len -= avail;
@@ -1667,8 +1667,8 @@ static void check_object(struct object_entry *entry)
16671667
struct pack_window *w_curs = NULL;
16681668
const unsigned char *base_ref = NULL;
16691669
struct object_entry *base_entry;
1670-
unsigned long used, used_0;
1671-
unsigned long avail;
1670+
size_t used, used_0;
1671+
size_t avail;
16721672
off_t ofs;
16731673
unsigned char *buf, c;
16741674
enum object_type type;
@@ -2123,7 +2123,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,
21232123
struct pack_window *w_curs;
21242124
unsigned char *buf;
21252125
enum object_type type;
2126-
unsigned long used, avail, size;
2126+
unsigned long used, size;
2127+
size_t avail;
21272128

21282129
if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
21292130
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
#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
4747
#define DTYPE(de) ((de)->d_type)

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
@@ -612,7 +612,7 @@ static int in_window(struct pack_window *win, off_t offset)
612612
unsigned char *use_pack(struct packed_git *p,
613613
struct pack_window **w_cursor,
614614
off_t offset,
615-
unsigned long *left)
615+
size_t *left)
616616
{
617617
struct pack_window *win = *w_cursor;
618618

@@ -1132,7 +1132,7 @@ int unpack_object_header(struct packed_git *p,
11321132
unsigned long *sizep)
11331133
{
11341134
unsigned char *base;
1135-
unsigned long left;
1135+
size_t left;
11361136
unsigned long used;
11371137
enum object_type type;
11381138

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);

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)