Skip to content

Commit 34ad434

Browse files
committed
Merge branch 'mk/use-size-t-in-zlib' into seen
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 49d93bb + 5efde21 commit 34ad434

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
@@ -289,12 +289,12 @@ static void copy_pack_data(struct hashfile *f,
289289
off_t len)
290290
{
291291
unsigned char *in;
292-
unsigned long avail;
292+
size_t avail;
293293

294294
while (len) {
295295
in = use_pack(p, w_curs, offset, &avail);
296296
if (avail > len)
297-
avail = (unsigned long)len;
297+
avail = xsize_t(len);
298298
hashwrite(f, in, avail);
299299
offset += avail;
300300
len -= avail;
@@ -1736,8 +1736,8 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
17361736
int have_base = 0;
17371737
struct object_id base_ref;
17381738
struct object_entry *base_entry;
1739-
unsigned long used, used_0;
1740-
unsigned long avail;
1739+
size_t used, used_0;
1740+
size_t avail;
17411741
off_t ofs;
17421742
unsigned char *buf, c;
17431743
enum object_type type;
@@ -2208,7 +2208,8 @@ unsigned long oe_get_size_slow(struct packing_data *pack,
22082208
struct pack_window *w_curs;
22092209
unsigned char *buf;
22102210
enum object_type type;
2211-
unsigned long used, avail, size;
2211+
unsigned long used, size;
2212+
size_t avail;
22122213

22132214
if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
22142215
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
@@ -29,7 +29,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
2929
uint32_t data_crc = crc32(0, NULL, 0);
3030

3131
do {
32-
unsigned long avail;
32+
size_t avail;
3333
void *data = use_pack(p, w_curs, offset, &avail);
3434
if (avail > len)
3535
avail = len;
@@ -65,7 +65,7 @@ static int verify_packfile(struct repository *r,
6565

6666
r->hash_algo->init_fn(&ctx);
6767
do {
68-
unsigned long remaining;
68+
size_t remaining;
6969
unsigned char *in = use_pack(p, w_curs, offset, &remaining);
7070
offset += remaining;
7171
if (!pack_sig_ofs)

packfile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ static int in_window(struct pack_window *win, off_t offset)
613613
unsigned char *use_pack(struct packed_git *p,
614614
struct pack_window **w_cursor,
615615
off_t offset,
616-
unsigned long *left)
616+
size_t *left)
617617
{
618618
struct pack_window *win = *w_cursor;
619619

@@ -1133,7 +1133,7 @@ int unpack_object_header(struct packed_git *p,
11331133
unsigned long *sizep)
11341134
{
11351135
unsigned char *base;
1136-
unsigned long left;
1136+
size_t left;
11371137
unsigned long used;
11381138
enum object_type type;
11391139

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)