Skip to content

Commit 923a5b8

Browse files
committed
Merge branch 'topic/size-t' (size_t evacuation, upstream-bound)
2 parents 4621f8c + bbf9087 commit 923a5b8

86 files changed

Lines changed: 397 additions & 352 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apply.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,7 +3232,7 @@ static int apply_binary_fragment(struct apply_state *state,
32323232
struct patch *patch)
32333233
{
32343234
struct fragment *fragment = patch->fragments;
3235-
unsigned long len;
3235+
size_t len;
32363236
void *dst;
32373237

32383238
if (!fragment)
@@ -3321,7 +3321,7 @@ static int apply_binary(struct apply_state *state,
33213321
if (odb_has_object(the_repository->objects, &oid, 0)) {
33223322
/* We already have the postimage */
33233323
enum object_type type;
3324-
unsigned long size;
3324+
size_t size;
33253325
char *result;
33263326

33273327
result = odb_read_object(the_repository->objects, &oid,
@@ -3384,7 +3384,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
33843384
strbuf_addf(buf, "Subproject commit %s\n", oid_to_hex(oid));
33853385
} else {
33863386
enum object_type type;
3387-
unsigned long sz;
3387+
size_t sz;
33883388
char *result;
33893389

33903390
result = odb_read_object(the_repository->objects, oid,
@@ -3611,7 +3611,7 @@ static int load_preimage(struct apply_state *state,
36113611

36123612
static int resolve_to(struct image *image, const struct object_id *result_id)
36133613
{
3614-
unsigned long size;
3614+
size_t size;
36153615
enum object_type type;
36163616
char *data;
36173617

archive-zip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static void *zlib_deflate_raw(void *data, unsigned long size,
206206
unsigned long *compressed_size)
207207
{
208208
git_zstream stream;
209-
unsigned long maxsize;
209+
size_t maxsize;
210210
void *buffer;
211211
int result;
212212

archive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static void *object_file_to_archive(const struct archiver_args *args,
8787
const struct object_id *oid,
8888
unsigned int mode,
8989
enum object_type *type,
90-
unsigned long *sizep)
90+
size_t *sizep)
9191
{
9292
void *buffer;
9393
const struct commit *commit = args->convert ? args->commit : NULL;
@@ -158,7 +158,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,
158158
write_archive_entry_fn_t write_entry = c->write_entry;
159159
int err;
160160
const char *path_without_prefix;
161-
unsigned long size;
161+
size_t size;
162162
void *buffer;
163163
enum object_type type;
164164

attr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,
768768
const char *path, unsigned flags)
769769
{
770770
struct object_id oid;
771-
unsigned long sz;
771+
size_t sz;
772772
enum object_type type;
773773
void *buf;
774774
unsigned short mode;
@@ -793,7 +793,7 @@ static struct attr_stack *read_attr_from_index(struct index_state *istate,
793793
{
794794
struct attr_stack *stack = NULL;
795795
char *buf;
796-
unsigned long size;
796+
size_t size;
797797
int sparse_dir_pos = -1;
798798

799799
if (!istate)

bisect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static void show_list(const char *debug, int counted, int nr,
154154
struct commit *commit = p->item;
155155
unsigned commit_flags = commit->object.flags;
156156
enum object_type type;
157-
unsigned long size;
157+
size_t size;
158158
char *buf = odb_read_object(the_repository->objects,
159159
&commit->object.oid, &type,
160160
&size);

blame.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
238238
struct stat st;
239239
const char *read_from;
240240
char *buf_ptr;
241-
unsigned long buf_len;
241+
size_t buf_len;
242242

243243
if (contents_from) {
244244
if (stat(contents_from, &st) < 0)
@@ -335,7 +335,7 @@ static const char *get_next_line(const char *start, const char *end)
335335
}
336336

337337
static int find_line_starts(int **line_starts, const char *buf,
338-
unsigned long len)
338+
size_t len)
339339
{
340340
const char *end = buf + len;
341341
const char *p;
@@ -1034,7 +1034,7 @@ static void fill_origin_blob(struct diff_options *opt,
10341034
{
10351035
if (!o->file.ptr) {
10361036
enum object_type type;
1037-
unsigned long file_size;
1037+
size_t file_size;
10381038

10391039
(*num_read_blob)++;
10401040
if (opt->flags.allow_textconv &&
@@ -2861,18 +2861,20 @@ void setup_scoreboard(struct blame_scoreboard *sb,
28612861
sb->final_buf_size = o->file.size;
28622862
}
28632863
else {
2864+
size_t final_buf_size_st = 0;
28642865
o = get_origin(sb->final, sb->path);
28652866
if (fill_blob_sha1_and_mode(sb->repo, o))
28662867
die(_("no such path %s in %s"), sb->path, final_commit_name);
28672868

28682869
if (sb->revs->diffopt.flags.allow_textconv &&
28692870
textconv_object(sb->repo, sb->path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,
2870-
&sb->final_buf_size))
2871+
&final_buf_size_st))
28712872
;
28722873
else
28732874
sb->final_buf = odb_read_object(the_repository->objects,
28742875
&o->blob_oid, &type,
2875-
&sb->final_buf_size);
2876+
&final_buf_size_st);
2877+
sb->final_buf_size = cast_size_t_to_ulong(final_buf_size_st);
28762878

28772879
if (!sb->final_buf)
28782880
die(_("cannot read blob %s for path %s"),

builtin/cat-file.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static char *replace_idents_using_mailmap(char *object_buf, size_t *size)
8484

8585
static int filter_object(const char *path, unsigned mode,
8686
const struct object_id *oid,
87-
char **buf, unsigned long *size)
87+
char **buf, size_t *size)
8888
{
8989
enum object_type type;
9090

@@ -120,7 +120,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
120120
struct object_id oid;
121121
enum object_type type;
122122
char *buf;
123-
unsigned long size;
123+
size_t size;
124124
struct object_context obj_context = {0};
125125
struct object_info oi = OBJECT_INFO_INIT;
126126
unsigned flags = OBJECT_INFO_LOOKUP_REPLACE;
@@ -166,7 +166,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
166166
if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {
167167
size_t s = size;
168168
buf = replace_idents_using_mailmap(buf, &s);
169-
size = cast_size_t_to_ulong(s);
169+
size = s;
170170
}
171171

172172
printf("%"PRIuMAX"\n", (uintmax_t)size);
@@ -188,9 +188,13 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
188188
break;
189189

190190
case 'c':
191-
if (textconv_object(the_repository, path, obj_context.mode,
192-
&oid, 1, &buf, &size))
191+
{
192+
int textconv_ret = textconv_object(the_repository, path,
193+
obj_context.mode, &oid, 1,
194+
&buf, &size);
195+
if (textconv_ret)
193196
break;
197+
}
194198
/* else fallthrough */
195199

196200
case 'p':
@@ -219,7 +223,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
219223
if (use_mailmap) {
220224
size_t s = size;
221225
buf = replace_idents_using_mailmap(buf, &s);
222-
size = cast_size_t_to_ulong(s);
226+
size = s;
223227
}
224228

225229
/* otherwise just spit out the data */
@@ -266,7 +270,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
266270
if (use_mailmap) {
267271
size_t s = size;
268272
buf = replace_idents_using_mailmap(buf, &s);
269-
size = cast_size_t_to_ulong(s);
273+
size = s;
270274
}
271275
break;
272276
}
@@ -288,7 +292,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
288292
struct expand_data {
289293
struct object_id oid;
290294
enum object_type type;
291-
unsigned long size;
295+
size_t size;
292296
unsigned short mode;
293297
off_t disk_size;
294298
const char *rest;
@@ -404,7 +408,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
404408
fflush(stdout);
405409
if (opt->transform_mode) {
406410
char *contents;
407-
unsigned long size;
411+
size_t size;
408412

409413
if (!data->rest)
410414
die("missing path for '%s'", oid_to_hex(oid));
@@ -434,7 +438,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
434438
}
435439
else {
436440
enum object_type type;
437-
unsigned long size;
441+
size_t size;
438442
void *contents;
439443

440444
contents = odb_read_object(the_repository->objects, oid,
@@ -445,7 +449,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
445449
if (use_mailmap) {
446450
size_t s = size;
447451
contents = replace_idents_using_mailmap(contents, &s);
448-
size = cast_size_t_to_ulong(s);
452+
size = s;
449453
}
450454

451455
if (type != data->type)
@@ -554,7 +558,7 @@ static void batch_object_write(const char *obj_name,
554558
if (!buf)
555559
die(_("unable to read %s"), oid_to_hex(&data->oid));
556560
buf = replace_idents_using_mailmap(buf, &s);
557-
data->size = cast_size_t_to_ulong(s);
561+
data->size = s;
558562

559563
free(buf);
560564
}

builtin/difftool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static char *get_symlink(struct repository *repo,
319319
data = strbuf_detach(&link, NULL);
320320
} else {
321321
enum object_type type;
322-
unsigned long size;
322+
size_t size;
323323
data = odb_read_object(repo->objects, oid, &type, &size);
324324
if (!data)
325325
die(_("could not read object %s for symlink %s"),

builtin/fast-export.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static void show_progress(void)
285285
* There's no need to cache this result with anonymize_mem, since
286286
* we already handle blob content caching with marks.
287287
*/
288-
static char *anonymize_blob(unsigned long *size)
288+
static char *anonymize_blob(size_t *size)
289289
{
290290
static int counter;
291291
struct strbuf out = STRBUF_INIT;
@@ -296,7 +296,7 @@ static char *anonymize_blob(unsigned long *size)
296296

297297
static void export_blob(const struct object_id *oid)
298298
{
299-
unsigned long size;
299+
size_t size;
300300
enum object_type type;
301301
char *buf;
302302
struct object *object;
@@ -317,7 +317,8 @@ static void export_blob(const struct object_id *oid)
317317
object = (struct object *)lookup_blob(the_repository, oid);
318318
eaten = 0;
319319
} else {
320-
buf = odb_read_object(the_repository->objects, oid, &type, &size);
320+
buf = odb_read_object(the_repository->objects, oid, &type,
321+
&size);
321322
if (!buf)
322323
die(_("could not read blob %s"), oid_to_hex(oid));
323324
if (check_object_signature(the_repository, oid, buf, size,
@@ -880,7 +881,7 @@ static char *anonymize_tag(void)
880881

881882
static void handle_tag(const char *name, struct tag *tag)
882883
{
883-
unsigned long size;
884+
size_t size;
884885
enum object_type type;
885886
char *buf;
886887
const char *tagger, *tagger_end, *message;

builtin/fast-import.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -998,11 +998,13 @@ static int store_object(
998998

999999
if (last && last->data.len && last->data.buf && last->depth < max_depth
10001000
&& dat->len > the_hash_algo->rawsz) {
1001+
size_t deltalen_st = 0;
10011002

10021003
delta_count_attempts_by_type[type]++;
10031004
delta = diff_delta(last->data.buf, last->data.len,
10041005
dat->buf, dat->len,
1005-
&deltalen, dat->len - the_hash_algo->rawsz);
1006+
&deltalen_st, dat->len - the_hash_algo->rawsz);
1007+
deltalen = cast_size_t_to_ulong(deltalen_st);
10061008
} else
10071009
delta = NULL;
10081010

@@ -1241,6 +1243,8 @@ static void *gfi_unpack_entry(
12411243
unsigned long *sizep)
12421244
{
12431245
enum object_type type;
1246+
size_t size_st = 0;
1247+
void *data;
12441248
struct packed_git *p = all_packs[oe->pack_id];
12451249
if (p == pack_data && p->pack_size < (pack_size + the_hash_algo->rawsz)) {
12461250
/* The object is stored in the packfile we are writing to
@@ -1262,7 +1266,10 @@ static void *gfi_unpack_entry(
12621266
*/
12631267
p->pack_size = pack_size + the_hash_algo->rawsz;
12641268
}
1265-
return unpack_entry(the_repository, p, oe->idx.offset, &type, sizep);
1269+
data = unpack_entry(the_repository, p, oe->idx.offset, &type, &size_st);
1270+
if (sizep)
1271+
*sizep = cast_size_t_to_ulong(size_st);
1272+
return data;
12661273
}
12671274

12681275
static void load_tree(struct tree_entry *root)
@@ -1288,7 +1295,10 @@ static void load_tree(struct tree_entry *root)
12881295
die(_("can't load tree %s"), oid_to_hex(oid));
12891296
} else {
12901297
enum object_type type;
1291-
buf = odb_read_object(the_repository->objects, oid, &type, &size);
1298+
size_t size_st = 0;
1299+
buf = odb_read_object(the_repository->objects, oid, &type,
1300+
&size_st);
1301+
size = cast_size_t_to_ulong(size_st);
12921302
if (!buf || type != OBJ_TREE)
12931303
die(_("can't load tree %s"), oid_to_hex(oid));
12941304
}
@@ -2557,7 +2567,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
25572567
die(_("mark :%" PRIuMAX " not a commit"), commit_mark);
25582568
oidcpy(&commit_oid, &commit_oe->idx.oid);
25592569
} else if (!repo_get_oid(the_repository, p, &commit_oid)) {
2560-
unsigned long size;
2570+
size_t size;
25612571
char *buf = odb_read_object_peeled(the_repository->objects,
25622572
&commit_oid, OBJ_COMMIT, &size,
25632573
&commit_oid);
@@ -2624,10 +2634,12 @@ static void parse_from_existing(struct branch *b)
26242634
oidclr(&b->branch_tree.versions[1].oid, the_repository->hash_algo);
26252635
} else {
26262636
unsigned long size;
2637+
size_t size_st = 0;
26272638
char *buf;
26282639

26292640
buf = odb_read_object_peeled(the_repository->objects, &b->oid,
2630-
OBJ_COMMIT, &size, &b->oid);
2641+
OBJ_COMMIT, &size_st, &b->oid);
2642+
size = cast_size_t_to_ulong(size_st);
26312643
parse_from_commit(b, buf, size);
26322644
free(buf);
26332645
}
@@ -2719,7 +2731,7 @@ static struct hash_list *parse_merge(unsigned int *count)
27192731
die(_("mark :%" PRIuMAX " not a commit"), idnum);
27202732
oidcpy(&n->oid, &oe->idx.oid);
27212733
} else if (!repo_get_oid(the_repository, from, &n->oid)) {
2722-
unsigned long size;
2734+
size_t size;
27232735
char *buf = odb_read_object_peeled(the_repository->objects,
27242736
&n->oid, OBJ_COMMIT,
27252737
&size, &n->oid);
@@ -3327,7 +3339,10 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
33273339
char *buf;
33283340

33293341
if (!oe || oe->pack_id == MAX_PACK_ID) {
3330-
buf = odb_read_object(the_repository->objects, oid, &type, &size);
3342+
size_t size_st = 0;
3343+
buf = odb_read_object(the_repository->objects, oid, &type,
3344+
&size_st);
3345+
size = cast_size_t_to_ulong(size_st);
33313346
} else {
33323347
type = oe->type;
33333348
buf = gfi_unpack_entry(oe, &size);
@@ -3435,8 +3450,10 @@ static struct object_entry *dereference(struct object_entry *oe,
34353450
buf = gfi_unpack_entry(oe, &size);
34363451
} else {
34373452
enum object_type unused;
3453+
size_t size_st = 0;
34383454
buf = odb_read_object(the_repository->objects, oid,
3439-
&unused, &size);
3455+
&unused, &size_st);
3456+
size = cast_size_t_to_ulong(size_st);
34403457
}
34413458
if (!buf)
34423459
die(_("can't load object %s"), oid_to_hex(oid));

0 commit comments

Comments
 (0)