{"thread":{"id":"46607","subject":"[Patch size_t V3 03/19] Convert zlib.c to size_t","startedAt":"2017-08-16T20:16:52Z","lastAt":"2017-08-24T20:29:30Z","messageCount":33,"participants":["Martin Koegler","Junio C Hamano","Ramsay Jones","Torsten Bögershausen","brian m. carlson","Johannes Sixt"],"isPatch":true,"patchVersion":3,"patchTotal":19},"messages":[{"id":"326535","messageId":"1502914591-26215-4-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 03/19] Convert zlib.c to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:15Z","receivedAt":"2017-08-16T20:16:52Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n builtin/pack-objects.c |  8 ++++----\n cache.h                | 12 ++++++------\n pack-check.c           |  4 ++--\n sha1_file.c            |  6 +++---\n wrapper.c              |  8 ++++----\n zlib.c                 |  8 ++++----\n 6 files changed, 23 insertions(+), 23 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex d94fd17..9067803 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -225,12 +225,12 @@ static void copy_pack_data(struct sha1file *f,\n \t\toff_t len)\n {\n \tunsigned char *in;\n-\tunsigned long avail;\n+\tsize_t avail;\n \n \twhile (len) {\n \t\tin = use_pack(p, w_curs, offset, &avail);\n \t\tif (avail > len)\n-\t\t\tavail = (unsigned long)len;\n+\t\t\tavail = len;\n \t\tsha1write(f, in, avail);\n \t\toffset += avail;\n \t\tlen -= avail;\n@@ -1388,8 +1388,8 @@ static void check_object(struct object_entry *entry)\n \t\tstruct pack_window *w_curs = NULL;\n \t\tconst unsigned char *base_ref = NULL;\n \t\tstruct object_entry *base_entry;\n-\t\tunsigned long used, used_0;\n-\t\tunsigned long avail;\n+\t\tsize_t used, used_0;\n+\t\tsize_t avail;\n \t\toff_t ofs;\n \t\tunsigned char *buf, c;\n \ndiff --git a/cache.h b/cache.h\nindex ee96192..5c85844 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -42,10 +42,10 @@\n #include <zlib.h>\n typedef struct git_zstream {\n \tz_stream z;\n-\tunsigned long avail_in;\n-\tunsigned long avail_out;\n-\tunsigned long total_in;\n-\tunsigned long total_out;\n+\tsize_t avail_in;\n+\tsize_t avail_out;\n+\tsize_t total_in;\n+\tsize_t total_out;\n \tunsigned char *next_in;\n \tunsigned char *next_out;\n } git_zstream;\n@@ -62,7 +62,7 @@ void git_deflate_end(git_zstream *);\n int git_deflate_abort(git_zstream *);\n int git_deflate_end_gently(git_zstream *);\n int git_deflate(git_zstream *, int flush);\n-unsigned long git_deflate_bound(git_zstream *, unsigned long);\n+size_t git_deflate_bound(git_zstream *, size_t);\n \n /* The length in bytes and in hex digits of an object name (SHA-1 value). */\n #define GIT_SHA1_RAWSZ 20\n@@ -1686,7 +1686,7 @@ extern int open_pack_index(struct packed_git *);\n  */\n extern void close_pack_index(struct packed_git *);\n \n-extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);\n+extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, size_t *);\n extern void close_pack_windows(struct packed_git *);\n extern void close_all_packs(void);\n extern void unuse_pack(struct pack_window **);\ndiff --git a/pack-check.c b/pack-check.c\nindex 6f7714f..a78da5a 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -30,7 +30,7 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,\n \tuint32_t data_crc = crc32(0, NULL, 0);\n \n \tdo {\n-\t\tunsigned long avail;\n+\t\tsize_t avail;\n \t\tvoid *data = use_pack(p, w_curs, offset, &avail);\n \t\tif (avail > len)\n \t\t\tavail = len;\n@@ -65,7 +65,7 @@ static int verify_packfile(struct packed_git *p,\n \n \tgit_SHA1_Init(&ctx);\n \tdo {\n-\t\tunsigned long remaining;\n+\t\tsize_t remaining;\n \t\tunsigned char *in = use_pack(p, w_curs, offset, &remaining);\n \t\toffset += remaining;\n \t\tif (!pack_sig_ofs)\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 97b39b0..3428172 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1228,7 +1228,7 @@ static int in_window(struct pack_window *win, off_t offset)\n unsigned char *use_pack(struct packed_git *p,\n \t\tstruct pack_window **w_cursor,\n \t\toff_t offset,\n-\t\tunsigned long *left)\n+\t\tsize_t *left)\n {\n \tstruct pack_window *win = *w_cursor;\n \n@@ -2122,8 +2122,8 @@ int unpack_object_header(struct packed_git *p,\n \t\t\t size_t *sizep)\n {\n \tunsigned char *base;\n-\tunsigned long left;\n-\tunsigned long used;\n+\tsize_t left;\n+\tsize_t used;\n \tenum object_type type;\n \n \t/* use_pack() assures us we have [base, base + 20) available\ndiff --git a/wrapper.c b/wrapper.c\nindex 36630e5..c4253f7 100644\n--- a/wrapper.c\n+++ b/wrapper.c\n@@ -67,11 +67,11 @@ static void *do_xmalloc(size_t size, int gentle)\n \t\t\tret = malloc(1);\n \t\tif (!ret) {\n \t\t\tif (!gentle)\n-\t\t\t\tdie(\"Out of memory, malloc failed (tried to allocate %lu bytes)\",\n-\t\t\t\t    (unsigned long)size);\n+\t\t\t\tdie(\"Out of memory, malloc failed (tried to allocate %\" PRIuMAX \" bytes)\",\n+\t\t\t\t    (uintmax_t)size);\n \t\t\telse {\n-\t\t\t\terror(\"Out of memory, malloc failed (tried to allocate %lu bytes)\",\n-\t\t\t\t      (unsigned long)size);\n+\t\t\t\terror(\"Out of memory, malloc failed (tried to allocate %\" PRIuMAX \" bytes)\",\n+\t\t\t\t      (uintmax_t)size);\n \t\t\t\treturn NULL;\n \t\t\t}\n \t\t}\ndiff --git a/zlib.c b/zlib.c\nindex 4223f1a..e98e499 100644\n--- a/zlib.c\n+++ b/zlib.c\n@@ -29,7 +29,7 @@ static const char *zerr_to_string(int status)\n  */\n /* #define ZLIB_BUF_MAX ((uInt)-1) */\n #define ZLIB_BUF_MAX ((uInt) 1024 * 1024 * 1024) /* 1GB */\n-static inline uInt zlib_buf_cap(unsigned long len)\n+static inline uInt zlib_buf_cap(size_t len)\n {\n \treturn (ZLIB_BUF_MAX < len) ? ZLIB_BUF_MAX : len;\n }\n@@ -46,8 +46,8 @@ static void zlib_pre_call(git_zstream *s)\n \n static void zlib_post_call(git_zstream *s)\n {\n-\tunsigned long bytes_consumed;\n-\tunsigned long bytes_produced;\n+\tsize_t bytes_consumed;\n+\tsize_t bytes_produced;\n \n \tbytes_consumed = s->z.next_in - s->next_in;\n \tbytes_produced = s->z.next_out - s->next_out;\n@@ -150,7 +150,7 @@ int git_inflate(git_zstream *strm, int flush)\n #define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)\n #endif\n \n-unsigned long git_deflate_bound(git_zstream *strm, unsigned long size)\n+size_t git_deflate_bound(git_zstream *strm, size_t size)\n {\n \treturn deflateBound(&strm->z, size);\n }\n-- \n2.1.4\n\n"},{"id":"326536","messageId":"1502914591-26215-2-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 01/19] delta: fix enconding size larger than an \"uint\" can hold","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:13Z","receivedAt":"2017-08-16T20:16:54Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nThe current delta code produces incorrect pack objects for files > 4GB.\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n diff-delta.c | 23 ++++++++++++-----------\n 1 file changed, 12 insertions(+), 11 deletions(-)\n\ndiff --git a/diff-delta.c b/diff-delta.c\nindex 3797ce6..db27c1a 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -319,7 +319,8 @@ create_delta(const struct delta_index *index,\n \t     const void *trg_buf, unsigned long trg_size,\n \t     unsigned long *delta_size, unsigned long max_size)\n {\n-\tunsigned int i, outpos, outsize, moff, msize, val;\n+\tunsigned int i, val;\n+\tsize_t l, outpos, moff, outsize, msize;\n \tint inscnt;\n \tconst unsigned char *ref_data, *ref_top, *data, *top;\n \tunsigned char *out;\n@@ -336,20 +337,20 @@ create_delta(const struct delta_index *index,\n \t\treturn NULL;\n \n \t/* store reference buffer size */\n-\ti = index->src_size;\n-\twhile (i >= 0x80) {\n-\t\tout[outpos++] = i | 0x80;\n-\t\ti >>= 7;\n+\tl = index->src_size;\n+\twhile (l >= 0x80) {\n+\t\tout[outpos++] = l | 0x80;\n+\t\tl >>= 7;\n \t}\n-\tout[outpos++] = i;\n+\tout[outpos++] = l;\n \n \t/* store target buffer size */\n-\ti = trg_size;\n-\twhile (i >= 0x80) {\n-\t\tout[outpos++] = i | 0x80;\n-\t\ti >>= 7;\n+\tl = trg_size;\n+\twhile (l >= 0x80) {\n+\t\tout[outpos++] = l | 0x80;\n+\t\tl >>= 7;\n \t}\n-\tout[outpos++] = i;\n+\tout[outpos++] = l;\n \n \tref_data = index->src_buf;\n \tref_top = ref_data + index->src_size;\n-- \n2.1.4\n\n"},{"id":"326537","messageId":"1502914591-26215-9-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 08/19] Convert fsck.c & commit.c to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:20Z","receivedAt":"2017-08-16T20:16:57Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n builtin/replace.c |  2 +-\n commit.c          | 14 +++++++-------\n commit.h          |  8 ++++----\n fsck.c            | 14 +++++++-------\n fsck.h            |  2 +-\n 5 files changed, 20 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin/replace.c b/builtin/replace.c\nindex f4a85a1..dcd0d1e 100644\n--- a/builtin/replace.c\n+++ b/builtin/replace.c\n@@ -391,7 +391,7 @@ static int create_graft(int argc, const char **argv, int force)\n \tstruct commit *commit;\n \tstruct strbuf buf = STRBUF_INIT;\n \tconst char *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (get_oid(old_ref, &old) < 0)\n \t\tdie(_(\"Not a valid object name: '%s'\"), old_ref);\ndiff --git a/commit.c b/commit.c\nindex 79decc2..5ebac6a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -231,19 +231,19 @@ int unregister_shallow(const struct object_id *oid)\n \n struct commit_buffer {\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n };\n define_commit_slab(buffer_slab, struct commit_buffer);\n static struct buffer_slab buffer_slab = COMMIT_SLAB_INIT(1, buffer_slab);\n \n-void set_commit_buffer(struct commit *commit, void *buffer, unsigned long size)\n+void set_commit_buffer(struct commit *commit, void *buffer, size_t size)\n {\n \tstruct commit_buffer *v = buffer_slab_at(&buffer_slab, commit);\n \tv->buffer = buffer;\n \tv->size = size;\n }\n \n-const void *get_cached_commit_buffer(const struct commit *commit, unsigned long *sizep)\n+const void *get_cached_commit_buffer(const struct commit *commit, size_t *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);\n \tif (!v) {\n@@ -256,7 +256,7 @@ const void *get_cached_commit_buffer(const struct commit *commit, unsigned long\n \treturn v->buffer;\n }\n \n-const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)\n+const void *get_commit_buffer(const struct commit *commit, size_t *sizep)\n {\n \tconst void *ret = get_cached_commit_buffer(commit, sizep);\n \tif (!ret) {\n@@ -291,7 +291,7 @@ void free_commit_buffer(struct commit *commit)\n \t}\n }\n \n-const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n+const void *detach_commit_buffer(struct commit *commit, size_t *sizep)\n {\n \tstruct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);\n \tvoid *ret;\n@@ -1128,7 +1128,7 @@ int parse_signed_commit(const struct commit *commit,\n \t\t\tstruct strbuf *payload, struct strbuf *signature)\n {\n \n-\tunsigned long size;\n+\tsize_t size;\n \tconst char *buffer = get_commit_buffer(commit, &size);\n \tint in_signature, saw_signature = -1;\n \tconst char *line, *tail;\n@@ -1284,7 +1284,7 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,\n \t\t\t\t\t\t      const char **exclude)\n {\n \tstruct commit_extra_header *extra = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \tconst char *buffer = get_commit_buffer(commit, &size);\n \textra = read_commit_extra_header_lines(buffer, size, exclude);\n \tunuse_commit_buffer(commit, buffer);\ndiff --git a/commit.h b/commit.h\nindex 82e966e..fd44de3 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -70,20 +70,20 @@ void parse_commit_or_die(struct commit *item);\n  * Associate an object buffer with the commit. The ownership of the\n  * memory is handed over to the commit, and must be free()-able.\n  */\n-void set_commit_buffer(struct commit *, void *buffer, unsigned long size);\n+void set_commit_buffer(struct commit *, void *buffer, size_t size);\n \n /*\n  * Get any cached object buffer associated with the commit. Returns NULL\n  * if none. The resulting memory should not be freed.\n  */\n-const void *get_cached_commit_buffer(const struct commit *, unsigned long *size);\n+const void *get_cached_commit_buffer(const struct commit *, size_t *size);\n \n /*\n  * Get the commit's object contents, either from cache or by reading the object\n  * from disk. The resulting memory should not be modified, and must be given\n  * to unuse_commit_buffer when the caller is done.\n  */\n-const void *get_commit_buffer(const struct commit *, unsigned long *size);\n+const void *get_commit_buffer(const struct commit *, size_t *size);\n \n /*\n  * Tell the commit subsytem that we are done with a particular commit buffer.\n@@ -102,7 +102,7 @@ void free_commit_buffer(struct commit *);\n  * Disassociate any cached object buffer from the commit, but do not free it.\n  * The buffer (or NULL, if none) is returned.\n  */\n-const void *detach_commit_buffer(struct commit *, unsigned long *sizep);\n+const void *detach_commit_buffer(struct commit *, size_t *sizep);\n \n /* Find beginning and length of commit subject. */\n int find_commit_subject(const char *commit_buffer, const char **subject);\ndiff --git a/fsck.c b/fsck.c\nindex feca3a8..9039373 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -632,18 +632,18 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)\n \treturn retval;\n }\n \n-static int verify_headers(const void *data, unsigned long size,\n+static int verify_headers(const void *data, size_t size,\n \t\t\t  struct object *obj, struct fsck_options *options)\n {\n \tconst char *buffer = (const char *)data;\n-\tunsigned long i;\n+\tsize_t i;\n \n \tfor (i = 0; i < size; i++) {\n \t\tswitch (buffer[i]) {\n \t\tcase '\\0':\n \t\t\treturn report(options, obj,\n \t\t\t\tFSCK_MSG_NUL_IN_HEADER,\n-\t\t\t\t\"unterminated header: NUL at offset %ld\", i);\n+\t\t\t\t\"unterminated header: NUL at offset %\" PRIuMAX, (uintmax_t)i);\n \t\tcase '\\n':\n \t\t\tif (i + 1 < size && buffer[i + 1] == '\\n')\n \t\t\t\treturn 0;\n@@ -708,7 +708,7 @@ static int fsck_ident(const char **ident, struct object *obj, struct fsck_option\n }\n \n static int fsck_commit_buffer(struct commit *commit, const char *buffer,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tunsigned char tree_sha1[20], sha1[20];\n \tstruct commit_graft *graft;\n@@ -786,7 +786,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,\n }\n \n static int fsck_commit(struct commit *commit, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tconst char *buffer = data ?  data : get_commit_buffer(commit, &size);\n \tint ret = fsck_commit_buffer(commit, buffer, size, options);\n@@ -890,7 +890,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,\n }\n \n static int fsck_tag(struct tag *tag, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tstruct object *tagged = tag->tagged;\n \n@@ -900,7 +900,7 @@ static int fsck_tag(struct tag *tag, const char *data,\n \treturn fsck_tag_buffer(tag, data, size, options);\n }\n \n-int fsck_object(struct object *obj, void *data, unsigned long size,\n+int fsck_object(struct object *obj, void *data, size_t size,\n \tstruct fsck_options *options)\n {\n \tif (!obj)\ndiff --git a/fsck.h b/fsck.h\nindex 4525510..3de5807 100644\n--- a/fsck.h\n+++ b/fsck.h\n@@ -50,7 +50,7 @@ struct fsck_options {\n  */\n int fsck_walk(struct object *obj, void *data, struct fsck_options *options);\n /* If NULL is passed for data, we assume the object is local and read it. */\n-int fsck_object(struct object *obj, void *data, unsigned long size,\n+int fsck_object(struct object *obj, void *data, size_t size,\n \tstruct fsck_options *options);\n \n #endif\n-- \n2.1.4\n\n"},{"id":"326538","messageId":"1502914591-26215-12-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 11/19] Use size_t for config parsing","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:23Z","receivedAt":"2017-08-16T20:16:59Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n builtin/pack-objects.c |  6 +++---\n config.c               | 27 ++++++++++++++++++++++-----\n config.h               |  2 ++\n 3 files changed, 27 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 9067803..fbb07a8 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2450,7 +2450,7 @@ static int git_pack_config(const char *k, const char *v, void *cb)\n \t\treturn 0;\n \t}\n \tif (!strcmp(k, \"pack.windowmemory\")) {\n-\t\twindow_memory_limit = git_config_ulong(k, v);\n+\t\twindow_memory_limit = git_config_size_t(k, v);\n \t\treturn 0;\n \t}\n \tif (!strcmp(k, \"pack.depth\")) {\n@@ -2458,11 +2458,11 @@ static int git_pack_config(const char *k, const char *v, void *cb)\n \t\treturn 0;\n \t}\n \tif (!strcmp(k, \"pack.deltacachesize\")) {\n-\t\tmax_delta_cache_size = git_config_int(k, v);\n+\t\tmax_delta_cache_size = git_config_size_t(k, v);\n \t\treturn 0;\n \t}\n \tif (!strcmp(k, \"pack.deltacachelimit\")) {\n-\t\tcache_max_small_delta_size = git_config_int(k, v);\n+\t\tcache_max_small_delta_size = git_config_size_t(k, v);\n \t\treturn 0;\n \t}\n \tif (!strcmp(k, \"pack.writebitmaphashcache\")) {\ndiff --git a/config.c b/config.c\nindex bf4e2e4..50f0077 100644\n--- a/config.c\n+++ b/config.c\n@@ -863,6 +863,15 @@ static int git_parse_ssize_t(const char *value, ssize_t *ret)\n \treturn 1;\n }\n \n+int git_parse_size_t(const char *value, size_t *ret)\n+{\n+\tuintmax_t tmp;\n+\tif (!git_parse_unsigned(value, &tmp, maximum_signed_value_of_type(size_t)))\n+\t\treturn 0;\n+\t*ret = tmp;\n+\treturn 1;\n+}\n+\n NORETURN\n static void die_bad_number(const char *name, const char *value)\n {\n@@ -929,6 +938,14 @@ ssize_t git_config_ssize_t(const char *name, const char *value)\n \treturn ret;\n }\n \n+size_t git_config_size_t(const char *name, const char *value)\n+{\n+\tsize_t ret;\n+\tif (!git_parse_size_t(value, &ret))\n+\t\tdie_bad_number(name, value);\n+\treturn ret;\n+}\n+\n int git_parse_maybe_bool(const char *value)\n {\n \tif (!value)\n@@ -1105,7 +1122,7 @@ static int git_default_core_config(const char *var, const char *value)\n \n \tif (!strcmp(var, \"core.packedgitwindowsize\")) {\n \t\tint pgsz_x2 = getpagesize() * 2;\n-\t\tpacked_git_window_size = git_config_ulong(var, value);\n+\t\tpacked_git_window_size = git_config_size_t(var, value);\n \n \t\t/* This value must be multiple of (pagesize * 2) */\n \t\tpacked_git_window_size /= pgsz_x2;\n@@ -1116,17 +1133,17 @@ static int git_default_core_config(const char *var, const char *value)\n \t}\n \n \tif (!strcmp(var, \"core.bigfilethreshold\")) {\n-\t\tbig_file_threshold = git_config_ulong(var, value);\n+\t\tbig_file_threshold = git_config_size_t(var, value);\n \t\treturn 0;\n \t}\n \n \tif (!strcmp(var, \"core.packedgitlimit\")) {\n-\t\tpacked_git_limit = git_config_ulong(var, value);\n+\t\tpacked_git_limit = git_config_size_t(var, value);\n \t\treturn 0;\n \t}\n \n \tif (!strcmp(var, \"core.deltabasecachelimit\")) {\n-\t\tdelta_base_cache_limit = git_config_ulong(var, value);\n+\t\tdelta_base_cache_limit = git_config_size_t(var, value);\n \t\treturn 0;\n \t}\n \n@@ -1360,7 +1377,7 @@ int git_default_config(const char *var, const char *value, void *dummy)\n \t}\n \n \tif (!strcmp(var, \"pack.packsizelimit\")) {\n-\t\tpack_size_limit_cfg = git_config_ulong(var, value);\n+\t\tpack_size_limit_cfg = git_config_size_t(var, value);\n \t\treturn 0;\n \t}\n \ndiff --git a/config.h b/config.h\nindex 18b6f3f..cbaa3e3 100644\n--- a/config.h\n+++ b/config.h\n@@ -49,11 +49,13 @@ extern int config_with_options(config_fn_t fn, void *,\n \t\t\t       struct git_config_source *config_source,\n \t\t\t       const struct config_options *opts);\n extern int git_parse_ulong(const char *, unsigned long *);\n+extern int git_parse_size_t(const char *, size_t *);\n extern int git_parse_maybe_bool(const char *);\n extern int git_config_int(const char *, const char *);\n extern int64_t git_config_int64(const char *, const char *);\n extern unsigned long git_config_ulong(const char *, const char *);\n extern ssize_t git_config_ssize_t(const char *, const char *);\n+extern size_t git_config_size_t(const char *, const char *);\n extern int git_config_bool_or_int(const char *, const char *, int *);\n extern int git_config_bool(const char *, const char *);\n extern int git_config_maybe_bool(const char *, const char *);\n-- \n2.1.4\n\n"},{"id":"326539","messageId":"1502914591-26215-5-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 04/19] delta: Fix offset overflows","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:16Z","receivedAt":"2017-08-16T20:17:01Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nPrevent generating delta offsets beyond 4G.\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n diff-delta.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/diff-delta.c b/diff-delta.c\nindex dffbab1..4489b79 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -453,6 +453,9 @@ create_delta(const struct delta_index *index,\n \t\t\tmoff += msize;\n \t\t\tmsize = left;\n \n+\t\t\tif (moff > 0xffffffff)\n+\t\t\t\tmsize = 0;\n+\n \t\t\tif (msize < 4096) {\n \t\t\t\tint j;\n \t\t\t\tval = 0;\n-- \n2.1.4\n\n"},{"id":"326540","messageId":"1502914591-26215-13-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 12/19] Convert pack-objects to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:24Z","receivedAt":"2017-08-16T20:17:02Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n Documentation/technical/api-parse-options.txt |  2 +-\n builtin/pack-objects.c                        | 46 +++++++++++++--------------\n parse-options.c                               |  6 ++--\n 3 files changed, 27 insertions(+), 27 deletions(-)\n\ndiff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt\nindex 829b558..22b788e 100644\n--- a/Documentation/technical/api-parse-options.txt\n+++ b/Documentation/technical/api-parse-options.txt\n@@ -181,7 +181,7 @@ There are some macros to easily define options:\n \tIntroduce an option with a size argument. The argument must be a\n \tnon-negative integer and may include a suffix of 'k', 'm' or 'g' to\n \tscale the provided value by 1024, 1024^2 or 1024^3 respectively.\n-\tThe scaled value is put into `unsigned_long_var`.\n+\tThe scaled value is put into `size_t`.\n \n `OPT_DATE(short, long, &timestamp_t_var, description)`::\n \tIntroduce an option with date argument, see `approxidate()`.\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex fbb07a8..12457ae 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -56,7 +56,7 @@ static struct pack_idx_option pack_idx_opts;\n static const char *base_name;\n static int progress = 1;\n static int window = 10;\n-static unsigned long pack_size_limit;\n+static size_t pack_size_limit;\n static int depth = 50;\n static int delta_search_threads;\n static int pack_to_stdout;\n@@ -72,11 +72,11 @@ static int use_bitmap_index = -1;\n static int write_bitmap_index;\n static uint16_t write_bitmap_options;\n \n-static unsigned long delta_cache_size = 0;\n-static unsigned long max_delta_cache_size = 256 * 1024 * 1024;\n-static unsigned long cache_max_small_delta_size = 1000;\n+static size_t delta_cache_size = 0;\n+static size_t max_delta_cache_size = 256 * 1024 * 1024;\n+static size_t cache_max_small_delta_size = 1000;\n \n-static unsigned long window_memory_limit = 0;\n+static size_t window_memory_limit = 0;\n \n /*\n  * stats\n@@ -124,11 +124,11 @@ static void *get_delta(struct object_entry *entry)\n \treturn delta_buf;\n }\n \n-static unsigned long do_compress(void **pptr, unsigned long size)\n+static size_t do_compress(void **pptr, size_t size)\n {\n \tgit_zstream stream;\n \tvoid *in, *out;\n-\tunsigned long maxsize;\n+\tsize_t maxsize;\n \n \tgit_deflate_init(&stream, pack_compression_level);\n \tmaxsize = git_deflate_bound(&stream, size);\n@@ -149,13 +149,13 @@ static unsigned long do_compress(void **pptr, unsigned long size)\n \treturn stream.total_out;\n }\n \n-static unsigned long write_large_blob_data(struct git_istream *st, struct sha1file *f,\n+static size_t write_large_blob_data(struct git_istream *st, struct sha1file *f,\n \t\t\t\t\t   const unsigned char *sha1)\n {\n \tgit_zstream stream;\n \tunsigned char ibuf[1024 * 16];\n \tunsigned char obuf[1024 * 16];\n-\tunsigned long olen = 0;\n+\tsize_t olen = 0;\n \n \tgit_deflate_init(&stream, pack_compression_level);\n \n@@ -196,7 +196,7 @@ static int check_pack_inflate(struct packed_git *p,\n \t\tstruct pack_window **w_curs,\n \t\toff_t offset,\n \t\toff_t len,\n-\t\tunsigned long expect)\n+\t\tsize_t expect)\n {\n \tgit_zstream stream;\n \tunsigned char fakebuf[4096], *in;\n@@ -238,13 +238,13 @@ static void copy_pack_data(struct sha1file *f,\n }\n \n /* Return 0 if we will bust the pack-size limit */\n-static unsigned long write_no_reuse_object(struct sha1file *f, struct object_entry *entry,\n-\t\t\t\t\t   unsigned long limit, int usable_delta)\n+static size_t write_no_reuse_object(struct sha1file *f, struct object_entry *entry,\n+\t\t\t\t    size_t limit, int usable_delta)\n {\n \tsize_t size, datalen;\n \tunsigned char header[MAX_PACK_OBJECT_HEADER],\n \t\t      dheader[MAX_PACK_OBJECT_HEADER];\n-\tunsigned hdrlen;\n+\tsize_t hdrlen;\n \tenum object_type type;\n \tvoid *buf;\n \tstruct git_istream *st = NULL;\n@@ -350,7 +350,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent\n \n /* Return 0 if we will bust the pack-size limit */\n static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,\n-\t\t\t\tunsigned long limit, int usable_delta)\n+\t\t\t\tsize_t limit, int usable_delta)\n {\n \tstruct packed_git *p = entry->in_pack;\n \tstruct pack_window *w_curs = NULL;\n@@ -360,7 +360,7 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,\n \toff_t datalen;\n \tunsigned char header[MAX_PACK_OBJECT_HEADER],\n \t\t      dheader[MAX_PACK_OBJECT_HEADER];\n-\tunsigned hdrlen;\n+\tsize_t hdrlen;\n \n \tif (entry->delta)\n \t\ttype = (allow_ofs_delta && entry->delta->idx.offset) ?\n@@ -431,7 +431,7 @@ static off_t write_object(struct sha1file *f,\n \t\t\t  struct object_entry *entry,\n \t\t\t  off_t write_offset)\n {\n-\tunsigned long limit;\n+\tsize_t limit;\n \toff_t len;\n \tint usable_delta, to_reuse;\n \n@@ -1120,7 +1120,7 @@ struct pbase_tree_cache {\n \tint ref;\n \tint temporary;\n \tvoid *tree_data;\n-\tunsigned long tree_size;\n+\tsize_t tree_size;\n };\n \n static struct pbase_tree_cache *(pbase_tree_cache[256]);\n@@ -1759,8 +1759,8 @@ struct unpacked {\n \tunsigned depth;\n };\n \n-static int delta_cacheable(unsigned long src_size, unsigned long trg_size,\n-\t\t\t   unsigned long delta_size)\n+static int delta_cacheable(size_t src_size, size_t trg_size,\n+\t\t\t   size_t delta_size)\n {\n \tif (max_delta_cache_size && delta_cache_size + delta_size > max_delta_cache_size)\n \t\treturn 0;\n@@ -1801,7 +1801,7 @@ static pthread_mutex_t progress_mutex;\n #endif\n \n static int try_delta(struct unpacked *trg, struct unpacked *src,\n-\t\t     unsigned max_depth, unsigned long *mem_usage)\n+\t\t     unsigned max_depth, size_t *mem_usage)\n {\n \tstruct object_entry *trg_entry = trg->entry;\n \tstruct object_entry *src_entry = src->entry;\n@@ -1962,9 +1962,9 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)\n \treturn m;\n }\n \n-static unsigned long free_unpacked(struct unpacked *n)\n+static size_t free_unpacked(struct unpacked *n)\n {\n-\tunsigned long freed_mem = sizeof_delta_index(n->index);\n+\tsize_t freed_mem = sizeof_delta_index(n->index);\n \tfree_delta_index(n->index);\n \tn->index = NULL;\n \tif (n->data) {\n@@ -1981,7 +1981,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n {\n \tuint32_t i, idx = 0, count = 0;\n \tstruct unpacked *array;\n-\tunsigned long mem_usage = 0;\n+\tsize_t mem_usage = 0;\n \n \tarray = xcalloc(window, sizeof(struct unpacked));\n \ndiff --git a/parse-options.c b/parse-options.c\nindex 0dd9fc6..3e7c514 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -181,16 +181,16 @@ static int get_value(struct parse_opt_ctx_t *p,\n \n \tcase OPTION_MAGNITUDE:\n \t\tif (unset) {\n-\t\t\t*(unsigned long *)opt->value = 0;\n+\t\t\t*(size_t *)opt->value = 0;\n \t\t\treturn 0;\n \t\t}\n \t\tif (opt->flags & PARSE_OPT_OPTARG && !p->opt) {\n-\t\t\t*(unsigned long *)opt->value = opt->defval;\n+\t\t\t*(size_t *)opt->value = opt->defval;\n \t\t\treturn 0;\n \t\t}\n \t\tif (get_arg(p, opt, flags, &arg))\n \t\t\treturn -1;\n-\t\tif (!git_parse_ulong(arg, opt->value))\n+\t\tif (!git_parse_size_t(arg, opt->value))\n \t\t\treturn opterror(opt,\n \t\t\t\t\"expects a non-negative integer value with an optional k/m/g suffix\",\n \t\t\t\tflags);\n-- \n2.1.4\n\n"},{"id":"326541","messageId":"1502914591-26215-20-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 19/19] Convert xdiff-interface to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:31Z","receivedAt":"2017-08-16T20:17:13Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n combine-diff.c     |  2 +-\n diff.c             | 28 ++++++++++++++--------------\n diffcore-pickaxe.c |  4 ++--\n xdiff-interface.c  |  8 ++++----\n xdiff-interface.h  |  6 +++---\n 5 files changed, 24 insertions(+), 24 deletions(-)\n\ndiff --git a/combine-diff.c b/combine-diff.c\nindex acf39ec..ad5d177 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -343,7 +343,7 @@ struct combine_diff_state {\n \tstruct sline *lost_bucket;\n };\n \n-static void consume_line(void *state_, char *line, unsigned long len)\n+static void consume_line(void *state_, char *line, size_t len)\n {\n \tstruct combine_diff_state *state = state_;\n \tif (5 < len && !memcmp(\"@@ -\", line, 4)) {\ndiff --git a/diff.c b/diff.c\nindex c12d062..f665f8d 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -406,7 +406,7 @@ static struct diff_tempfile {\n \tstruct tempfile tempfile;\n } diff_temp[2];\n \n-typedef unsigned long (*sane_truncate_fn)(char *line, unsigned long len);\n+typedef size_t (*sane_truncate_fn)(char *line, size_t len);\n \n struct emit_callback {\n \tint color_diff;\n@@ -461,7 +461,7 @@ static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one)\n }\n \n /* like fill_mmfile, but only for size, so we can avoid retrieving blob */\n-static unsigned long diff_filespec_size(struct diff_filespec *one)\n+static size_t diff_filespec_size(struct diff_filespec *one)\n {\n \tif (!DIFF_FILE_VALID(one))\n \t\treturn 0;\n@@ -832,7 +832,7 @@ struct diff_words_buffer {\n \tint orig_nr, orig_alloc;\n };\n \n-static void diff_words_append(char *line, unsigned long len,\n+static void diff_words_append(char *line, size_t len,\n \t\tstruct diff_words_buffer *buffer)\n {\n \tALLOC_GROW(buffer->text.ptr, buffer->text.size + len, buffer->alloc);\n@@ -949,7 +949,7 @@ static int color_words_output_graph_prefix(struct diff_words_data *diff_words)\n \t}\n }\n \n-static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)\n+static void fn_out_diff_words_aux(void *priv, char *line, size_t len)\n {\n \tstruct diff_words_data *diff_words = priv;\n \tstruct diff_words_style *style = diff_words->style;\n@@ -1237,10 +1237,10 @@ const char *diff_line_prefix(struct diff_options *opt)\n \treturn msgbuf->buf;\n }\n \n-static unsigned long sane_truncate_line(struct emit_callback *ecb, char *line, unsigned long len)\n+static size_t sane_truncate_line(struct emit_callback *ecb, char *line, size_t len)\n {\n \tconst char *cp;\n-\tunsigned long allot;\n+\tsize_t allot;\n \tsize_t l = len;\n \n \tif (ecb->truncate)\n@@ -1270,7 +1270,7 @@ static void find_lno(const char *line, struct emit_callback *ecbdata)\n \tecbdata->lno_in_postimage = strtol(p + 1, NULL, 10);\n }\n \n-static void fn_out_consume(void *priv, char *line, unsigned long len)\n+static void fn_out_consume(void *priv, char *line, size_t len)\n {\n \tstruct emit_callback *ecbdata = priv;\n \tconst char *meta = diff_get_color(ecbdata->color_diff, DIFF_METAINFO);\n@@ -1492,7 +1492,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,\n \treturn x;\n }\n \n-static void diffstat_consume(void *priv, char *line, unsigned long len)\n+static void diffstat_consume(void *priv, char *line, size_t len)\n {\n \tstruct diffstat_t *diffstat = priv;\n \tstruct diffstat_file *x = diffstat->files[diffstat->nr - 1];\n@@ -2132,7 +2132,7 @@ struct checkdiff_t {\n \tunsigned status;\n };\n \n-static int is_conflict_marker(const char *line, int marker_size, unsigned long len)\n+static int is_conflict_marker(const char *line, int marker_size, size_t len)\n {\n \tchar firstchar;\n \tint cnt;\n@@ -2155,7 +2155,7 @@ static int is_conflict_marker(const char *line, int marker_size, unsigned long l\n \treturn 1;\n }\n \n-static void checkdiff_consume(void *priv, char *line, unsigned long len)\n+static void checkdiff_consume(void *priv, char *line, size_t len)\n {\n \tstruct checkdiff_t *data = priv;\n \tint marker_size = data->conflict_marker_size;\n@@ -2953,7 +2953,7 @@ void diff_free_filespec_data(struct diff_filespec *s)\n \n static void prep_temp_blob(const char *path, struct diff_tempfile *temp,\n \t\t\t   void *blob,\n-\t\t\t   unsigned long size,\n+\t\t\t   size_t size,\n \t\t\t   const struct object_id *oid,\n \t\t\t   int mode)\n {\n@@ -4536,7 +4536,7 @@ struct patch_id_t {\n \tint patchlen;\n };\n \n-static int remove_space(char *line, int len)\n+static size_t remove_space(char *line, size_t len)\n {\n \tint i;\n \tchar *dst = line;\n@@ -4549,10 +4549,10 @@ static int remove_space(char *line, int len)\n \treturn dst - line;\n }\n \n-static void patch_id_consume(void *priv, char *line, unsigned long len)\n+static void patch_id_consume(void *priv, char *line, size_t len)\n {\n \tstruct patch_id_t *data = priv;\n-\tint new_len;\n+\tsize_t new_len;\n \n \t/* Ignore line numbers when computing the SHA1 of the patch */\n \tif (starts_with(line, \"@@ -\"))\ndiff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c\nindex 341529b..db73cb4 100644\n--- a/diffcore-pickaxe.c\n+++ b/diffcore-pickaxe.c\n@@ -19,7 +19,7 @@ struct diffgrep_cb {\n \tint hit;\n };\n \n-static void diffgrep_consume(void *priv, char *line, unsigned long len)\n+static void diffgrep_consume(void *priv, char *line, size_t len)\n {\n \tstruct diffgrep_cb *data = priv;\n \tregmatch_t regmatch;\n@@ -70,7 +70,7 @@ static int diff_grep(mmfile_t *one, mmfile_t *two,\n static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws)\n {\n \tunsigned int cnt;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tconst char *data;\n \n \tsz = mf->size;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex d82cd4a..f12285d 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -26,7 +26,7 @@ static int parse_num(char **cp_p, int *num_p)\n \treturn 0;\n }\n \n-int parse_hunk_header(char *line, int len,\n+int parse_hunk_header(char *line, size_t len,\n \t\t      int *ob, int *on,\n \t\t      int *nb, int *nn)\n {\n@@ -57,12 +57,12 @@ int parse_hunk_header(char *line, int len,\n \treturn -!!memcmp(cp, \" @@\", 3);\n }\n \n-static void consume_one(void *priv_, char *s, unsigned long size)\n+static void consume_one(void *priv_, char *s, size_t size)\n {\n \tstruct xdiff_emit_state *priv = priv_;\n \tchar *ep;\n \twhile (size) {\n-\t\tunsigned long this_size;\n+\t\tsize_t this_size;\n \t\tep = memchr(s, '\\n', size);\n \t\tthis_size = (ep == NULL) ? size : (ep - s + 1);\n \t\tpriv->consume(priv->consume_callback_data, s, this_size);\n@@ -197,7 +197,7 @@ void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n }\n \n #define FIRST_FEW_BYTES 8000\n-int buffer_is_binary(const char *ptr, unsigned long size)\n+int buffer_is_binary(const char *ptr, size_t size)\n {\n \tif (FIRST_FEW_BYTES < size)\n \t\tsize = FIRST_FEW_BYTES;\ndiff --git a/xdiff-interface.h b/xdiff-interface.h\nindex 6f6ba90..7eb58ad 100644\n--- a/xdiff-interface.h\n+++ b/xdiff-interface.h\n@@ -11,18 +11,18 @@\n  */\n #define MAX_XDIFF_SIZE (1024UL * 1024 * 1023)\n \n-typedef void (*xdiff_emit_consume_fn)(void *, char *, unsigned long);\n+typedef void (*xdiff_emit_consume_fn)(void *, char *, size_t);\n \n int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb);\n int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,\n \t\t  xdiff_emit_consume_fn fn, void *consume_callback_data,\n \t\t  xpparam_t const *xpp, xdemitconf_t const *xecfg);\n-int parse_hunk_header(char *line, int len,\n+int parse_hunk_header(char *line, size_t len,\n \t\t      int *ob, int *on,\n \t\t      int *nb, int *nn);\n int read_mmfile(mmfile_t *ptr, const char *filename);\n void read_mmblob(mmfile_t *ptr, const struct object_id *oid);\n-int buffer_is_binary(const char *ptr, unsigned long size);\n+int buffer_is_binary(const char *ptr, size_t size);\n \n extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);\n extern void xdiff_clear_find_func(xdemitconf_t *xecfg);\n-- \n2.1.4\n\n"},{"id":"326542","messageId":"1502914591-26215-18-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 17/19] Convert ref-filter to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:29Z","receivedAt":"2017-08-16T20:17:17Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n ref-filter.c | 34 +++++++++++++++++-----------------\n 1 file changed, 17 insertions(+), 17 deletions(-)\n\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 5c903a5..30f249c 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -724,7 +724,7 @@ static int grab_objectname(const char *name, const unsigned char *sha1,\n }\n \n /* See grab_values */\n-static void grab_common_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_common_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \n@@ -739,7 +739,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct object\n \t\t\tv->s = typename(obj->type);\n \t\telse if (!strcmp(name, \"objectsize\")) {\n \t\t\tv->value = sz;\n-\t\t\tv->s = xstrfmt(\"%lu\", sz);\n+\t\t\tv->s = xstrfmt(\"%\" PRIuMAX, (uintmax_t)sz);\n \t\t}\n \t\telse if (deref)\n \t\t\tgrab_objectname(name, obj->oid.hash, v, &used_atom[i]);\n@@ -747,7 +747,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct object\n }\n \n /* See grab_values */\n-static void grab_tag_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_tag_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tstruct tag *tag = (struct tag *) obj;\n@@ -769,7 +769,7 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *ob\n }\n \n /* See grab_values */\n-static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tstruct commit *commit = (struct commit *) obj;\n@@ -786,7 +786,7 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object\n \t\t}\n \t\telse if (!strcmp(name, \"numparent\")) {\n \t\t\tv->value = commit_list_count(commit->parents);\n-\t\t\tv->s = xstrfmt(\"%lu\", (unsigned long)v->value);\n+\t\t\tv->s = xstrfmt(\"%\" PRIuMAX, (uintmax_t)v->value);\n \t\t}\n \t\telse if (!strcmp(name, \"parent\")) {\n \t\t\tstruct commit_list *parents;\n@@ -802,7 +802,7 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object\n \t}\n }\n \n-static const char *find_wholine(const char *who, int wholen, const char *buf, unsigned long sz)\n+static const char *find_wholine(const char *who, int wholen, const char *buf, size_t sz)\n {\n \tconst char *eol;\n \twhile (*buf) {\n@@ -848,7 +848,7 @@ static const char *copy_email(const char *buf)\n \treturn xmemdupz(email, eoemail + 1 - email);\n }\n \n-static char *copy_subject(const char *buf, unsigned long len)\n+static char *copy_subject(const char *buf, size_t len)\n {\n \tchar *r = xmemdupz(buf, len);\n \tint i;\n@@ -898,7 +898,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam\n }\n \n /* See grab_values */\n-static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tint wholen = strlen(who);\n@@ -957,11 +957,11 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru\n \t}\n }\n \n-static void find_subpos(const char *buf, unsigned long sz,\n-\t\t\tconst char **sub, unsigned long *sublen,\n-\t\t\tconst char **body, unsigned long *bodylen,\n-\t\t\tunsigned long *nonsiglen,\n-\t\t\tconst char **sig, unsigned long *siglen)\n+static void find_subpos(const char *buf, size_t sz,\n+\t\t\tconst char **sub, size_t *sublen,\n+\t\t\tconst char **body, size_t *bodylen,\n+\t\t\tsize_t *nonsiglen,\n+\t\t\tconst char **sig, size_t *siglen)\n {\n \tconst char *eol;\n \t/* skip past header until we hit empty line */\n@@ -1005,7 +1005,7 @@ static void find_subpos(const char *buf, unsigned long sz,\n  * If 'lines' is greater than 0, append that many lines from the given\n  * 'buf' of length 'size' to the given strbuf.\n  */\n-static void append_lines(struct strbuf *out, const char *buf, unsigned long size, int lines)\n+static void append_lines(struct strbuf *out, const char *buf, size_t size, int lines)\n {\n \tint i;\n \tconst char *sp, *eol;\n@@ -1026,11 +1026,11 @@ static void append_lines(struct strbuf *out, const char *buf, unsigned long size\n }\n \n /* See grab_values */\n-static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tint i;\n \tconst char *subpos = NULL, *bodypos = NULL, *sigpos = NULL;\n-\tunsigned long sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;\n+\tsize_t sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;\n \n \tfor (i = 0; i < used_atom_cnt; i++) {\n \t\tstruct used_atom *atom = &used_atom[i];\n@@ -1100,7 +1100,7 @@ static void fill_missing_values(struct atom_value *val)\n  * pointed at by the ref itself; otherwise it is the object the\n  * ref (which is a tag) refers to.\n  */\n-static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n+static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n {\n \tgrab_common_values(val, deref, obj, buf, sz);\n \tswitch (obj->type) {\n-- \n2.1.4\n\n"},{"id":"326543","messageId":"1502914591-26215-11-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 10/19] Add overflow check to get_delta_hdr_size","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:22Z","receivedAt":"2017-08-16T20:17:18Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n delta.h | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/delta.h b/delta.h\nindex 2df0f55..dab7352 100644\n--- a/delta.h\n+++ b/delta.h\n@@ -96,6 +96,11 @@ static inline size_t get_delta_hdr_size(const unsigned char **datap,\n \t\tcmd = *data++;\n \t\tsize |= (cmd & 0x7f) << i;\n \t\ti += 7;\n+\t\tif (bitsizeof(size_t) <= i) {\n+\t\t\tdie(\"too large object size\");\n+\t\t\tsize = 0;\n+\t\t\tbreak;\n+\t\t}\n \t} while (cmd & 0x80 && data < top);\n \t*datap = data;\n \treturn size;\n-- \n2.1.4\n\n"},{"id":"326544","messageId":"1502914591-26215-19-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 18/19] Convert tree-walk to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:30Z","receivedAt":"2017-08-16T20:17:20Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n tree-walk.c | 17 +++++++++--------\n tree-walk.h |  4 ++--\n tree.h      |  2 +-\n 3 files changed, 12 insertions(+), 11 deletions(-)\n\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 7c9f9e3..a7d8b2a 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -22,10 +22,11 @@ static const char *get_mode(const char *str, unsigned int *modep)\n \treturn str;\n }\n \n-static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned long size, struct strbuf *err)\n+static int decode_tree_entry(struct tree_desc *desc, const char *buf, size_t size, struct strbuf *err)\n {\n \tconst char *path;\n-\tunsigned int mode, len;\n+\tunsigned int mode;\n+\tsize_t len;\n \n \tif (size < 23 || buf[size - 21]) {\n \t\tstrbuf_addstr(err, _(\"too-short tree object\"));\n@@ -51,7 +52,7 @@ static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned l\n \treturn 0;\n }\n \n-static int init_tree_desc_internal(struct tree_desc *desc, const void *buffer, unsigned long size, struct strbuf *err)\n+static int init_tree_desc_internal(struct tree_desc *desc, const void *buffer, size_t size, struct strbuf *err)\n {\n \tdesc->buffer = buffer;\n \tdesc->size = size;\n@@ -60,7 +61,7 @@ static int init_tree_desc_internal(struct tree_desc *desc, const void *buffer, u\n \treturn 0;\n }\n \n-void init_tree_desc(struct tree_desc *desc, const void *buffer, unsigned long size)\n+void init_tree_desc(struct tree_desc *desc, const void *buffer, size_t size)\n {\n \tstruct strbuf err = STRBUF_INIT;\n \tif (init_tree_desc_internal(desc, buffer, size, &err))\n@@ -68,7 +69,7 @@ void init_tree_desc(struct tree_desc *desc, const void *buffer, unsigned long si\n \tstrbuf_release(&err);\n }\n \n-int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, unsigned long size)\n+int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, size_t size)\n {\n \tstruct strbuf err = STRBUF_INIT;\n \tint result = init_tree_desc_internal(desc, buffer, size, &err);\n@@ -106,8 +107,8 @@ static int update_tree_entry_internal(struct tree_desc *desc, struct strbuf *err\n {\n \tconst void *buf = desc->buffer;\n \tconst unsigned char *end = desc->entry.oid->hash + 20;\n-\tunsigned long size = desc->size;\n-\tunsigned long len = end - (const unsigned char *)buf;\n+\tsize_t size = desc->size;\n+\tsize_t len = end - (const unsigned char *)buf;\n \n \tif (size < len)\n \t\tdie(_(\"too-short tree file\"));\n@@ -487,7 +488,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)\n \n struct dir_state {\n \tvoid *tree;\n-\tunsigned long size;\n+\tsize_t size;\n \tunsigned char sha1[20];\n };\n \ndiff --git a/tree-walk.h b/tree-walk.h\nindex 68bb78b..9160cc2 100644\n--- a/tree-walk.h\n+++ b/tree-walk.h\n@@ -32,8 +32,8 @@ static inline int tree_entry_len(const struct name_entry *ne)\n \n void update_tree_entry(struct tree_desc *);\n int update_tree_entry_gently(struct tree_desc *);\n-void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size);\n-int init_tree_desc_gently(struct tree_desc *desc, const void *buf, unsigned long size);\n+void init_tree_desc(struct tree_desc *desc, const void *buf, size_t size);\n+int init_tree_desc_gently(struct tree_desc *desc, const void *buf, size_t size);\n \n /*\n  * Helper function that does both tree_entry_extract() and update_tree_entry()\ndiff --git a/tree.h b/tree.h\nindex 1dac7fc..69b9233 100644\n--- a/tree.h\n+++ b/tree.h\n@@ -9,7 +9,7 @@ struct strbuf;\n struct tree {\n \tstruct object object;\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n };\n \n struct tree *lookup_tree(const struct object_id *oid);\n-- \n2.1.4\n\n"},{"id":"326545","messageId":"1502914591-26215-17-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 16/19] Convert various things to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:28Z","receivedAt":"2017-08-16T20:17:24Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n bisect.c                | 2 +-\n blame.c                 | 2 +-\n builtin/fmt-merge-msg.c | 2 +-\n builtin/mktag.c         | 2 +-\n dir.c                   | 4 ++--\n dir.h                   | 2 +-\n 6 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 2549eaf..0580c82 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -131,7 +131,7 @@ static void show_list(const char *debug, int counted, int nr,\n \t\tstruct commit *commit = p->item;\n \t\tunsigned flags = commit->object.flags;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf = read_sha1_file(commit->object.sha1, &type, &size);\n \t\tconst char *subject_start;\n \t\tint subject_len;\ndiff --git a/blame.c b/blame.c\nindex 739a280..f628b42 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -1621,7 +1621,7 @@ static const char *get_next_line(const char *start, const char *end)\n static int prepare_lines(struct blame_scoreboard *sb)\n {\n \tconst char *buf = sb->final_buf;\n-\tunsigned long len = sb->final_buf_size;\n+\tsize_t len = sb->final_buf_size;\n \tconst char *end = buf + len;\n \tconst char *p;\n \tint *lineno;\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 61ab796..3faf100 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -464,7 +464,7 @@ static void fmt_merge_msg_title(struct strbuf *out,\n static void fmt_tag_signature(struct strbuf *tagbuf,\n \t\t\t      struct strbuf *sig,\n \t\t\t      const char *buf,\n-\t\t\t      unsigned long len)\n+\t\t\t      size_t len)\n {\n \tconst char *tag_body = strstr(buf, \"\\n\\n\");\n \tif (tag_body) {\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 0663106..ff919a7 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -34,7 +34,7 @@ static int verify_object(const unsigned char *sha1, const char *expected_type)\n \treturn ret;\n }\n \n-static int verify_tag(char *buffer, unsigned long size)\n+static int verify_tag(char *buffer, size_t size)\n {\n \tint typelen;\n \tchar type[20];\ndiff --git a/dir.c b/dir.c\nindex f161c26..0c7c767 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -180,7 +180,7 @@ static size_t common_prefix_len(const struct pathspec *pathspec)\n  */\n char *common_prefix(const struct pathspec *pathspec)\n {\n-\tunsigned long len = common_prefix_len(pathspec);\n+\tsize_t len = common_prefix_len(pathspec);\n \n \treturn len ? xmemdupz(pathspec->items[0].match, len) : NULL;\n }\n@@ -2673,7 +2673,7 @@ static void load_sha1_stat(struct sha1_stat *sha1_stat,\n \tsha1_stat->valid = 1;\n }\n \n-struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz)\n+struct untracked_cache *read_untracked_extension(const void *data, size_t sz)\n {\n \tstruct untracked_cache *uc;\n \tstruct read_data rd;\ndiff --git a/dir.h b/dir.h\nindex e371705..709c72c 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -349,7 +349,7 @@ void untracked_cache_remove_from_index(struct index_state *, const char *);\n void untracked_cache_add_to_index(struct index_state *, const char *);\n \n void free_untracked_cache(struct untracked_cache *);\n-struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz);\n+struct untracked_cache *read_untracked_extension(const void *data, size_t sz);\n void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked);\n void add_untracked_cache(struct index_state *istate);\n void remove_untracked_cache(struct index_state *istate);\n-- \n2.1.4\n\n"},{"id":"326546","messageId":"1502914591-26215-16-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 15/19] Convert archive functions to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:27Z","receivedAt":"2017-08-16T20:17:26Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n archive-tar.c | 16 ++++++++--------\n archive-zip.c | 22 +++++++++++-----------\n 2 files changed, 19 insertions(+), 19 deletions(-)\n\ndiff --git a/archive-tar.c b/archive-tar.c\nindex 719673d..ee56b2b 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -12,7 +12,7 @@\n #define BLOCKSIZE\t(RECORDSIZE * 20)\n \n static char block[BLOCKSIZE];\n-static unsigned long offset;\n+static size_t offset;\n \n static int tar_umask = 002;\n \n@@ -50,12 +50,12 @@ static void write_if_needed(void)\n  * queues up writes, so that all our write(2) calls write exactly one\n  * full block; pads writes to RECORDSIZE\n  */\n-static void do_write_blocked(const void *data, unsigned long size)\n+static void do_write_blocked(const void *data, size_t size)\n {\n \tconst char *buf = data;\n \n \tif (offset) {\n-\t\tunsigned long chunk = BLOCKSIZE - offset;\n+\t\tsize_t chunk = BLOCKSIZE - offset;\n \t\tif (size < chunk)\n \t\t\tchunk = size;\n \t\tmemcpy(block + offset, buf, chunk);\n@@ -77,7 +77,7 @@ static void do_write_blocked(const void *data, unsigned long size)\n \n static void finish_record(void)\n {\n-\tunsigned long tail;\n+\tsize_t tail;\n \ttail = offset % RECORDSIZE;\n \tif (tail)  {\n \t\tmemset(block + offset, 0, RECORDSIZE - tail);\n@@ -86,7 +86,7 @@ static void finish_record(void)\n \twrite_if_needed();\n }\n \n-static void write_blocked(const void *data, unsigned long size)\n+static void write_blocked(const void *data, size_t size)\n {\n \tdo_write_blocked(data, size);\n \tfinish_record();\n@@ -198,10 +198,10 @@ static size_t get_path_prefix(const char *path, size_t pathlen, size_t maxlen)\n \n static void prepare_header(struct archiver_args *args,\n \t\t\t   struct ustar_header *header,\n-\t\t\t   unsigned int mode, unsigned long size)\n+\t\t\t   unsigned int mode, size_t size)\n {\n \txsnprintf(header->mode, sizeof(header->mode), \"%07o\", mode & 07777);\n-\txsnprintf(header->size, sizeof(header->size), \"%011lo\", S_ISREG(mode) ? size : 0);\n+\txsnprintf(header->size, sizeof(header->size), \"%011lo\", S_ISREG(mode) ? (unsigned long)size : 0);\n \txsnprintf(header->mtime, sizeof(header->mtime), \"%011lo\", (unsigned long) args->time);\n \n \txsnprintf(header->uid, sizeof(header->uid), \"%07o\", 0);\n@@ -219,7 +219,7 @@ static void prepare_header(struct archiver_args *args,\n \n static void write_extended_header(struct archiver_args *args,\n \t\t\t\t  const unsigned char *sha1,\n-\t\t\t\t  const void *buffer, unsigned long size)\n+\t\t\t\t  const void *buffer, size_t size)\n {\n \tstruct ustar_header header;\n \tunsigned int mode;\ndiff --git a/archive-zip.c b/archive-zip.c\nindex 4492d64..3a54d80 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -186,12 +186,12 @@ static uint32_t clamp32(uintmax_t n)\n \treturn (n < max) ? n : max;\n }\n \n-static void *zlib_deflate_raw(void *data, unsigned long size,\n+static void *zlib_deflate_raw(void *data, size_t size,\n \t\t\t      int compression_level,\n-\t\t\t      unsigned long *compressed_size)\n+\t\t\t      size_t *compressed_size)\n {\n \tgit_zstream stream;\n-\tunsigned long maxsize;\n+\tsize_t maxsize;\n \tvoid *buffer;\n \tint result;\n \n@@ -219,9 +219,9 @@ static void *zlib_deflate_raw(void *data, unsigned long size,\n \treturn buffer;\n }\n \n-static void write_zip_data_desc(unsigned long size,\n-\t\t\t\tunsigned long compressed_size,\n-\t\t\t\tunsigned long crc)\n+static void write_zip_data_desc(size_t size,\n+\t\t\t\tsize_t compressed_size,\n+\t\t\t\tuint32_t crc)\n {\n \tif (size >= 0xffffffff || compressed_size >= 0xffffffff) {\n \t\tstruct zip64_data_desc trailer;\n@@ -243,9 +243,9 @@ static void write_zip_data_desc(unsigned long size,\n }\n \n static void set_zip_header_data_desc(struct zip_local_header *header,\n-\t\t\t\t     unsigned long size,\n-\t\t\t\t     unsigned long compressed_size,\n-\t\t\t\t     unsigned long crc)\n+\t\t\t\t     size_t size,\n+\t\t\t\t     size_t compressed_size,\n+\t\t\t\t     uint32_t crc)\n {\n \tcopy_le32(header->crc32, crc);\n \tcopy_le32(header->compressed_size, compressed_size);\n@@ -287,8 +287,8 @@ static int write_zip_entry(struct archiver_args *args,\n \tsize_t header_extra_size = ZIP_EXTRA_MTIME_SIZE;\n \tint need_zip64_extra = 0;\n \tunsigned long attr2;\n-\tunsigned long compressed_size;\n-\tunsigned long crc;\n+\tsize_t compressed_size;\n+\tuint32_t crc;\n \tint method;\n \tunsigned char *out;\n \tvoid *deflated = NULL;\n-- \n2.1.4\n\n"},{"id":"326547","messageId":"1502914591-26215-8-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 07/19] Convert parse_X_buffer to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:19Z","receivedAt":"2017-08-16T20:17:28Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n blob.c         | 2 +-\n blob.h         | 2 +-\n builtin/fsck.c | 2 +-\n commit.c       | 2 +-\n commit.h       | 2 +-\n object.c       | 2 +-\n object.h       | 2 +-\n pack-check.c   | 2 +-\n pack.h         | 2 +-\n tag.c          | 4 ++--\n tag.h          | 2 +-\n tree.c         | 2 +-\n tree.h         | 2 +-\n 13 files changed, 14 insertions(+), 14 deletions(-)\n\ndiff --git a/blob.c b/blob.c\nindex fa2ab4f..7530624 100644\n--- a/blob.c\n+++ b/blob.c\n@@ -11,7 +11,7 @@ struct blob *lookup_blob(const struct object_id *oid)\n \treturn object_as_type(obj, OBJ_BLOB, 0);\n }\n \n-int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)\n+int parse_blob_buffer(struct blob *item, void *buffer, size_t size)\n {\n \titem->object.parsed = 1;\n \treturn 0;\ndiff --git a/blob.h b/blob.h\nindex 4460616..31e9aa3 100644\n--- a/blob.h\n+++ b/blob.h\n@@ -11,7 +11,7 @@ struct blob {\n \n struct blob *lookup_blob(const struct object_id *oid);\n \n-int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);\n+int parse_blob_buffer(struct blob *item, void *buffer, size_t size);\n \n /**\n  * Blobs do not contain references to other objects and do not have\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 635902c..e31a52a 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -369,7 +369,7 @@ static int fsck_obj(struct object *obj)\n }\n \n static int fsck_obj_buffer(const struct object_id *oid, enum object_type type,\n-\t\t\t   unsigned long size, void *buffer, int *eaten)\n+\t\t\t   size_t size, void *buffer, int *eaten)\n {\n \t/*\n \t * Note, buffer may be NULL if type is OBJ_BLOB. See\ndiff --git a/commit.c b/commit.c\nindex 22e66b8..79decc2 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -310,7 +310,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)\n \treturn ret;\n }\n \n-int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size)\n+int parse_commit_buffer(struct commit *item, const void *buffer, size_t size)\n {\n \tconst char *tail = buffer;\n \tconst char *bufptr = buffer;\ndiff --git a/commit.h b/commit.h\nindex 6d857f0..82e966e 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -58,7 +58,7 @@ struct commit *lookup_commit_reference_by_name(const char *name);\n  */\n struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);\n \n-int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size);\n+int parse_commit_buffer(struct commit *item, const void *buffer, size_t size);\n int parse_commit_gently(struct commit *item, int quiet_on_missing);\n static inline int parse_commit(struct commit *item)\n {\ndiff --git a/object.c b/object.c\nindex dff9f52..1a18545 100644\n--- a/object.c\n+++ b/object.c\n@@ -179,7 +179,7 @@ struct object *lookup_unknown_object(const unsigned char *sha1)\n \treturn obj;\n }\n \n-struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p)\n+struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, size_t size, void *buffer, int *eaten_p)\n {\n \tstruct object *obj;\n \t*eaten_p = 0;\ndiff --git a/object.h b/object.h\nindex 0a419ba..8b1bbfd 100644\n--- a/object.h\n+++ b/object.h\n@@ -102,7 +102,7 @@ struct object *parse_object_or_die(const struct object_id *oid, const char *name\n  * parsing it.  eaten_p indicates if the object has a borrowed copy\n  * of buffer and the caller should not free() it.\n  */\n-struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p);\n+struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, size_t size, void *buffer, int *eaten_p);\n \n /** Returns the object, with potentially excess memory allocated. **/\n struct object *lookup_unknown_object(const unsigned  char *sha1);\ndiff --git a/pack-check.c b/pack-check.c\nindex a78da5a..da64a91 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -175,7 +175,7 @@ int verify_pack_index(struct packed_git *p)\n \n \t/* Verify SHA1 sum of the index file */\n \tgit_SHA1_Init(&ctx);\n-\tgit_SHA1_Update(&ctx, index_base, (unsigned int)(index_size - 20));\n+\tgit_SHA1_Update(&ctx, index_base, (size_t)(index_size - 20));\n \tgit_SHA1_Final(sha1, &ctx);\n \tif (hashcmp(sha1, index_base + index_size - 20))\n \t\terr = error(\"Packfile index for %s SHA1 mismatch\",\ndiff --git a/pack.h b/pack.h\nindex 8294341..0070927 100644\n--- a/pack.h\n+++ b/pack.h\n@@ -75,7 +75,7 @@ struct pack_idx_entry {\n \n struct progress;\n /* Note, the data argument could be NULL if object type is blob */\n-typedef int (*verify_fn)(const struct object_id *, enum object_type, unsigned long, void*, int*);\n+typedef int (*verify_fn)(const struct object_id *, enum object_type, size_t, void*, int*);\n \n extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, const struct pack_idx_option *, const unsigned char *sha1);\n extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr);\ndiff --git a/tag.c b/tag.c\nindex b6bb5ea..301ee9c 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -7,7 +7,7 @@\n \n const char *tag_type = \"tag\";\n \n-static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags)\n+static int run_gpg_verify(const char *buf, size_t size, unsigned flags)\n {\n \tstruct signature_check sigc;\n \tsize_t payload_size;\n@@ -114,7 +114,7 @@ static timestamp_t parse_tag_date(const char *buf, const char *tail)\n \treturn parse_timestamp(dateptr, NULL, 10);\n }\n \n-int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)\n+int parse_tag_buffer(struct tag *item, const void *data, size_t size)\n {\n \tstruct object_id oid;\n \tchar type[20];\ndiff --git a/tag.h b/tag.h\nindex d469534..8ed0648 100644\n--- a/tag.h\n+++ b/tag.h\n@@ -13,7 +13,7 @@ struct tag {\n };\n \n extern struct tag *lookup_tag(const struct object_id *oid);\n-extern int parse_tag_buffer(struct tag *item, const void *data, unsigned long size);\n+extern int parse_tag_buffer(struct tag *item, const void *data, size_t size);\n extern int parse_tag(struct tag *item);\n extern struct object *deref_tag(struct object *, const char *, int);\n extern struct object *deref_tag_noverify(struct object *);\ndiff --git a/tree.c b/tree.c\nindex 5e42f83..956d65f 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -200,7 +200,7 @@ struct tree *lookup_tree(const struct object_id *oid)\n \treturn object_as_type(obj, OBJ_TREE, 0);\n }\n \n-int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)\n+int parse_tree_buffer(struct tree *item, void *buffer, size_t size)\n {\n \tif (item->object.parsed)\n \t\treturn 0;\ndiff --git a/tree.h b/tree.h\nindex 744e6dc..1dac7fc 100644\n--- a/tree.h\n+++ b/tree.h\n@@ -14,7 +14,7 @@ struct tree {\n \n struct tree *lookup_tree(const struct object_id *oid);\n \n-int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);\n+int parse_tree_buffer(struct tree *item, void *buffer, size_t size);\n \n int parse_tree_gently(struct tree *tree, int quiet_on_missing);\n static inline int parse_tree(struct tree *tree)\n-- \n2.1.4\n\n"},{"id":"326548","messageId":"1502914591-26215-15-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 14/19] Convert unpack-objects to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:26Z","receivedAt":"2017-08-16T20:17:33Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n builtin/unpack-objects.c | 20 ++++++++++----------\n 1 file changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 001dd4b..0d8b6b3 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -31,7 +31,7 @@ static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;\n  */\n struct obj_buffer {\n \tchar *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n };\n \n static struct decoration obj_decorate;\n@@ -41,7 +41,7 @@ static struct obj_buffer *lookup_object_buffer(struct object *base)\n \treturn lookup_decoration(&obj_decorate, base);\n }\n \n-static void add_object_buffer(struct object *object, char *buffer, unsigned long size)\n+static void add_object_buffer(struct object *object, char *buffer, size_t size)\n {\n \tstruct obj_buffer *obj;\n \tobj = xcalloc(1, sizeof(struct obj_buffer));\n@@ -93,7 +93,7 @@ static void use(int bytes)\n \t\tdie(_(\"pack exceeds maximum allowed size\"));\n }\n \n-static void *get_data(unsigned long size)\n+static void *get_data(size_t size)\n {\n \tgit_zstream stream;\n \tvoid *buf = xmallocz(size);\n@@ -130,7 +130,7 @@ struct delta_info {\n \tstruct object_id base_oid;\n \tunsigned nr;\n \toff_t base_offset;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *delta;\n \tstruct delta_info *next;\n };\n@@ -139,7 +139,7 @@ static struct delta_info *delta_list;\n \n static void add_delta_to_list(unsigned nr, const struct object_id *base_oid,\n \t\t\t      off_t base_offset,\n-\t\t\t      void *delta, unsigned long size)\n+\t\t\t      void *delta, size_t size)\n {\n \tstruct delta_info *info = xmalloc(sizeof(*info));\n \n@@ -226,7 +226,7 @@ static void write_rest(void)\n }\n \n static void added_object(unsigned nr, enum object_type type,\n-\t\t\t void *data, unsigned long size);\n+\t\t\t void *data, size_t size);\n \n /*\n  * Write out nr-th object from the list, now we know the contents\n@@ -234,7 +234,7 @@ static void added_object(unsigned nr, enum object_type type,\n  * to be checked at the end.\n  */\n static void write_object(unsigned nr, enum object_type type,\n-\t\t\t void *buf, unsigned long size)\n+\t\t\t void *buf, size_t size)\n {\n \tif (!strict) {\n \t\tif (write_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash) < 0)\n@@ -291,7 +291,7 @@ static void resolve_delta(unsigned nr, enum object_type type,\n  * resolve all the deltified objects that are based on it.\n  */\n static void added_object(unsigned nr, enum object_type type,\n-\t\t\t void *data, unsigned long size)\n+\t\t\t void *data, size_t size)\n {\n \tstruct delta_info **p = &delta_list;\n \tstruct delta_info *info;\n@@ -310,7 +310,7 @@ static void added_object(unsigned nr, enum object_type type,\n \t}\n }\n \n-static void unpack_non_delta_entry(enum object_type type, unsigned long size,\n+static void unpack_non_delta_entry(enum object_type type, size_t size,\n \t\t\t\t   unsigned nr)\n {\n \tvoid *buf = get_data(size);\n@@ -436,7 +436,7 @@ static void unpack_one(unsigned nr)\n {\n \tunsigned shift;\n \tunsigned char *pack;\n-\tunsigned long size, c;\n+\tsize_t size, c;\n \tenum object_type type;\n \n \tobj_list[nr].offset = consumed_bytes;\n-- \n2.1.4\n\n"},{"id":"326549","messageId":"1502914591-26215-14-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 13/19] Convert index-pack to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:25Z","receivedAt":"2017-08-16T20:17:38Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n builtin/index-pack.c | 26 +++++++++++++-------------\n 1 file changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 7f3ccd0..bf2d728 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -435,7 +435,7 @@ static int is_delta_type(enum object_type type)\n \treturn (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);\n }\n \n-static void *unpack_entry_data(off_t offset, unsigned long size,\n+static void *unpack_entry_data(off_t offset, size_t size,\n \t\t\t       enum object_type type, unsigned char *sha1)\n {\n \tstatic char fixed_buf[8192];\n@@ -444,10 +444,10 @@ static void *unpack_entry_data(off_t offset, unsigned long size,\n \tvoid *buf;\n \tgit_SHA_CTX c;\n \tchar hdr[32];\n-\tint hdrlen;\n+\tsize_t hdrlen;\n \n \tif (!is_delta_type(type)) {\n-\t\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", typename(type), size) + 1;\n+\t\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %\" PRIuMAX, typename(type), (uintmax_t)size) + 1;\n \t\tgit_SHA1_Init(&c);\n \t\tgit_SHA1_Update(&c, hdr, hdrlen);\n \t} else\n@@ -489,7 +489,7 @@ static void *unpack_raw_entry(struct object_entry *obj,\n \t\t\t      unsigned char *sha1)\n {\n \tunsigned char *p;\n-\tunsigned long size, c;\n+\tsize_t size, c;\n \toff_t base_offset;\n \tunsigned shift;\n \tvoid *data;\n@@ -551,11 +551,11 @@ static void *unpack_raw_entry(struct object_entry *obj,\n }\n \n static void *unpack_data(struct object_entry *obj,\n-\t\t\t int (*consume)(const unsigned char *, unsigned long, void *),\n+\t\t\t int (*consume)(const unsigned char *, size_t, void *),\n \t\t\t void *cb_data)\n {\n \toff_t from = obj[0].idx.offset + obj[0].hdr_size;\n-\toff_t len = obj[1].idx.offset - from;\n+\tsize_t len = obj[1].idx.offset - from;\n \tunsigned char *data, *inbuf;\n \tgit_zstream stream;\n \tint status;\n@@ -728,10 +728,10 @@ struct compare_data {\n \tstruct object_entry *entry;\n \tstruct git_istream *st;\n \tunsigned char *buf;\n-\tunsigned long buf_size;\n+\tsize_t buf_size;\n };\n \n-static int compare_objects(const unsigned char *buf, unsigned long size,\n+static int compare_objects(const unsigned char *buf, size_t size,\n \t\t\t   void *cb_data)\n {\n \tstruct compare_data *data = cb_data;\n@@ -783,7 +783,7 @@ static int check_collison(struct object_entry *entry)\n }\n \n static void sha1_object(const void *data, struct object_entry *obj_entry,\n-\t\t\tunsigned long size, enum object_type type,\n+\t\t\tsize_t size, enum object_type type,\n \t\t\tconst struct object_id *oid)\n {\n \tvoid *new_data = NULL;\n@@ -1311,11 +1311,11 @@ static int write_compressed(struct sha1file *f, void *in, unsigned int size)\n \n static struct object_entry *append_obj_to_pack(struct sha1file *f,\n \t\t\t       const unsigned char *sha1, void *buf,\n-\t\t\t       unsigned long size, enum object_type type)\n+\t\t\t       size_t size, enum object_type type)\n {\n \tstruct object_entry *obj = &objects[nr_objects++];\n \tunsigned char header[10];\n-\tunsigned long s = size;\n+\tsize_t s = size;\n \tint n = 0;\n \tunsigned char c = (type << 4) | (s & 15);\n \ts >>= 4;\n@@ -1585,10 +1585,10 @@ static void show_pack_info(int stat_only)\n \t\t\tchain_histogram[obj_stat[i].delta_depth - 1]++;\n \t\tif (stat_only)\n \t\t\tcontinue;\n-\t\tprintf(\"%s %-6s %\" PRIuMAX \" %lu %\" PRIuMAX,\n+\t\tprintf(\"%s %-6s %\" PRIuMAX \" %\" PRIuMAX \" %\" PRIuMAX,\n \t\t       oid_to_hex(&obj->idx.oid),\n \t\t       typename(obj->real_type), (uintmax_t)obj->size,\n-\t\t       (unsigned long)(obj[1].idx.offset - obj->idx.offset),\n+\t\t       (uintmax_t)(obj[1].idx.offset - obj->idx.offset),\n \t\t       (uintmax_t)obj->idx.offset);\n \t\tif (is_delta_type(obj->type)) {\n \t\t\tstruct object_entry *bobj = &objects[obj_stat[i].base_object_no];\n-- \n2.1.4\n\n"},{"id":"326550","messageId":"1502914591-26215-1-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":null,"subject":"[Patch size_t V3 00/19] use size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:12Z","receivedAt":"2017-08-16T20:17:39Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nThis patchset is for next [24db08a6e8fed761d3bace7f2d5997806e20b9f7].\nIts a complete collection of all patches. Some errors were fixed and\nit sticks with off_t for length in (pack) files. Object sizes are handled\nas size_t.\n\nMartin Koegler (19):\n  delta: fix enconding size larger than an \"uint\" can hold\n  Convert size datatype to size_t\n  Convert zlib.c to size_t\n  delta: Fix offset overflows\n  Convert sha1_file.c to size_t\n  Use size_t for sha1\n  Convert parse_X_buffer to size_t\n  Convert fsck.c & commit.c to size_t\n  Convert cache functions to size_t\n  Add overflow check to get_delta_hdr_size\n  Use size_t for config parsing\n  Convert pack-objects to size_t\n  Convert index-pack to size_t\n  Convert unpack-objects to size_t\n  Convert archive functions to size_t\n  Convert various things to size_t\n  Convert ref-filter to size_t\n  Convert tree-walk to size_t\n  Convert xdiff-interface to size_t\n\n Documentation/technical/api-parse-options.txt |   2 +-\n apply.c                                       |   6 +-\n archive-tar.c                                 |  20 ++---\n archive-zip.c                                 |  24 ++---\n archive.c                                     |   2 +-\n archive.h                                     |   2 +-\n bisect.c                                      |   2 +-\n blame.c                                       |   6 +-\n blame.h                                       |   2 +-\n blob.c                                        |   2 +-\n blob.h                                        |   2 +-\n block-sha1/sha1.c                             |   2 +-\n block-sha1/sha1.h                             |   2 +-\n builtin/cat-file.c                            |  14 +--\n builtin/difftool.c                            |   2 +-\n builtin/fast-export.c                         |   8 +-\n builtin/fmt-merge-msg.c                       |   4 +-\n builtin/fsck.c                                |   4 +-\n builtin/grep.c                                |   8 +-\n builtin/index-pack.c                          |  40 ++++-----\n builtin/log.c                                 |   4 +-\n builtin/ls-tree.c                             |   4 +-\n builtin/merge-tree.c                          |   6 +-\n builtin/mktag.c                               |   4 +-\n builtin/notes.c                               |   6 +-\n builtin/pack-objects.c                        |  84 +++++++++---------\n builtin/reflog.c                              |   2 +-\n builtin/replace.c                             |   2 +-\n builtin/tag.c                                 |   4 +-\n builtin/unpack-file.c                         |   2 +-\n builtin/unpack-objects.c                      |  34 +++----\n builtin/verify-commit.c                       |   2 +-\n bundle.c                                      |   2 +-\n cache-tree.c                                  |   6 +-\n cache-tree.h                                  |   2 +-\n cache.h                                       |  54 ++++++------\n combine-diff.c                                |  11 +--\n commit.c                                      |  22 ++---\n commit.h                                      |  10 +--\n config.c                                      |  29 ++++--\n config.h                                      |   2 +\n convert.c                                     |  18 ++--\n delta.h                                       |  31 ++++---\n diff-delta.c                                  |  42 +++++----\n diff.c                                        |  46 +++++-----\n diff.h                                        |   2 +-\n diffcore-pickaxe.c                            |   4 +-\n diffcore.h                                    |   2 +-\n dir.c                                         |   6 +-\n dir.h                                         |   2 +-\n entry.c                                       |   4 +-\n environment.c                                 |   4 +-\n fast-import.c                                 |  24 ++---\n fsck.c                                        |  16 ++--\n fsck.h                                        |   2 +-\n grep.h                                        |   2 +-\n http-push.c                                   |   5 +-\n mailmap.c                                     |   2 +-\n match-trees.c                                 |   4 +-\n merge-blobs.c                                 |   6 +-\n merge-blobs.h                                 |   2 +-\n merge-recursive.c                             |   4 +-\n notes-cache.c                                 |   2 +-\n notes-merge.c                                 |   2 +-\n notes.c                                       |   6 +-\n object.c                                      |   4 +-\n object.h                                      |   2 +-\n pack-check.c                                  |   8 +-\n pack-objects.h                                |   6 +-\n pack.h                                        |   2 +-\n parse-options.c                               |   6 +-\n patch-delta.c                                 |  11 +--\n ppc/sha1.c                                    |   2 +-\n ppc/sha1.h                                    |   2 +-\n read-cache.c                                  |  22 ++---\n ref-filter.c                                  |  38 ++++----\n remote-testsvn.c                              |   4 +-\n rerere.c                                      |   2 +-\n sha1_file.c                                   | 122 +++++++++++++-------------\n sha1dc_git.c                                  |   2 +-\n sha1dc_git.h                                  |   2 +-\n streaming.c                                   |  10 +--\n streaming.h                                   |   2 +-\n submodule-config.c                            |   2 +-\n t/helper/test-delta.c                         |   2 +-\n tag.c                                         |   8 +-\n tag.h                                         |   2 +-\n tree-walk.c                                   |  25 +++---\n tree-walk.h                                   |   4 +-\n tree.c                                        |   4 +-\n tree.h                                        |   4 +-\n wrapper.c                                     |   8 +-\n xdiff-interface.c                             |  10 +--\n xdiff-interface.h                             |   6 +-\n zlib.c                                        |   8 +-\n 95 files changed, 525 insertions(+), 489 deletions(-)\n\n-- \n2.1.4\n\n"},{"id":"326551","messageId":"1502914591-26215-3-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 02/19] Convert size datatype to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:14Z","receivedAt":"2017-08-16T20:17:45Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nIt changes the signature of the core object access function\nincluding any other functions to assure a clean compile if\nsizeof(size_t) != sizeof(unsigned long).\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n apply.c                  |  6 +++---\n archive-tar.c            |  4 ++--\n archive-zip.c            |  2 +-\n archive.c                |  2 +-\n archive.h                |  2 +-\n blame.c                  |  4 ++--\n blame.h                  |  2 +-\n builtin/cat-file.c       | 14 +++++++-------\n builtin/difftool.c       |  2 +-\n builtin/fast-export.c    |  8 ++++----\n builtin/fmt-merge-msg.c  |  2 +-\n builtin/fsck.c           |  2 +-\n builtin/grep.c           |  8 ++++----\n builtin/index-pack.c     | 16 ++++++++--------\n builtin/log.c            |  4 ++--\n builtin/ls-tree.c        |  4 ++--\n builtin/merge-tree.c     |  6 +++---\n builtin/mktag.c          |  2 +-\n builtin/notes.c          |  6 +++---\n builtin/pack-objects.c   | 24 ++++++++++++-----------\n builtin/reflog.c         |  2 +-\n builtin/tag.c            |  4 ++--\n builtin/unpack-file.c    |  2 +-\n builtin/unpack-objects.c | 14 +++++++-------\n builtin/verify-commit.c  |  2 +-\n bundle.c                 |  2 +-\n cache.h                  | 22 ++++++++++-----------\n combine-diff.c           |  9 +++++----\n commit.c                 |  6 +++---\n config.c                 |  2 +-\n delta.h                  | 26 ++++++++++++-------------\n diff-delta.c             | 16 ++++++++--------\n diff.c                   | 18 ++++++++---------\n diff.h                   |  2 +-\n diffcore.h               |  2 +-\n dir.c                    |  2 +-\n entry.c                  |  4 ++--\n fast-import.c            | 24 +++++++++++------------\n fsck.c                   |  2 +-\n grep.h                   |  2 +-\n http-push.c              |  5 +++--\n mailmap.c                |  2 +-\n match-trees.c            |  4 ++--\n merge-blobs.c            |  6 +++---\n merge-blobs.h            |  2 +-\n merge-recursive.c        |  4 ++--\n notes-cache.c            |  2 +-\n notes-merge.c            |  2 +-\n notes.c                  |  6 +++---\n object.c                 |  2 +-\n pack-check.c             |  2 +-\n pack-objects.h           |  6 +++---\n patch-delta.c            | 11 ++++++-----\n read-cache.c             |  4 ++--\n ref-filter.c             |  4 ++--\n remote-testsvn.c         |  4 ++--\n rerere.c                 |  2 +-\n sha1_file.c              | 50 +++++++++++++++++++++++++-----------------------\n streaming.c              |  8 ++++----\n streaming.h              |  2 +-\n submodule-config.c       |  2 +-\n t/helper/test-delta.c    |  2 +-\n tag.c                    |  4 ++--\n tree-walk.c              |  8 ++++----\n tree.c                   |  2 +-\n xdiff-interface.c        |  2 +-\n 66 files changed, 219 insertions(+), 212 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 41ee63e..af9ffee 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3082,7 +3082,7 @@ static int apply_binary_fragment(struct apply_state *state,\n \t\t\t\t struct patch *patch)\n {\n \tstruct fragment *fragment = patch->fragments;\n-\tunsigned long len;\n+\tsize_t len;\n \tvoid *dst;\n \n \tif (!fragment)\n@@ -3171,7 +3171,7 @@ static int apply_binary(struct apply_state *state,\n \tif (has_sha1_file(oid.hash)) {\n \t\t/* We already have the postimage */\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *result;\n \n \t\tresult = read_sha1_file(oid.hash, &type, &size);\n@@ -3233,7 +3233,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns\n \t\tstrbuf_addf(buf, \"Subproject commit %s\\n\", oid_to_hex(oid));\n \t} else {\n \t\tenum object_type type;\n-\t\tunsigned long sz;\n+\t\tsize_t sz;\n \t\tchar *result;\n \n \t\tresult = read_sha1_file(oid->hash, &type, &sz);\ndiff --git a/archive-tar.c b/archive-tar.c\nindex c6ed96e..719673d 100644\n--- a/archive-tar.c\n+++ b/archive-tar.c\n@@ -115,7 +115,7 @@ static int stream_blocked(const unsigned char *sha1)\n {\n \tstruct git_istream *st;\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tchar buf[BLOCKSIZE];\n \tssize_t readlen;\n \n@@ -240,7 +240,7 @@ static int write_tar_entry(struct archiver_args *args,\n \tstruct ustar_header header;\n \tstruct strbuf ext_header = STRBUF_INIT;\n \tunsigned int old_mode = mode;\n-\tunsigned long size, size_in_header;\n+\tsize_t size, size_in_header;\n \tvoid *buffer;\n \tint err = 0;\n \ndiff --git a/archive-zip.c b/archive-zip.c\nindex e8913e5..4492d64 100644\n--- a/archive-zip.c\n+++ b/archive-zip.c\n@@ -295,7 +295,7 @@ static int write_zip_entry(struct archiver_args *args,\n \tvoid *buffer;\n \tstruct git_istream *stream = NULL;\n \tunsigned long flags = 0;\n-\tunsigned long size;\n+\tsize_t size;\n \tint is_binary = -1;\n \tconst char *path_without_prefix = path + args->baselen;\n \tunsigned int creator_version = 0;\ndiff --git a/archive.c b/archive.c\nindex 557dd2d..92f3960 100644\n--- a/archive.c\n+++ b/archive.c\n@@ -66,7 +66,7 @@ static void format_subst(const struct commit *commit,\n void *sha1_file_to_archive(const struct archiver_args *args,\n \t\t\t   const char *path, const unsigned char *sha1,\n \t\t\t   unsigned int mode, enum object_type *type,\n-\t\t\t   unsigned long *sizep)\n+\t\t\t   size_t *sizep)\n {\n \tvoid *buffer;\n \tconst struct commit *commit = args->convert ? args->commit : NULL;\ndiff --git a/archive.h b/archive.h\nindex 62d1d82..dd831a3 100644\n--- a/archive.h\n+++ b/archive.h\n@@ -42,6 +42,6 @@ const char *archive_format_from_filename(const char *filename);\n extern void *sha1_file_to_archive(const struct archiver_args *args,\n \t\t\t\t  const char *path, const unsigned char *sha1,\n \t\t\t\t  unsigned int mode, enum object_type *type,\n-\t\t\t\t  unsigned long *sizep);\n+\t\t\t\t  size_t *sizep);\n \n #endif\t/* ARCHIVE_H */\ndiff --git a/blame.c b/blame.c\nindex f575e9c..739a280 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -193,7 +193,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,\n \t\tstruct stat st;\n \t\tconst char *read_from;\n \t\tchar *buf_ptr;\n-\t\tunsigned long buf_len;\n+\t\tsize_t buf_len;\n \n \t\tif (contents_from) {\n \t\t\tif (stat(contents_from, &st) < 0)\n@@ -290,7 +290,7 @@ static void fill_origin_blob(struct diff_options *opt,\n {\n \tif (!o->file.ptr) {\n \t\tenum object_type type;\n-\t\tunsigned long file_size;\n+\t\tsize_t file_size;\n \n \t\t(*num_read_blob)++;\n \t\tif (DIFF_OPT_TST(opt, ALLOW_TEXTCONV) &&\ndiff --git a/blame.h b/blame.h\nindex a6c915c..9a0ed1c 100644\n--- a/blame.h\n+++ b/blame.h\n@@ -111,7 +111,7 @@ struct blame_scoreboard {\n \t * indexed with scoreboard.lineno[blame_entry.lno].\n \t */\n \tconst char *final_buf;\n-\tunsigned long final_buf_size;\n+\tsize_t final_buf_size;\n \n \t/* linked list of blames */\n \tstruct blame_entry *ent;\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex 62c8cf0..045cab5 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -27,7 +27,7 @@ static const char *force_path;\n \n static int filter_object(const char *path, unsigned mode,\n \t\t\t const struct object_id *oid,\n-\t\t\t char **buf, unsigned long *size)\n+\t\t\t char **buf, size_t *size)\n {\n \tenum object_type type;\n \n@@ -53,7 +53,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \tstruct object_id oid;\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tstruct object_context obj_context;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tstruct strbuf sb = STRBUF_INIT;\n@@ -89,7 +89,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n \t\toi.sizep = &size;\n \t\tif (sha1_object_info_extended(oid.hash, &oi, flags) < 0)\n \t\t\tdie(\"git cat-file: could not get object info\");\n-\t\tprintf(\"%lu\\n\", size);\n+\t\tprintf(\"%\" PRIuMAX \"\\n\", (uintmax_t)size);\n \t\treturn 0;\n \n \tcase 'e':\n@@ -176,7 +176,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,\n struct expand_data {\n \tstruct object_id oid;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t disk_size;\n \tconst char *rest;\n \tstruct object_id delta_base_oid;\n@@ -232,7 +232,7 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len,\n \t\tif (data->mark_query)\n \t\t\tdata->info.sizep = &data->size;\n \t\telse\n-\t\t\tstrbuf_addf(sb, \"%lu\", data->size);\n+\t\t\tstrbuf_addf(sb, \"%\" PRIuMAX, (uintmax_t)data->size);\n \t} else if (is_atom(\"objectsize:disk\", atom, len)) {\n \t\tif (data->mark_query)\n \t\t\tdata->info.disk_sizep = &data->disk_size;\n@@ -288,7 +288,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t\t\tfflush(stdout);\n \t\tif (opt->cmdmode) {\n \t\t\tchar *contents;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \n \t\t\tif (!data->rest)\n \t\t\t\tdie(\"missing path for '%s'\", oid_to_hex(oid));\n@@ -316,7 +316,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d\n \t}\n \telse {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tvoid *contents;\n \n \t\tcontents = read_sha1_file(oid->hash, &type, &size);\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex 8864d84..525d4d9 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -305,7 +305,7 @@ static char *get_symlink(const struct object_id *oid, const char *path)\n \t\tdata = strbuf_detach(&link, NULL);\n \t} else {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tdata = read_sha1_file(oid->hash, &type, &size);\n \t\tif (!data)\n \t\t\tdie(_(\"could not read object %s for symlink %s\"),\ndiff --git a/builtin/fast-export.c b/builtin/fast-export.c\nindex d412c0a..9ef2fc1 100644\n--- a/builtin/fast-export.c\n+++ b/builtin/fast-export.c\n@@ -205,7 +205,7 @@ static void show_progress(void)\n  * There's no need to cache this result with anonymize_mem, since\n  * we already handle blob content caching with marks.\n  */\n-static char *anonymize_blob(unsigned long *size)\n+static char *anonymize_blob(size_t *size)\n {\n \tstatic int counter;\n \tstruct strbuf out = STRBUF_INIT;\n@@ -216,7 +216,7 @@ static char *anonymize_blob(unsigned long *size)\n \n static void export_blob(const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf;\n \tstruct object *object;\n@@ -250,7 +250,7 @@ static void export_blob(const struct object_id *oid)\n \n \tmark_next_object(object);\n \n-\tprintf(\"blob\\nmark :%\"PRIu32\"\\ndata %lu\\n\", last_idnum, size);\n+\tprintf(\"blob\\nmark :%\"PRIu32\"\\ndata %\" PRIuMAX \"\\n\", last_idnum, (uintmax_t)size);\n \tif (size && fwrite(buf, size, 1, stdout) != 1)\n \t\tdie_errno (\"Could not write blob '%s'\", oid_to_hex(oid));\n \tprintf(\"\\n\");\n@@ -644,7 +644,7 @@ static void handle_tail(struct object_array *commits, struct rev_info *revs)\n \n static void handle_tag(const char *name, struct tag *tag)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf;\n \tconst char *tagger, *tagger_end, *message;\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex e99b5dd..61ab796 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -486,7 +486,7 @@ static void fmt_merge_msg_sigs(struct strbuf *out)\n \tfor (i = 0; i < origins.nr; i++) {\n \t\tunsigned char *sha1 = origins.items[i].util;\n \t\tenum object_type type;\n-\t\tunsigned long size, len;\n+\t\tsize_t size, len;\n \t\tchar *buf = read_sha1_file(sha1, &type, &size);\n \t\tstruct strbuf sig = STRBUF_INIT;\n \ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex a92f448..635902c 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -489,7 +489,7 @@ static struct object *parse_loose_object(const struct object_id *oid,\n \tstruct object *obj;\n \tvoid *contents;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tint eaten;\n \n \tif (read_loose_object(path, oid->hash, &type, &size, &contents) < 0)\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex a70d8e2..b032d24 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -302,7 +302,7 @@ static int grep_cmd_config(const char *var, const char *value, void *cb)\n \treturn st;\n }\n \n-static void *lock_and_read_oid_file(const struct object_id *oid, enum object_type *type, unsigned long *size)\n+static void *lock_and_read_oid_file(const struct object_id *oid, enum object_type *type, size_t *size)\n {\n \tvoid *data;\n \n@@ -437,7 +437,7 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,\n \t\tstruct object *object;\n \t\tstruct tree_desc tree;\n \t\tvoid *data;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tstruct strbuf base = STRBUF_INIT;\n \n \t\tobject = parse_object_or_die(oid, oid_to_hex(oid));\n@@ -564,7 +564,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,\n \t\t\tenum object_type type;\n \t\t\tstruct tree_desc sub;\n \t\t\tvoid *data;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \n \t\t\tdata = lock_and_read_oid_file(entry.oid, &type, &size);\n \t\t\tif (!data)\n@@ -600,7 +600,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,\n \tif (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) {\n \t\tstruct tree_desc tree;\n \t\tvoid *data;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tstruct strbuf base;\n \t\tint hit, len;\n \ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 26828c1..7f3ccd0 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -18,8 +18,8 @@ static const char index_pack_usage[] =\n \n struct object_entry {\n \tstruct pack_idx_entry idx;\n-\tunsigned long size;\n-\tunsigned char hdr_size;\n+\tsize_t size;\n+\tsize_t hdr_size;\n \tsigned char type;\n \tsigned char real_type;\n };\n@@ -34,7 +34,7 @@ struct base_data {\n \tstruct base_data *child;\n \tstruct object_entry *obj;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ref_first, ref_last;\n \tint ofs_first, ofs_last;\n };\n@@ -219,7 +219,7 @@ static unsigned check_object(struct object *obj)\n \t\treturn 0;\n \n \tif (!(obj->flags & FLAG_CHECKED)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tint type = sha1_object_info(obj->oid.hash, &size);\n \t\tif (type <= 0)\n \t\t\tdie(_(\"did not receive expected object %s\"),\n@@ -763,7 +763,7 @@ static int check_collison(struct object_entry *entry)\n {\n \tstruct compare_data data;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (entry->size <= big_file_threshold || entry->type != OBJ_BLOB)\n \t\treturn -1;\n@@ -807,7 +807,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \tif (collision_test_needed) {\n \t\tvoid *has_data;\n \t\tenum object_type has_type;\n-\t\tunsigned long has_size;\n+\t\tsize_t has_size;\n \t\tread_lock();\n \t\thas_type = sha1_object_info(oid->hash, &has_size);\n \t\tif (has_type < 0)\n@@ -1585,9 +1585,9 @@ static void show_pack_info(int stat_only)\n \t\t\tchain_histogram[obj_stat[i].delta_depth - 1]++;\n \t\tif (stat_only)\n \t\t\tcontinue;\n-\t\tprintf(\"%s %-6s %lu %lu %\"PRIuMAX,\n+\t\tprintf(\"%s %-6s %\" PRIuMAX \" %lu %\" PRIuMAX,\n \t\t       oid_to_hex(&obj->idx.oid),\n-\t\t       typename(obj->real_type), obj->size,\n+\t\t       typename(obj->real_type), (uintmax_t)obj->size,\n \t\t       (unsigned long)(obj[1].idx.offset - obj->idx.offset),\n \t\t       (uintmax_t)obj->idx.offset);\n \t\tif (is_delta_type(obj->type)) {\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 725c7b8..2330822 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -480,7 +480,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \tstruct object_id oidc;\n \tstruct object_context obj_context;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tfflush(rev->diffopt.file);\n \tif (!DIFF_OPT_TOUCHED(&rev->diffopt, ALLOW_TEXTCONV) ||\n@@ -506,7 +506,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c\n \n static int show_tag_object(const struct object_id *oid, struct rev_info *rev)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = read_sha1_file(oid->hash, &type, &size);\n \tint offset = 0;\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex ef96540..b09d9cb 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -93,13 +93,13 @@ static int show_tree(const unsigned char *sha1, struct strbuf *base,\n \t\tif (ls_options & LS_SHOW_SIZE) {\n \t\t\tchar size_text[24];\n \t\t\tif (!strcmp(type, blob_type)) {\n-\t\t\t\tunsigned long size;\n+\t\t\t\tsize_t size;\n \t\t\t\tif (sha1_object_info(sha1, &size) == OBJ_BAD)\n \t\t\t\t\txsnprintf(size_text, sizeof(size_text),\n \t\t\t\t\t\t  \"BAD\");\n \t\t\t\telse\n \t\t\t\t\txsnprintf(size_text, sizeof(size_text),\n-\t\t\t\t\t\t  \"%lu\", size);\n+\t\t\t\t\t\t  \"%\" PRIuMAX, (uintmax_t)size);\n \t\t\t} else\n \t\t\t\txsnprintf(size_text, sizeof(size_text), \"-\");\n \t\t\tprintf(\"%06o %s %s %7s\\t\", mode, type,\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex f12da29..2edbad2 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -53,7 +53,7 @@ static const char *explanation(struct merge_list *entry)\n \treturn \"removed in remote\";\n }\n \n-static void *result(struct merge_list *entry, unsigned long *size)\n+static void *result(struct merge_list *entry, size_t *size)\n {\n \tenum object_type type;\n \tstruct blob *base, *our, *their;\n@@ -77,7 +77,7 @@ static void *result(struct merge_list *entry, unsigned long *size)\n \treturn merge_blobs(path, base, our, their, size);\n }\n \n-static void *origin(struct merge_list *entry, unsigned long *size)\n+static void *origin(struct merge_list *entry, size_t *size)\n {\n \tenum object_type type;\n \twhile (entry) {\n@@ -98,7 +98,7 @@ static int show_outf(void *priv_, mmbuffer_t *mb, int nbuf)\n \n static void show_diff(struct merge_list *entry)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tmmfile_t src, dst;\n \txpparam_t xpp;\n \txdemitconf_t xecfg;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 031b750..0663106 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -22,7 +22,7 @@ static int verify_object(const unsigned char *sha1, const char *expected_type)\n {\n \tint ret = -1;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *buffer = read_sha1_file(sha1, &type, &size);\n \tconst unsigned char *repl = lookup_replace_object(sha1);\n \ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 4303848..7932a8e 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -120,7 +120,7 @@ static int list_each_note(const struct object_id *object_oid,\n \n static void copy_obj_to_fd(int fd, const unsigned char *sha1)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = read_sha1_file(sha1, &type, &size);\n \tif (buf) {\n@@ -246,7 +246,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)\n \tchar *buf;\n \tstruct object_id object;\n \tenum object_type type;\n-\tunsigned long len;\n+\tsize_t len;\n \n \tif (d->buf.len)\n \t\tstrbuf_addch(&d->buf, '\\n');\n@@ -605,7 +605,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)\n \n \tif (note && !edit) {\n \t\t/* Append buf to previous note contents */\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tenum object_type type;\n \t\tchar *prev_buf = read_sha1_file(note->hash, &type, &size);\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex c753e92..d94fd17 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -103,7 +103,7 @@ static void index_commit_for_bitmap(struct commit *commit)\n \n static void *get_delta(struct object_entry *entry)\n {\n-\tunsigned long size, base_size, delta_size;\n+\tsize_t size, base_size, delta_size;\n \tvoid *buf, *base_buf, *delta_buf;\n \tenum object_type type;\n \n@@ -241,7 +241,7 @@ static void copy_pack_data(struct sha1file *f,\n static unsigned long write_no_reuse_object(struct sha1file *f, struct object_entry *entry,\n \t\t\t\t\t   unsigned long limit, int usable_delta)\n {\n-\tunsigned long size, datalen;\n+\tsize_t size, datalen;\n \tunsigned char header[MAX_PACK_OBJECT_HEADER],\n \t\t      dheader[MAX_PACK_OBJECT_HEADER];\n \tunsigned hdrlen;\n@@ -1147,7 +1147,7 @@ static struct pbase_tree_cache *pbase_tree_get(const unsigned char *sha1)\n {\n \tstruct pbase_tree_cache *ent, *nent;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tint neigh;\n \tint my_ix = pbase_tree_cache_ix(sha1);\n@@ -1330,7 +1330,7 @@ static void add_preferred_base(unsigned char *sha1)\n {\n \tstruct pbase_tree *it;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tunsigned char tree_sha1[20];\n \n \tif (window <= num_preferred_base++)\n@@ -1805,7 +1805,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n {\n \tstruct object_entry *trg_entry = trg->entry;\n \tstruct object_entry *src_entry = src->entry;\n-\tunsigned long trg_size, src_size, delta_size, sizediff, max_size, sz;\n+\tsize_t trg_size, src_size, delta_size, sizediff, max_size, sz;\n \tunsigned ref_depth;\n \tenum object_type type;\n \tvoid *delta_buf;\n@@ -1863,9 +1863,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t\t\tdie(\"object %s cannot be read\",\n \t\t\t    oid_to_hex(&trg_entry->idx.oid));\n \t\tif (sz != trg_size)\n-\t\t\tdie(\"object %s inconsistent object length (%lu vs %lu)\",\n-\t\t\t    oid_to_hex(&trg_entry->idx.oid), sz,\n-\t\t\t    trg_size);\n+\t\t\tdie(\"object %s inconsistent object length (%\" PRIuMAX\n+\t\t\t    \" vs %\" PRIuMAX \")\",\n+\t\t\t    oid_to_hex(&trg_entry->idx.oid), (uintmax_t)sz,\n+\t\t\t    (uintmax_t)trg_size);\n \t\t*mem_usage += sz;\n \t}\n \tif (!src->data) {\n@@ -1891,9 +1892,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,\n \t\t\t    oid_to_hex(&src_entry->idx.oid));\n \t\t}\n \t\tif (sz != src_size)\n-\t\t\tdie(\"object %s inconsistent object length (%lu vs %lu)\",\n-\t\t\t    oid_to_hex(&src_entry->idx.oid), sz,\n-\t\t\t    src_size);\n+\t\t\tdie(\"object %s inconsistent object length (%\" PRIuMAX\n+\t\t\t    \" vs %\" PRIuMAX \")\",\n+\t\t\t    oid_to_hex(&src_entry->idx.oid), (uintmax_t)sz,\n+\t\t\t    (uintmax_t)src_size);\n \t\t*mem_usage += sz;\n \t}\n \tif (!src->index) {\ndiff --git a/builtin/reflog.c b/builtin/reflog.c\nindex e237d92..7f0382d 100644\n--- a/builtin/reflog.c\n+++ b/builtin/reflog.c\n@@ -73,7 +73,7 @@ static int tree_is_complete(const struct object_id *oid)\n \n \tif (!tree->buffer) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tvoid *data = read_sha1_file(oid->hash, &type, &size);\n \t\tif (!data) {\n \t\t\ttree->object.flags |= INCOMPLETE;\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex c627794..864461b 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -163,7 +163,7 @@ static int git_tag_config(const char *var, const char *value, void *cb)\n \n static void write_tag_body(int fd, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf, *sp;\n \n@@ -280,7 +280,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)\n \tenum object_type type;\n \tstruct commit *c;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint subject_len = 0;\n \tconst char *subject_start;\n \ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex 281ca1d..16c1431 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -6,7 +6,7 @@ static char *create_temp_file(struct object_id *oid)\n \tstatic char path[50];\n \tvoid *buf;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tint fd;\n \n \tbuf = read_sha1_file(oid->hash, &type, &size);\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 689a29f..001dd4b 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -196,7 +196,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op\n \t\tdie(\"object type mismatch\");\n \n \tif (!(obj->flags & FLAG_OPEN)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tint type = sha1_object_info(obj->oid.hash, &size);\n \t\tif (type != obj->type || type <= 0)\n \t\t\tdie(\"object of unexpected type\");\n@@ -271,11 +271,11 @@ static void write_object(unsigned nr, enum object_type type,\n }\n \n static void resolve_delta(unsigned nr, enum object_type type,\n-\t\t\t  void *base, unsigned long base_size,\n-\t\t\t  void *delta, unsigned long delta_size)\n+\t\t\t  void *base, size_t base_size,\n+\t\t\t  void *delta, size_t delta_size)\n {\n \tvoid *result;\n-\tunsigned long result_size;\n+\tsize_t result_size;\n \n \tresult = patch_delta(base, base_size,\n \t\t\t     delta, delta_size,\n@@ -322,7 +322,7 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size,\n }\n \n static int resolve_against_held(unsigned nr, const struct object_id *base,\n-\t\t\t\tvoid *delta_data, unsigned long delta_size)\n+\t\t\t\tvoid *delta_data, size_t delta_size)\n {\n \tstruct object *obj;\n \tstruct obj_buffer *obj_buffer;\n@@ -337,11 +337,11 @@ static int resolve_against_held(unsigned nr, const struct object_id *base,\n \treturn 1;\n }\n \n-static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n+static void unpack_delta_entry(enum object_type type, size_t delta_size,\n \t\t\t       unsigned nr)\n {\n \tvoid *delta_data, *base;\n-\tunsigned long base_size;\n+\tsize_t base_size;\n \tstruct object_id base_oid;\n \n \tif (type == OBJ_REF_DELTA) {\ndiff --git a/builtin/verify-commit.c b/builtin/verify-commit.c\nindex ba38ac9..ea0857a 100644\n--- a/builtin/verify-commit.c\n+++ b/builtin/verify-commit.c\n@@ -38,7 +38,7 @@ static int verify_commit(const char *name, unsigned flags)\n \tenum object_type type;\n \tstruct object_id oid;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (get_oid(name, &oid))\ndiff --git a/bundle.c b/bundle.c\nindex d15db03..c49cb13 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -209,7 +209,7 @@ int list_bundle_refs(struct bundle_header *header, int argc, const char **argv)\n \n static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tchar *buf = NULL, *line, *lineend;\n \ttimestamp_t date;\ndiff --git a/cache.h b/cache.h\nindex 3c44a25..ee96192 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1170,8 +1170,8 @@ extern char *xdg_cache_home(const char *filename);\n \n extern void *read_sha1_file_extended(const unsigned char *sha1,\n \t\t\t\t     enum object_type *type,\n-\t\t\t\t     unsigned long *size, int lookup_replace);\n-static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *type, unsigned long *size)\n+\t\t\t\t     size_t *size, int lookup_replace);\n+static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *type, size_t *size)\n {\n \treturn read_sha1_file_extended(sha1, type, size, 1);\n }\n@@ -1196,7 +1196,7 @@ static inline const unsigned char *lookup_replace_object(const unsigned char *sh\n }\n \n /* Read and unpack a sha1 file into memory, write memory to a sha1 file */\n-extern int sha1_object_info(const unsigned char *, unsigned long *);\n+extern int sha1_object_info(const unsigned char *, size_t *);\n extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);\n extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);\n extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, unsigned char *sha1, unsigned flags);\n@@ -1206,12 +1206,12 @@ extern int git_open_cloexec(const char *name, int flags);\n #define git_open(name) git_open_cloexec(name, O_RDONLY)\n extern void *map_sha1_file(const unsigned char *sha1, unsigned long *size);\n extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);\n-extern int parse_sha1_header(const char *hdr, unsigned long *sizep);\n+extern int parse_sha1_header(const char *hdr, size_t *sizep);\n \n /* global flag to enable extra checks when accessing packed objects */\n extern int do_check_packed_object_crc;\n \n-extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);\n+extern int check_sha1_signature(const unsigned char *sha1, void *buf, size_t size, const char *type);\n \n extern int finalize_object_file(const char *tmpfile, const char *filename);\n \n@@ -1227,7 +1227,7 @@ extern int has_sha1_pack(const unsigned char *sha1);\n int read_loose_object(const char *path,\n \t\t      const unsigned char *expected_sha1,\n \t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n+\t\t      size_t *size,\n \t\t      void **contents);\n \n /*\n@@ -1405,7 +1405,7 @@ extern int cache_name_stage_compare(const char *name1, int len1, int stage1, con\n \n extern void *read_object_with_reference(const unsigned char *sha1,\n \t\t\t\t\tconst char *required_type,\n-\t\t\t\t\tunsigned long *size,\n+\t\t\t\t\tsize_t *size,\n \t\t\t\t\tunsigned char *sha1_ret);\n \n extern struct object *peel_to_type(const char *name, int namelen,\n@@ -1730,10 +1730,10 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);\n extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);\n \n extern int is_pack_valid(struct packed_git *);\n-extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);\n-extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);\n+extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, size_t *);\n+extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, size_t *sizep);\n extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n-extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);\n+extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, size_t *);\n \n /*\n  * Iterate over the files in the loose-object parts of the object\n@@ -1799,7 +1799,7 @@ extern int for_each_packed_object(each_packed_object_fn, void *, unsigned flags)\n struct object_info {\n \t/* Request */\n \tenum object_type *typep;\n-\tunsigned long *sizep;\n+\tsize_t *sizep;\n \toff_t *disk_sizep;\n \tunsigned char *delta_base_sha1;\n \tstruct strbuf *typename;\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 9e163d5..acf39ec 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -285,7 +285,7 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,\n }\n \n static char *grab_blob(const struct object_id *oid, unsigned int mode,\n-\t\t       unsigned long *size, struct userdiff_driver *textconv,\n+\t\t       size_t *size, struct userdiff_driver *textconv,\n \t\t       const char *path)\n {\n \tchar *blob;\n@@ -401,7 +401,7 @@ static void combine_diff(const struct object_id *parent, unsigned int mode,\n \txdemitconf_t xecfg;\n \tmmfile_t parent_file;\n \tstruct combine_diff_state state;\n-\tunsigned long sz;\n+\tsize_t sz;\n \n \tif (result_deleted)\n \t\treturn; /* result deleted */\n@@ -971,7 +971,8 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\t    struct rev_info *rev)\n {\n \tstruct diff_options *opt = &rev->diffopt;\n-\tunsigned long result_size, cnt, lno;\n+\tsize_t result_size;\n+\tunsigned long cnt, lno;\n \tint result_deleted = 0;\n \tchar *result, *cp;\n \tstruct sline *sline; /* survived lines */\n@@ -1087,7 +1088,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\tis_binary = buffer_is_binary(result, result_size);\n \t\tfor (i = 0; !is_binary && i < num_parent; i++) {\n \t\t\tchar *buf;\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\tbuf = grab_blob(&elem->parent[i].oid,\n \t\t\t\t\telem->parent[i].mode,\n \t\t\t\t\t&size, NULL, NULL);\ndiff --git a/commit.c b/commit.c\nindex 8b28415..22e66b8 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -261,7 +261,7 @@ const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)\n \tconst void *ret = get_cached_commit_buffer(commit, sizep);\n \tif (!ret) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tret = read_sha1_file(commit->object.oid.hash, &type, &size);\n \t\tif (!ret)\n \t\t\tdie(\"cannot read commit object %s\",\n@@ -372,7 +372,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)\n {\n \tenum object_type type;\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (!item)\n@@ -1203,7 +1203,7 @@ static void handle_signed_tag(struct commit *parent, struct commit_extra_header\n \tstruct merge_remote_desc *desc;\n \tstruct commit_extra_header *mergetag;\n \tchar *buf;\n-\tunsigned long size, len;\n+\tsize_t size, len;\n \tenum object_type type;\n \n \tdesc = merge_remote_util(parent);\ndiff --git a/config.c b/config.c\nindex c145073..bf4e2e4 100644\n--- a/config.c\n+++ b/config.c\n@@ -1471,7 +1471,7 @@ int git_config_from_blob_oid(config_fn_t fn,\n {\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tbuf = read_sha1_file(oid->hash, &type, &size);\ndiff --git a/delta.h b/delta.h\nindex 9b67531..2df0f55 100644\n--- a/delta.h\n+++ b/delta.h\n@@ -14,7 +14,7 @@ struct delta_index;\n  * using free_delta_index().\n  */\n extern struct delta_index *\n-create_delta_index(const void *buf, unsigned long bufsize);\n+create_delta_index(const void *buf, size_t bufsize);\n \n /*\n  * free_delta_index: free the index created by create_delta_index()\n@@ -28,7 +28,7 @@ extern void free_delta_index(struct delta_index *index);\n  *\n  * Given pointer must be what create_delta_index() returned, or NULL.\n  */\n-extern unsigned long sizeof_delta_index(struct delta_index *index);\n+extern size_t sizeof_delta_index(struct delta_index *index);\n \n /*\n  * create_delta: create a delta from given index for the given buffer\n@@ -42,8 +42,8 @@ extern unsigned long sizeof_delta_index(struct delta_index *index);\n  */\n extern void *\n create_delta(const struct delta_index *index,\n-\t     const void *buf, unsigned long bufsize,\n-\t     unsigned long *delta_size, unsigned long max_delta_size);\n+\t     const void *buf, size_t bufsize,\n+\t     size_t *delta_size, size_t max_delta_size);\n \n /*\n  * diff_delta: create a delta from source buffer to target buffer\n@@ -54,9 +54,9 @@ create_delta(const struct delta_index *index,\n  * updated with its size.  The returned buffer must be freed by the caller.\n  */\n static inline void *\n-diff_delta(const void *src_buf, unsigned long src_bufsize,\n-\t   const void *trg_buf, unsigned long trg_bufsize,\n-\t   unsigned long *delta_size, unsigned long max_delta_size)\n+diff_delta(const void *src_buf, size_t src_bufsize,\n+\t   const void *trg_buf, size_t trg_bufsize,\n+\t   size_t *delta_size, size_t max_delta_size)\n {\n \tstruct delta_index *index = create_delta_index(src_buf, src_bufsize);\n \tif (index) {\n@@ -75,9 +75,9 @@ diff_delta(const void *src_buf, unsigned long src_bufsize,\n  * *trg_bufsize is updated with its size.  On failure a NULL pointer is\n  * returned.  The returned buffer must be freed by the caller.\n  */\n-extern void *patch_delta(const void *src_buf, unsigned long src_size,\n-\t\t\t const void *delta_buf, unsigned long delta_size,\n-\t\t\t unsigned long *dst_size);\n+extern void *patch_delta(const void *src_buf, size_t src_size,\n+\t\t\t const void *delta_buf, size_t delta_size,\n+\t\t\t size_t *dst_size);\n \n /* the smallest possible delta size is 4 bytes */\n #define DELTA_SIZE_MIN\t4\n@@ -86,11 +86,11 @@ extern void *patch_delta(const void *src_buf, unsigned long src_size,\n  * This must be called twice on the delta data buffer, first to get the\n  * expected source buffer size, and again to get the target buffer size.\n  */\n-static inline unsigned long get_delta_hdr_size(const unsigned char **datap,\n-\t\t\t\t\t       const unsigned char *top)\n+static inline size_t get_delta_hdr_size(const unsigned char **datap,\n+\t\t\t\t\tconst unsigned char *top)\n {\n \tconst unsigned char *data = *datap;\n-\tunsigned long cmd, size = 0;\n+\tsize_t cmd, size = 0;\n \tint i = 0;\n \tdo {\n \t\tcmd = *data++;\ndiff --git a/diff-delta.c b/diff-delta.c\nindex db27c1a..dffbab1 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -123,14 +123,14 @@ struct unpacked_index_entry {\n };\n \n struct delta_index {\n-\tunsigned long memsize;\n+\tsize_t memsize;\n \tconst void *src_buf;\n-\tunsigned long src_size;\n+\tsize_t src_size;\n \tunsigned int hash_mask;\n \tstruct index_entry *hash[FLEX_ARRAY];\n };\n \n-struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n+struct delta_index * create_delta_index(const void *buf, size_t bufsize)\n {\n \tunsigned int i, hsize, hmask, entries, prev_val, *hash_count;\n \tconst unsigned char *data, *buffer = buf;\n@@ -138,7 +138,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n \tstruct unpacked_index_entry *entry, **hash;\n \tstruct index_entry *packed_entry, **packed_hash;\n \tvoid *mem;\n-\tunsigned long memsize;\n+\tsize_t memsize;\n \n \tif (!buf || !bufsize)\n \t\treturn NULL;\n@@ -300,7 +300,7 @@ void free_delta_index(struct delta_index *index)\n \tfree(index);\n }\n \n-unsigned long sizeof_delta_index(struct delta_index *index)\n+size_t sizeof_delta_index(struct delta_index *index)\n {\n \tif (index)\n \t\treturn index->memsize;\n@@ -316,8 +316,8 @@ unsigned long sizeof_delta_index(struct delta_index *index)\n \n void *\n create_delta(const struct delta_index *index,\n-\t     const void *trg_buf, unsigned long trg_size,\n-\t     unsigned long *delta_size, unsigned long max_size)\n+\t     const void *trg_buf, size_t trg_size,\n+\t     size_t *delta_size, size_t max_size)\n {\n \tunsigned int i, val;\n \tsize_t l, outpos, moff, outsize, msize;\n@@ -406,7 +406,7 @@ create_delta(const struct delta_index *index,\n \t\t\t}\n \t\t\tmsize = 0;\n \t\t} else {\n-\t\t\tunsigned int left;\n+\t\t\tsize_t left;\n \t\t\tunsigned char *op;\n \n \t\t\tif (inscnt) {\ndiff --git a/diff.c b/diff.c\nindex 9c38258..c12d062 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2200,8 +2200,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)\n }\n \n static unsigned char *deflate_it(char *data,\n-\t\t\t\t unsigned long size,\n-\t\t\t\t unsigned long *result_size)\n+\t\t\t\t size_t size,\n+\t\t\t\t size_t *result_size)\n {\n \tint bound;\n \tunsigned char *deflated;\n@@ -2229,10 +2229,10 @@ static void emit_binary_diff_body(FILE *file, mmfile_t *one, mmfile_t *two,\n \tvoid *delta;\n \tvoid *deflated;\n \tvoid *data;\n-\tunsigned long orig_size;\n-\tunsigned long delta_size;\n-\tunsigned long deflate_size;\n-\tunsigned long data_size;\n+\tsize_t orig_size;\n+\tsize_t delta_size;\n+\tsize_t deflate_size;\n+\tsize_t data_size;\n \n \t/* We could do deflated delta, or we could do just deflated two,\n \t * whichever is smaller.\n@@ -2252,13 +2252,13 @@ static void emit_binary_diff_body(FILE *file, mmfile_t *one, mmfile_t *two,\n \t}\n \n \tif (delta && delta_size < deflate_size) {\n-\t\tfprintf(file, \"%sdelta %lu\\n\", prefix, orig_size);\n+\t\tfprintf(file, \"%sdelta %\" PRIuMAX \"\\n\", prefix, (uintmax_t)orig_size);\n \t\tfree(deflated);\n \t\tdata = delta;\n \t\tdata_size = delta_size;\n \t}\n \telse {\n-\t\tfprintf(file, \"%sliteral %lu\\n\", prefix, two->size);\n+\t\tfprintf(file, \"%sliteral %\" PRIuMAX \"\\n\", prefix, (uintmax_t)two->size);\n \t\tfree(delta);\n \t\tdata = deflated;\n \t\tdata_size = deflate_size;\n@@ -5267,7 +5267,7 @@ int textconv_object(const char *path,\n \t\t    const struct object_id *oid,\n \t\t    int oid_valid,\n \t\t    char **buf,\n-\t\t    unsigned long *buf_size)\n+\t\t    size_t *buf_size)\n {\n \tstruct diff_filespec *df;\n \tstruct userdiff_driver *textconv;\ndiff --git a/diff.h b/diff.h\nindex 2d442e2..0901822 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -390,7 +390,7 @@ extern struct userdiff_driver *get_textconv(struct diff_filespec *one);\n  * if the textconv driver exists.\n  * Return 1 if the conversion succeeds, 0 otherwise.\n  */\n-extern int textconv_object(const char *path, unsigned mode, const struct object_id *oid, int oid_valid, char **buf, unsigned long *buf_size);\n+extern int textconv_object(const char *path, unsigned mode, const struct object_id *oid, int oid_valid, char **buf, size_t *buf_size);\n \n extern int parse_rename_score(const char **cp_p);\n \ndiff --git a/diffcore.h b/diffcore.h\nindex a30da16..8ad1823 100644\n--- a/diffcore.h\n+++ b/diffcore.h\n@@ -29,7 +29,7 @@ struct diff_filespec {\n \tchar *path;\n \tvoid *data;\n \tvoid *cnt_data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint count;               /* Reference count */\n \tint rename_used;         /* Count of rename users */\n \tunsigned short mode;\t /* file mode */\ndiff --git a/dir.c b/dir.c\nindex 1c55dc3..f161c26 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -605,7 +605,7 @@ static void *read_skip_worktree_file_from_index(const struct index_state *istate\n \t\t\t\t\t\tstruct sha1_stat *sha1_stat)\n {\n \tint pos, len;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tenum object_type type;\n \tvoid *data;\n \ndiff --git a/entry.c b/entry.c\nindex 65458f0..6db2d2e 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -80,7 +80,7 @@ static int create_file(const char *path, unsigned int mode)\n \treturn open(path, O_WRONLY | O_CREAT | O_EXCL, mode);\n }\n \n-static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)\n+static void *read_blob_entry(const struct cache_entry *ce, size_t *size)\n {\n \tenum object_type type;\n \tvoid *new = read_sha1_file(ce->oid.hash, &type, size);\n@@ -243,7 +243,7 @@ static int write_entry(struct cache_entry *ce,\n \tint fd, ret, fstat_done = 0;\n \tchar *new;\n \tstruct strbuf buf = STRBUF_INIT;\n-\tunsigned long size;\n+\tsize_t size;\n \tsize_t wrote, newsize = 0;\n \tstruct stat st;\n \tconst struct submodule *sub;\ndiff --git a/fast-import.c b/fast-import.c\nindex a959161..334cabf 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1090,7 +1090,7 @@ static int store_object(\n \tstruct object_entry *e;\n \tunsigned char hdr[96];\n \tstruct object_id oid;\n-\tunsigned long hdrlen, deltalen;\n+\tsize_t hdrlen, deltalen;\n \tgit_SHA_CTX c;\n \tgit_zstream s;\n \n@@ -1345,7 +1345,7 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)\n  */\n static void *gfi_unpack_entry(\n \tstruct object_entry *oe,\n-\tunsigned long *sizep)\n+\tsize_t *sizep)\n {\n \tenum object_type type;\n \tstruct packed_git *p = all_packs[oe->pack_id];\n@@ -1391,7 +1391,7 @@ static void load_tree(struct tree_entry *root)\n \tstruct object_id *oid = &root->versions[1].oid;\n \tstruct object_entry *myoe;\n \tstruct tree_content *t;\n-\tunsigned long size;\n+\tsize_t size;\n \tchar *buf;\n \tconst char *c;\n \n@@ -2579,7 +2579,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa\n \t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", commit_mark);\n \t\toidcpy(&commit_oid, &commit_oe->idx.oid);\n \t} else if (!get_oid(p, &commit_oid)) {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf = read_object_with_reference(commit_oid.hash,\n \t\t\tcommit_type, &size, commit_oid.hash);\n \t\tif (!buf || size < 46)\n@@ -2647,7 +2647,7 @@ static void parse_from_existing(struct branch *b)\n \t\toidclr(&b->branch_tree.versions[0].oid);\n \t\toidclr(&b->branch_tree.versions[1].oid);\n \t} else {\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\tchar *buf;\n \n \t\tbuf = read_object_with_reference(b->oid.hash,\n@@ -2685,7 +2685,7 @@ static int parse_from(struct branch *b)\n \t\tif (oidcmp(&b->oid, &oe->idx.oid)) {\n \t\t\toidcpy(&b->oid, &oe->idx.oid);\n \t\t\tif (oe->pack_id != MAX_PACK_ID) {\n-\t\t\t\tunsigned long size;\n+\t\t\t\tsize_t size;\n \t\t\t\tchar *buf = gfi_unpack_entry(oe, &size);\n \t\t\t\tparse_from_commit(b, buf, size);\n \t\t\t\tfree(buf);\n@@ -2728,7 +2728,7 @@ static struct hash_list *parse_merge(unsigned int *count)\n \t\t\t\tdie(\"Mark :%\" PRIuMAX \" not a commit\", idnum);\n \t\t\toidcpy(&n->oid, &oe->idx.oid);\n \t\t} else if (!get_oid(from, &n->oid)) {\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\tchar *buf = read_object_with_reference(n->oid.hash,\n \t\t\t\tcommit_type, &size, n->oid.hash);\n \t\t\tif (!buf || size < 46)\n@@ -2958,7 +2958,7 @@ static void cat_blob_write(const char *buf, unsigned long size)\n static void cat_blob(struct object_entry *oe, struct object_id *oid)\n {\n \tstruct strbuf line = STRBUF_INIT;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type = 0;\n \tchar *buf;\n \n@@ -2986,8 +2986,8 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)\n \t\tdie(\"Object %s is a %s but a blob was expected.\",\n \t\t    oid_to_hex(oid), typename(type));\n \tstrbuf_reset(&line);\n-\tstrbuf_addf(&line, \"%s %s %lu\\n\", oid_to_hex(oid),\n-\t\t\t\t\t\ttypename(type), size);\n+\tstrbuf_addf(&line, \"%s %s %\" PRIuMAX \"\\n\", oid_to_hex(oid),\n+\t\t    typename(type), (uintmax_t)size);\n \tcat_blob_write(line.buf, line.len);\n \tstrbuf_release(&line);\n \tcat_blob_write(buf, size);\n@@ -3042,7 +3042,7 @@ static void parse_cat_blob(const char *p)\n static struct object_entry *dereference(struct object_entry *oe,\n \t\t\t\t\tstruct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tchar *buf = NULL;\n \tif (!oe) {\n \t\tenum object_type type = sha1_object_info(oid->hash, NULL);\n@@ -3538,7 +3538,7 @@ int cmd_main(int argc, const char **argv)\n \t\tfprintf(stderr, \"Total branches:  %10lu (%10lu loads     )\\n\", branch_count, branch_load_count);\n \t\tfprintf(stderr, \"      marks:     %10\" PRIuMAX \" (%10\" PRIuMAX \" unique    )\\n\", (((uintmax_t)1) << marks->shift) * 1024, marks_set_count);\n \t\tfprintf(stderr, \"      atoms:     %10u\\n\", atom_cnt);\n-\t\tfprintf(stderr, \"Memory total:    %10\" PRIuMAX \" KiB\\n\", (total_allocd + alloc_count*sizeof(struct object_entry))/1024);\n+\t\tfprintf(stderr, \"Memory total:    %10\" PRIuMAX \" KiB\\n\", (uintmax_t)(total_allocd + alloc_count*sizeof(struct object_entry))/1024);\n \t\tfprintf(stderr, \"       pools:    %10lu KiB\\n\", (unsigned long)(total_allocd/1024));\n \t\tfprintf(stderr, \"     objects:    %10\" PRIuMAX \" KiB\\n\", (alloc_count*sizeof(struct object_entry))/1024);\n \t\tfprintf(stderr, \"---------------------------------------------------------------------\\n\");\ndiff --git a/fsck.c b/fsck.c\nindex 2d2d2e9..feca3a8 100644\n--- a/fsck.c\n+++ b/fsck.c\n@@ -796,7 +796,7 @@ static int fsck_commit(struct commit *commit, const char *data,\n }\n \n static int fsck_tag_buffer(struct tag *tag, const char *data,\n-\tunsigned long size, struct fsck_options *options)\n+\tsize_t size, struct fsck_options *options)\n {\n \tunsigned char sha1[20];\n \tint ret = 0;\ndiff --git a/grep.h b/grep.h\nindex 52aecfa..f810a93 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -197,7 +197,7 @@ struct grep_source {\n \tvoid *identifier;\n \n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tchar *path; /* for attribute lookups */\n \tstruct userdiff_driver *driver;\ndiff --git a/http-push.c b/http-push.c\nindex c91f40a..4c06802 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -355,13 +355,14 @@ static void start_put(struct transfer_request *request)\n \tenum object_type type;\n \tchar hdr[50];\n \tvoid *unpacked;\n-\tunsigned long len;\n+\tsize_t len;\n \tint hdrlen;\n \tssize_t size;\n \tgit_zstream stream;\n \n \tunpacked = read_sha1_file(request->obj->oid.hash, &type, &len);\n-\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", typename(type), len) + 1;\n+\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %\" PRIuMAX,\n+\t\t\t   typename(type), (uintmax_t)len) + 1;\n \n \t/* Set it up */\n \tgit_deflate_init(&stream, zlib_compression_level);\ndiff --git a/mailmap.c b/mailmap.c\nindex cb921b4..323bbef 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -216,7 +216,7 @@ static int read_mailmap_blob(struct string_list *map,\n {\n \tstruct object_id oid;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tif (!name)\ndiff --git a/match-trees.c b/match-trees.c\nindex 396b733..d4b7c1e 100644\n--- a/match-trees.c\n+++ b/match-trees.c\n@@ -52,7 +52,7 @@ static void *fill_tree_desc_strict(struct tree_desc *desc,\n {\n \tvoid *buffer;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tbuffer = read_sha1_file(hash->hash, &type, &size);\n \tif (!buffer)\n@@ -169,7 +169,7 @@ static int splice_tree(const unsigned char *hash1,\n \tchar *subpath;\n \tint toplen;\n \tchar *buf;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tstruct tree_desc desc;\n \tunsigned char *rewrite_here;\n \tconst unsigned char *rewrite_with;\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex 9b6eac2..f7e55c4 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -8,7 +8,7 @@\n static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n {\n \tvoid *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tbuf = read_sha1_file(obj->object.oid.hash, &type, &size);\n@@ -28,7 +28,7 @@ static void free_mmfile(mmfile_t *f)\n \tfree(f->ptr);\n }\n \n-static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our, mmfile_t *their, unsigned long *size)\n+static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our, mmfile_t *their, size_t *size)\n {\n \tint merge_status;\n \tmmbuffer_t res;\n@@ -48,7 +48,7 @@ static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our\n \treturn res.ptr;\n }\n \n-void *merge_blobs(const char *path, struct blob *base, struct blob *our, struct blob *their, unsigned long *size)\n+void *merge_blobs(const char *path, struct blob *base, struct blob *our, struct blob *their, size_t *size)\n {\n \tvoid *res = NULL;\n \tmmfile_t f1, f2, common;\ndiff --git a/merge-blobs.h b/merge-blobs.h\nindex 62b569e..e66eee7 100644\n--- a/merge-blobs.h\n+++ b/merge-blobs.h\n@@ -3,6 +3,6 @@\n \n #include \"blob.h\"\n \n-extern void *merge_blobs(const char *, struct blob *, struct blob *, struct blob *, unsigned long *);\n+extern void *merge_blobs(const char *, struct blob *, struct blob *, struct blob *, size_t *);\n \n #endif /* MERGE_BLOBS_H */\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 1494ffd..e6b547c 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -787,7 +787,7 @@ static int update_file_flags(struct merge_options *o,\n \tif (update_wd) {\n \t\tenum object_type type;\n \t\tvoid *buf;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \n \t\tif (S_ISGITLINK(mode)) {\n \t\t\t/*\n@@ -1602,7 +1602,7 @@ static int read_oid_strbuf(struct merge_options *o,\n {\n \tvoid *buf;\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tbuf = read_sha1_file(oid->hash, &type, &size);\n \tif (!buf)\n \t\treturn err(o, _(\"cannot read object %s\"), oid_to_hex(oid));\ndiff --git a/notes-cache.c b/notes-cache.c\nindex 29b4ced..df86765 100644\n--- a/notes-cache.c\n+++ b/notes-cache.c\n@@ -72,7 +72,7 @@ char *notes_cache_get(struct notes_cache *c, struct object_id *key_oid,\n \tconst struct object_id *value_oid;\n \tenum object_type type;\n \tchar *value;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tvalue_oid = get_note(&c->tree, key_oid);\n \tif (!value_oid)\ndiff --git a/notes-merge.c b/notes-merge.c\nindex c12b354..b1bf7ff 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -323,7 +323,7 @@ static void write_note_to_worktree(const struct object_id *obj,\n \t\t\t\t   const struct object_id *note)\n {\n \tenum object_type type;\n-\tunsigned long size;\n+\tsize_t size;\n \tvoid *buf = read_sha1_file(note->hash, &type, &size);\n \n \tif (!buf)\ndiff --git a/notes.c b/notes.c\nindex 503754d..5b9bb96 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -808,7 +808,7 @@ int combine_notes_concatenate(unsigned char *cur_sha1,\n \t\tconst unsigned char *new_sha1)\n {\n \tchar *cur_msg = NULL, *new_msg = NULL, *buf;\n-\tunsigned long cur_len, new_len, buf_len;\n+\tsize_t cur_len, new_len, buf_len;\n \tenum object_type cur_type, new_type;\n \tint ret;\n \n@@ -869,7 +869,7 @@ static int string_list_add_note_lines(struct string_list *list,\n \t\t\t\t      const unsigned char *sha1)\n {\n \tchar *data;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type t;\n \n \tif (is_null_sha1(sha1))\n@@ -1222,7 +1222,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid\n \tstatic const char utf8[] = \"utf-8\";\n \tconst struct object_id *oid;\n \tchar *msg, *msg_p;\n-\tunsigned long linelen, msglen;\n+\tsize_t linelen, msglen;\n \tenum object_type type;\n \n \tif (!t)\ndiff --git a/object.c b/object.c\nindex 321d7e9..dff9f52 100644\n--- a/object.c\n+++ b/object.c\n@@ -241,7 +241,7 @@ struct object *parse_object_or_die(const struct object_id *oid,\n \n struct object *parse_object(const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tint eaten;\n \tconst unsigned char *repl = lookup_replace_object(oid->hash);\ndiff --git a/pack-check.c b/pack-check.c\nindex e1fcb22..6f7714f 100644\n--- a/pack-check.c\n+++ b/pack-check.c\n@@ -104,7 +104,7 @@ static int verify_packfile(struct packed_git *p,\n \tfor (i = 0; i < nr_objects; i++) {\n \t\tvoid *data;\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\toff_t curpos;\n \t\tint data_valid;\n \ndiff --git a/pack-objects.h b/pack-objects.h\nindex 03f1191..3a2cf4e 100644\n--- a/pack-objects.h\n+++ b/pack-objects.h\n@@ -3,7 +3,7 @@\n \n struct object_entry {\n \tstruct pack_idx_entry idx;\n-\tunsigned long size;\t/* uncompressed size */\n+\tsize_t size;\t/* uncompressed size */\n \tstruct packed_git *in_pack;\t/* already in pack */\n \toff_t in_pack_offset;\n \tstruct object_entry *delta;\t/* delta base object */\n@@ -12,8 +12,8 @@ struct object_entry {\n \t\t\t\t\t     * uses the same base as me\n \t\t\t\t\t     */\n \tvoid *delta_data;\t/* cached delta (uncompressed) */\n-\tunsigned long delta_size;\t/* delta data size (uncompressed) */\n-\tunsigned long z_delta_size;\t/* delta data size (compressed) */\n+\tsize_t delta_size;\t/* delta data size (uncompressed) */\n+\tsize_t z_delta_size;\t/* delta data size (compressed) */\n \tenum object_type type;\n \tenum object_type in_pack_type;\t/* could be delta */\n \tuint32_t hash;\t\t\t/* name hint hash */\ndiff --git a/patch-delta.c b/patch-delta.c\nindex 56e0a5e..8b2fa20 100644\n--- a/patch-delta.c\n+++ b/patch-delta.c\n@@ -12,13 +12,13 @@\n #include \"git-compat-util.h\"\n #include \"delta.h\"\n \n-void *patch_delta(const void *src_buf, unsigned long src_size,\n-\t\t  const void *delta_buf, unsigned long delta_size,\n-\t\t  unsigned long *dst_size)\n+void *patch_delta(const void *src_buf, size_t src_size,\n+\t\t  const void *delta_buf, size_t delta_size,\n+\t\t  size_t *dst_size)\n {\n \tconst unsigned char *data, *top;\n \tunsigned char *dst_buf, *out, cmd;\n-\tunsigned long size;\n+\tsize_t size;\n \n \tif (delta_size < DELTA_SIZE_MIN)\n \t\treturn NULL;\n@@ -39,7 +39,8 @@ void *patch_delta(const void *src_buf, unsigned long src_size,\n \twhile (data < top) {\n \t\tcmd = *data++;\n \t\tif (cmd & 0x80) {\n-\t\t\tunsigned long cp_off = 0, cp_size = 0;\n+\t\t\toff_t cp_off = 0;\n+\t\t\tsize_t cp_size = 0;\n \t\t\tif (cmd & 0x01) cp_off = *data++;\n \t\t\tif (cmd & 0x02) cp_off |= (*data++ << 8);\n \t\t\tif (cmd & 0x04) cp_off |= (*data++ << 16);\ndiff --git a/read-cache.c b/read-cache.c\nindex acfb028..854a5d6 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -172,7 +172,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)\n {\n \tint match = -1;\n \tvoid *buffer;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tstruct strbuf sb = STRBUF_INIT;\n \n@@ -2583,7 +2583,7 @@ void *read_blob_data_from_index(const struct index_state *istate,\n \t\t\t\tconst char *path, unsigned long *size)\n {\n \tint pos, len;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tenum object_type type;\n \tvoid *data;\n \ndiff --git a/ref-filter.c b/ref-filter.c\nindex bc591f4..5c903a5 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -692,7 +692,7 @@ int verify_ref_format(struct ref_format *format)\n  * by the \"struct object\" representation, set *eaten as well---it is a\n  * signal from parse_object_buffer to us not to free the buffer.\n  */\n-static void *get_obj(const struct object_id *oid, struct object **obj, unsigned long *sz, int *eaten)\n+static void *get_obj(const struct object_id *oid, struct object **obj, size_t *sz, int *eaten)\n {\n \tenum object_type type;\n \tvoid *buf = read_sha1_file(oid->hash, &type, sz);\n@@ -1311,7 +1311,7 @@ static void populate_value(struct ref_array_item *ref)\n \tvoid *buf;\n \tstruct object *obj;\n \tint eaten, i;\n-\tunsigned long size;\n+\tsize_t size;\n \tconst struct object_id *tagged;\n \n \tref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex 0ff4a31..08748ca 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -55,7 +55,7 @@ static char *read_ref_note(const struct object_id *oid)\n {\n \tconst struct object_id *note_oid;\n \tchar *msg = NULL;\n-\tunsigned long msglen;\n+\tsize_t msglen;\n \tenum object_type type;\n \n \tinit_notes(NULL, notes_ref, NULL, 0);\n@@ -104,7 +104,7 @@ static int note2mark_cb(const struct object_id *object_oid,\n {\n \tFILE *file = (FILE *)cb_data;\n \tchar *msg;\n-\tunsigned long msglen;\n+\tsize_t msglen;\n \tenum object_type type;\n \tstruct rev_note note;\n \ndiff --git a/rerere.c b/rerere.c\nindex 70634d4..41852f0 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -974,7 +974,7 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu\n \n \twhile (pos < active_nr) {\n \t\tenum object_type type;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \n \t\tce = active_cache[pos++];\n \t\tif (ce_namelen(ce) != len || memcmp(ce->name, path, len))\ndiff --git a/sha1_file.c b/sha1_file.c\nindex b60ae15..97b39b0 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1631,7 +1631,7 @@ static const struct packed_git *has_packed_and_bad(const unsigned char *sha1)\n  * the streaming interface and rehash it to do the same.\n  */\n int check_sha1_signature(const unsigned char *sha1, void *map,\n-\t\t\t unsigned long size, const char *type)\n+\t\t\t size_t size, const char *type)\n {\n \tunsigned char real_sha1[20];\n \tenum object_type obj_type;\n@@ -1650,7 +1650,8 @@ int check_sha1_signature(const unsigned char *sha1, void *map,\n \t\treturn -1;\n \n \t/* Generate the header */\n-\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", typename(obj_type), size) + 1;\n+\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %\" PRIuMAX,\n+\t\t\t   typename(obj_type), (uintmax_t)size) + 1;\n \n \t/* Sha1.. */\n \tgit_SHA1_Init(&c);\n@@ -1795,11 +1796,11 @@ void *map_sha1_file(const unsigned char *sha1, unsigned long *size)\n }\n \n unsigned long unpack_object_header_buffer(const unsigned char *buf,\n-\t\tunsigned long len, enum object_type *type, unsigned long *sizep)\n+\t\tunsigned long len, enum object_type *type, size_t *sizep)\n {\n \tunsigned shift;\n-\tunsigned long size, c;\n-\tunsigned long used = 0;\n+\tsize_t size, c;\n+\tsize_t used = 0;\n \n \tc = buf[used++];\n \t*type = (c >> 4) & 7;\n@@ -1997,7 +1998,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,\n \treturn *hdr ? -1 : type;\n }\n \n-int parse_sha1_header(const char *hdr, unsigned long *sizep)\n+int parse_sha1_header(const char *hdr, size_t *sizep)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \n@@ -2118,7 +2119,7 @@ static const unsigned char *get_delta_base_sha1(struct packed_git *p,\n int unpack_object_header(struct packed_git *p,\n \t\t\t struct pack_window **w_curs,\n \t\t\t off_t *curpos,\n-\t\t\t unsigned long *sizep)\n+\t\t\t size_t *sizep)\n {\n \tunsigned char *base;\n \tunsigned long left;\n@@ -2171,7 +2172,7 @@ static enum object_type packed_to_object_type(struct packed_git *p,\n \n \twhile (type == OBJ_OFS_DELTA || type == OBJ_REF_DELTA) {\n \t\toff_t base_offset;\n-\t\tunsigned long size;\n+\t\tsize_t size;\n \t\t/* Push the object we're going to leave behind */\n \t\tif (poi_stack_nr >= poi_stack_alloc && poi_stack == small_poi_stack) {\n \t\t\tpoi_stack_alloc = alloc_nr(poi_stack_nr);\n@@ -2306,7 +2307,7 @@ static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)\n }\n \n static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,\n-\tunsigned long *base_size, enum object_type *type)\n+\tsize_t *base_size, enum object_type *type)\n {\n \tstruct delta_base_cache_entry *ent;\n \n@@ -2370,7 +2371,7 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,\n \t\t       struct object_info *oi)\n {\n \tstruct pack_window *w_curs = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \toff_t curpos = obj_offset;\n \tenum object_type type;\n \n@@ -2484,7 +2485,7 @@ static void *unpack_compressed_entry(struct packed_git *p,\n }\n \n static void *read_object(const unsigned char *sha1, enum object_type *type,\n-\t\t\t unsigned long *size);\n+\t\t\t size_t *size);\n \n static void write_pack_access_log(struct packed_git *p, off_t obj_offset)\n {\n@@ -2503,12 +2504,12 @@ struct unpack_entry_stack_ent {\n };\n \n void *unpack_entry(struct packed_git *p, off_t obj_offset,\n-\t\t   enum object_type *final_type, unsigned long *final_size)\n+\t\t   enum object_type *final_type, size_t *final_size)\n {\n \tstruct pack_window *w_curs = NULL;\n \toff_t curpos = obj_offset;\n \tvoid *data = NULL;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \tstruct unpack_entry_stack_ent small_delta_stack[UNPACK_ENTRY_STACK_PREALLOC];\n \tstruct unpack_entry_stack_ent *delta_stack = small_delta_stack;\n@@ -2608,7 +2609,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,\n \t\tvoid *delta_data;\n \t\tvoid *base = data;\n \t\tvoid *external_base = NULL;\n-\t\tunsigned long delta_size, base_size = size;\n+\t\tsize_t delta_size, base_size = size;\n \t\tint i;\n \n \t\tdata = NULL;\n@@ -2913,7 +2914,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,\n \tgit_zstream stream;\n \tchar hdr[32];\n \tstruct strbuf hdrbuf = STRBUF_INIT;\n-\tunsigned long size_scratch;\n+\tsize_t size_scratch;\n \n \tif (oi->delta_base_sha1)\n \t\thashclr(oi->delta_base_sha1);\n@@ -3050,7 +3051,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,\n }\n \n /* returns enum object_type or negative */\n-int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)\n+int sha1_object_info(const unsigned char *sha1, size_t *sizep)\n {\n \tenum object_type type;\n \tstruct object_info oi = OBJECT_INFO_INIT;\n@@ -3064,7 +3065,7 @@ int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)\n }\n \n static void *read_packed_sha1(const unsigned char *sha1,\n-\t\t\t      enum object_type *type, unsigned long *size)\n+\t\t\t      enum object_type *type, size_t *size)\n {\n \tstruct pack_entry e;\n \tvoid *data;\n@@ -3106,7 +3107,7 @@ int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,\n }\n \n static void *read_object(const unsigned char *sha1, enum object_type *type,\n-\t\t\t unsigned long *size)\n+\t\t\t size_t *size)\n {\n \tstruct object_info oi = OBJECT_INFO_INIT;\n \tvoid *content;\n@@ -3126,7 +3127,7 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,\n  */\n void *read_sha1_file_extended(const unsigned char *sha1,\n \t\t\t      enum object_type *type,\n-\t\t\t      unsigned long *size,\n+\t\t\t      size_t *size,\n \t\t\t      int lookup_replace)\n {\n \tvoid *data;\n@@ -3162,12 +3163,12 @@ void *read_sha1_file_extended(const unsigned char *sha1,\n \n void *read_object_with_reference(const unsigned char *sha1,\n \t\t\t\t const char *required_type_name,\n-\t\t\t\t unsigned long *size,\n+\t\t\t\t size_t *size,\n \t\t\t\t unsigned char *actual_sha1_return)\n {\n \tenum object_type type, required_type;\n \tvoid *buffer;\n-\tunsigned long isize;\n+\tsize_t isize;\n \tunsigned char actual_sha1[20];\n \n \trequired_type = type_from_string(required_type_name);\n@@ -3461,7 +3462,7 @@ int hash_sha1_file_literally(const void *buf, unsigned long len, const char *typ\n int force_object_loose(const unsigned char *sha1, time_t mtime)\n {\n \tvoid *buf;\n-\tunsigned long len;\n+\tsize_t len;\n \tenum object_type type;\n \tchar hdr[32];\n \tint hdrlen;\n@@ -3472,7 +3473,8 @@ int force_object_loose(const unsigned char *sha1, time_t mtime)\n \tbuf = read_packed_sha1(sha1, &type, &len);\n \tif (!buf)\n \t\treturn error(\"cannot read sha1_file for %s\", sha1_to_hex(sha1));\n-\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", typename(type), len) + 1;\n+\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %\" PRIuMAX,\n+\t\t\t   typename(type), (uintmax_t)len) + 1;\n \tret = write_loose_object(sha1, hdr, hdrlen, buf, len, mtime);\n \tfree(buf);\n \n@@ -3985,7 +3987,7 @@ static int check_stream_sha1(git_zstream *stream,\n int read_loose_object(const char *path,\n \t\t      const unsigned char *expected_sha1,\n \t\t      enum object_type *type,\n-\t\t      unsigned long *size,\n+\t\t      size_t *size,\n \t\t      void **contents)\n {\n \tint ret = -1;\ndiff --git a/streaming.c b/streaming.c\nindex 9afa66b..04a8b99 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -65,7 +65,7 @@ struct filtered_istream {\n \n struct git_istream {\n \tconst struct stream_vtbl *vtbl;\n-\tunsigned long size; /* inflated size of full object */\n+\tsize_t size; /* inflated size of full object */\n \tgit_zstream z;\n \tenum { z_unused, z_used, z_done, z_error } z_state;\n \n@@ -108,7 +108,7 @@ static enum input_source istream_source(const unsigned char *sha1,\n \t\t\t\t\tenum object_type *type,\n \t\t\t\t\tstruct object_info *oi)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tint status;\n \n \toi->typep = type;\n@@ -131,7 +131,7 @@ static enum input_source istream_source(const unsigned char *sha1,\n \n struct git_istream *open_istream(const unsigned char *sha1,\n \t\t\t\t enum object_type *type,\n-\t\t\t\t unsigned long *size,\n+\t\t\t\t size_t *size,\n \t\t\t\t struct stream_filter *filter)\n {\n \tstruct git_istream *st;\n@@ -502,7 +502,7 @@ int stream_blob_to_fd(int fd, const struct object_id *oid, struct stream_filter\n {\n \tstruct git_istream *st;\n \tenum object_type type;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tssize_t kept = 0;\n \tint result = -1;\n \ndiff --git a/streaming.h b/streaming.h\nindex 73c1d15..49f42c3 100644\n--- a/streaming.h\n+++ b/streaming.h\n@@ -8,7 +8,7 @@\n /* opaque */\n struct git_istream;\n \n-extern struct git_istream *open_istream(const unsigned char *, enum object_type *, unsigned long *, struct stream_filter *);\n+extern struct git_istream *open_istream(const unsigned char *, enum object_type *, size_t *, struct stream_filter *);\n extern int close_istream(struct git_istream *);\n extern ssize_t read_istream(struct git_istream *, void *, size_t);\n \ndiff --git a/submodule-config.c b/submodule-config.c\nindex 2b83c23..fa385e6 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -482,7 +482,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,\n \t\tenum lookup_type lookup_type)\n {\n \tstruct strbuf rev = STRBUF_INIT;\n-\tunsigned long config_size;\n+\tsize_t config_size;\n \tchar *config = NULL;\n \tstruct object_id oid;\n \tenum object_type type;\ndiff --git a/t/helper/test-delta.c b/t/helper/test-delta.c\nindex 59937dc..6524fbd 100644\n--- a/t/helper/test-delta.c\n+++ b/t/helper/test-delta.c\n@@ -20,7 +20,7 @@ int cmd_main(int argc, const char **argv)\n \tint fd;\n \tstruct stat st;\n \tvoid *from_buf, *data_buf, *out_buf;\n-\tunsigned long from_size, data_size, out_size;\n+\tsize_t from_size, data_size, out_size;\n \n \tif (argc != 5 || (strcmp(argv[1], \"-d\") && strcmp(argv[1], \"-p\"))) {\n \t\tfprintf(stderr, \"usage: %s\\n\", usage_str);\ndiff --git a/tag.c b/tag.c\nindex 7e10acf..b6bb5ea 100644\n--- a/tag.c\n+++ b/tag.c\n@@ -38,7 +38,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,\n {\n \tenum object_type type;\n \tchar *buf;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \ttype = sha1_object_info(oid->hash, NULL);\n@@ -177,7 +177,7 @@ int parse_tag(struct tag *item)\n {\n \tenum object_type type;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tint ret;\n \n \tif (item->object.parsed)\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 6a42e40..7c9f9e3 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -80,7 +80,7 @@ int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, unsigned l\n \n void *fill_tree_descriptor(struct tree_desc *desc, const unsigned char *sha1)\n {\n-\tunsigned long size = 0;\n+\tsize_t size = 0;\n \tvoid *buf = NULL;\n \n \tif (sha1) {\n@@ -530,7 +530,7 @@ int get_tree_entry(const unsigned char *tree_sha1, const char *name, unsigned ch\n {\n \tint retval;\n \tvoid *tree;\n-\tunsigned long size;\n+\tsize_t size;\n \tunsigned char root[20];\n \n \ttree = read_object_with_reference(tree_sha1, tree_type, &size, root);\n@@ -600,7 +600,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\n \t\tif (!t.buffer) {\n \t\t\tvoid *tree;\n \t\t\tunsigned char root[20];\n-\t\t\tunsigned long size;\n+\t\t\tsize_t size;\n \t\t\ttree = read_object_with_reference(current_tree_sha1,\n \t\t\t\t\t\t\t  tree_type, &size,\n \t\t\t\t\t\t\t  root);\n@@ -696,7 +696,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s\n \t\t\tgoto done;\n \t\t} else if (S_ISLNK(*mode)) {\n \t\t\t/* Follow a symlink */\n-\t\t\tunsigned long link_len;\n+\t\t\tsize_t link_len;\n \t\t\tsize_t len;\n \t\t\tchar *contents, *contents_start;\n \t\t\tstruct dir_state *parent;\ndiff --git a/tree.c b/tree.c\nindex b224115..5e42f83 100644\n--- a/tree.c\n+++ b/tree.c\n@@ -215,7 +215,7 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)\n {\n \t enum object_type type;\n \t void *buffer;\n-\t unsigned long size;\n+\t size_t size;\n \n \tif (item->object.parsed)\n \t\treturn 0;\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 018e033..d82cd4a 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -181,7 +181,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename)\n \n void read_mmblob(mmfile_t *ptr, const struct object_id *oid)\n {\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n \n \tif (!oidcmp(oid, &null_oid)) {\n-- \n2.1.4\n\n"},{"id":"326552","messageId":"1502914591-26215-10-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 09/19] Convert cache functions to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:21Z","receivedAt":"2017-08-16T20:17:49Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n cache-tree.c  |  6 +++---\n cache-tree.h  |  2 +-\n cache.h       |  6 +++---\n convert.c     | 18 +++++++++---------\n environment.c |  4 ++--\n read-cache.c  | 18 +++++++++---------\n 6 files changed, 27 insertions(+), 27 deletions(-)\n\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 2440d1d..77b3253 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -485,10 +485,10 @@ void cache_tree_write(struct strbuf *sb, struct cache_tree *root)\n \twrite_one(sb, root, \"\", 0);\n }\n \n-static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)\n+static struct cache_tree *read_one(const char **buffer, size_t *size_p)\n {\n \tconst char *buf = *buffer;\n-\tunsigned long size = *size_p;\n+\tsize_t size = *size_p;\n \tconst char *cp;\n \tchar *ep;\n \tstruct cache_tree *it;\n@@ -568,7 +568,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)\n \treturn NULL;\n }\n \n-struct cache_tree *cache_tree_read(const char *buffer, unsigned long size)\n+struct cache_tree *cache_tree_read(const char *buffer, size_t size)\n {\n \tif (buffer[0])\n \t\treturn NULL; /* not the whole tree */\ndiff --git a/cache-tree.h b/cache-tree.h\nindex f7b9cab..df59e6e 100644\n--- a/cache-tree.h\n+++ b/cache-tree.h\n@@ -28,7 +28,7 @@ void cache_tree_invalidate_path(struct index_state *, const char *);\n struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *);\n \n void cache_tree_write(struct strbuf *, struct cache_tree *root);\n-struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);\n+struct cache_tree *cache_tree_read(const char *buffer, size_t size);\n \n int cache_tree_fully_valid(struct cache_tree *);\n int cache_tree_update(struct index_state *, int);\ndiff --git a/cache.h b/cache.h\nindex 681dcb6..1ec53e0 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -667,7 +667,7 @@ extern int chmod_index_entry(struct index_state *, struct cache_entry *ce, char\n extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);\n extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);\n extern int index_name_is_other(const struct index_state *, const char *, int);\n-extern void *read_blob_data_from_index(const struct index_state *, const char *, unsigned long *);\n+extern void *read_blob_data_from_index(const struct index_state *, const char *, size_t *);\n \n /* do stat comparison even if CE_VALID is true */\n #define CE_MATCH_IGNORE_VALID\t\t01\n@@ -743,8 +743,8 @@ extern int pack_compression_level;\n extern size_t packed_git_window_size;\n extern size_t packed_git_limit;\n extern size_t delta_base_cache_limit;\n-extern unsigned long big_file_threshold;\n-extern unsigned long pack_size_limit_cfg;\n+extern size_t big_file_threshold;\n+extern size_t pack_size_limit_cfg;\n \n /*\n  * Accessors for the core.sharedrepository config which lazy-load the value\ndiff --git a/convert.c b/convert.c\nindex 1012462..445599b 100644\n--- a/convert.c\n+++ b/convert.c\n@@ -41,9 +41,9 @@ struct text_stat {\n \tunsigned printable, nonprintable;\n };\n \n-static void gather_stats(const char *buf, unsigned long size, struct text_stat *stats)\n+static void gather_stats(const char *buf, size_t size, struct text_stat *stats)\n {\n-\tunsigned long i;\n+\tsize_t i;\n \n \tmemset(stats, 0, sizeof(*stats));\n \n@@ -90,7 +90,7 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *\n  * The same heuristics as diff.c::mmfile_is_binary()\n  * We treat files with bare CR as binary\n  */\n-static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n+static int convert_is_binary(size_t size, const struct text_stat *stats)\n {\n \tif (stats->lonecr)\n \t\treturn 1;\n@@ -101,7 +101,7 @@ static int convert_is_binary(unsigned long size, const struct text_stat *stats)\n \treturn 0;\n }\n \n-static unsigned int gather_convert_stats(const char *data, unsigned long size)\n+static unsigned int gather_convert_stats(const char *data, size_t size)\n {\n \tstruct text_stat stats;\n \tint ret = 0;\n@@ -118,7 +118,7 @@ static unsigned int gather_convert_stats(const char *data, unsigned long size)\n \treturn ret;\n }\n \n-static const char *gather_convert_stats_ascii(const char *data, unsigned long size)\n+static const char *gather_convert_stats_ascii(const char *data, size_t size)\n {\n \tunsigned int convert_stats = gather_convert_stats(data, size);\n \n@@ -140,7 +140,7 @@ const char *get_cached_convert_stats_ascii(const struct index_state *istate,\n \t\t\t\t\t   const char *path)\n {\n \tconst char *ret;\n-\tunsigned long sz;\n+\tsize_t sz;\n \tvoid *data = read_blob_data_from_index(istate, path, &sz);\n \tret = gather_convert_stats_ascii(data, sz);\n \tfree(data);\n@@ -222,7 +222,7 @@ static void check_safe_crlf(const char *path, enum crlf_action crlf_action,\n \n static int has_cr_in_index(const struct index_state *istate, const char *path)\n {\n-\tunsigned long sz;\n+\tsize_t sz;\n \tvoid *data;\n \tint has_cr;\n \n@@ -384,7 +384,7 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,\n \n struct filter_params {\n \tconst char *src;\n-\tunsigned long size;\n+\tsize_t size;\n \tint fd;\n \tconst char *cmd;\n \tconst char *path;\n@@ -798,7 +798,7 @@ static int read_convert_config(const char *var, const char *value, void *cb)\n \treturn 0;\n }\n \n-static int count_ident(const char *cp, unsigned long size)\n+static int count_ident(const char *cp, size_t size)\n {\n \t/*\n \t * \"$Id: 0000000000000000000000000000000000000000 $\" <=> \"$Id$\"\ndiff --git a/environment.c b/environment.c\nindex 3fd4b10..7cf201f 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -40,7 +40,7 @@ int fsync_object_files;\n size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;\n size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;\n size_t delta_base_cache_limit = 96 * 1024 * 1024;\n-unsigned long big_file_threshold = 512 * 1024 * 1024;\n+size_t big_file_threshold = 512 * 1024 * 1024;\n int pager_use_color = 1;\n const char *editor_program;\n const char *askpass_program;\n@@ -63,7 +63,7 @@ int grafts_replace_parents = 1;\n int core_apply_sparse_checkout;\n int merge_log_config = -1;\n int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */\n-unsigned long pack_size_limit_cfg;\n+size_t pack_size_limit_cfg;\n enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;\n enum log_refs_config log_all_ref_updates = LOG_REFS_UNSET;\n \ndiff --git a/read-cache.c b/read-cache.c\nindex 854a5d6..8a32619 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1509,7 +1509,7 @@ struct ondisk_cache_entry_extended {\n /* Allow fsck to force verification of the index checksum. */\n int verify_index_checksum;\n \n-static int verify_hdr(struct cache_header *hdr, unsigned long size)\n+static int verify_hdr(struct cache_header *hdr, size_t size)\n {\n \tgit_SHA_CTX c;\n \tunsigned char sha1[20];\n@@ -1533,7 +1533,7 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)\n }\n \n static int read_index_extension(struct index_state *istate,\n-\t\t\t\tconst char *ext, void *data, unsigned long sz)\n+\t\t\t\tconst char *ext, void *data, size_t sz)\n {\n \tswitch (CACHE_EXT(ext)) {\n \tcase CACHE_EXT_TREE:\n@@ -1602,7 +1602,7 @@ static struct cache_entry *cache_entry_from_ondisk(struct ondisk_cache_entry *on\n  * number of bytes to be stripped from the end of the previous name,\n  * and the bytes to append to the result, to come up with its name.\n  */\n-static unsigned long expand_name_field(struct strbuf *name, const char *cp_)\n+static size_t expand_name_field(struct strbuf *name, const char *cp_)\n {\n \tconst unsigned char *ep, *cp = (const unsigned char *)cp_;\n \tsize_t len = decode_varint(&cp);\n@@ -1617,7 +1617,7 @@ static unsigned long expand_name_field(struct strbuf *name, const char *cp_)\n }\n \n static struct cache_entry *create_from_disk(struct ondisk_cache_entry *ondisk,\n-\t\t\t\t\t    unsigned long *ent_size,\n+\t\t\t\t\t    size_t *ent_size,\n \t\t\t\t\t    struct strbuf *previous_name)\n {\n \tstruct cache_entry *ce;\n@@ -1651,7 +1651,7 @@ static struct cache_entry *create_from_disk(struct ondisk_cache_entry *ondisk,\n \n \t\t*ent_size = ondisk_ce_size(ce);\n \t} else {\n-\t\tunsigned long consumed;\n+\t\tsize_t consumed;\n \t\tconsumed = expand_name_field(previous_name, name);\n \t\tce = cache_entry_from_ondisk(ondisk, flags,\n \t\t\t\t\t     previous_name->buf,\n@@ -1728,7 +1728,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n {\n \tint fd, i;\n \tstruct stat st;\n-\tunsigned long src_offset;\n+\tsize_t src_offset;\n \tstruct cache_header *hdr;\n \tvoid *mmap;\n \tsize_t mmap_size;\n@@ -1778,7 +1778,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n \tfor (i = 0; i < istate->cache_nr; i++) {\n \t\tstruct ondisk_cache_entry *disk_ce;\n \t\tstruct cache_entry *ce;\n-\t\tunsigned long consumed;\n+\t\tsize_t consumed;\n \n \t\tdisk_ce = (struct ondisk_cache_entry *)((char *)mmap + src_offset);\n \t\tce = create_from_disk(disk_ce, &consumed, previous_name);\n@@ -1914,7 +1914,7 @@ int unmerged_index(const struct index_state *istate)\n \n #define WRITE_BUFFER_SIZE 8192\n static unsigned char write_buffer[WRITE_BUFFER_SIZE];\n-static unsigned long write_buffer_len;\n+static size_t write_buffer_len;\n \n static int ce_write_flush(git_SHA_CTX *context, int fd)\n {\n@@ -2580,7 +2580,7 @@ int index_name_is_other(const struct index_state *istate, const char *name,\n }\n \n void *read_blob_data_from_index(const struct index_state *istate,\n-\t\t\t\tconst char *path, unsigned long *size)\n+\t\t\t\tconst char *path, size_t *size)\n {\n \tint pos, len;\n \tsize_t sz;\n-- \n2.1.4\n\n"},{"id":"326553","messageId":"1502914591-26215-6-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 05/19] Convert sha1_file.c to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:17Z","receivedAt":"2017-08-16T20:17:51Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n cache.h     | 16 +++++++--------\n sha1_file.c | 68 ++++++++++++++++++++++++++++++-------------------------------\n streaming.c |  2 +-\n 3 files changed, 43 insertions(+), 43 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 5c85844..681dcb6 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1197,15 +1197,15 @@ static inline const unsigned char *lookup_replace_object(const unsigned char *sh\n \n /* Read and unpack a sha1 file into memory, write memory to a sha1 file */\n extern int sha1_object_info(const unsigned char *, size_t *);\n-extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);\n-extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);\n-extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, unsigned char *sha1, unsigned flags);\n-extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);\n+extern int hash_sha1_file(const void *buf, size_t len, const char *type, unsigned char *sha1);\n+extern int write_sha1_file(const void *buf, size_t len, const char *type, unsigned char *return_sha1);\n+extern int hash_sha1_file_literally(const void *buf, size_t len, const char *type, unsigned char *sha1, unsigned flags);\n+extern int pretend_sha1_file(void *, size_t, enum object_type, unsigned char *);\n extern int force_object_loose(const unsigned char *sha1, time_t mtime);\n extern int git_open_cloexec(const char *name, int flags);\n #define git_open(name) git_open_cloexec(name, O_RDONLY)\n-extern void *map_sha1_file(const unsigned char *sha1, unsigned long *size);\n-extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);\n+extern void *map_sha1_file(const unsigned char *sha1, size_t *size);\n+extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, size_t mapsize, void *buffer, size_t bufsiz);\n extern int parse_sha1_header(const char *hdr, size_t *sizep);\n \n /* global flag to enable extra checks when accessing packed objects */\n@@ -1731,8 +1731,8 @@ extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *)\n \n extern int is_pack_valid(struct packed_git *);\n extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, size_t *);\n-extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, size_t *sizep);\n-extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n+extern size_t unpack_object_header_buffer(const unsigned char *buf, size_t len, enum object_type *type, size_t *sizep);\n+extern size_t get_size_from_delta(struct packed_git *, struct pack_window **, off_t);\n extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, size_t *);\n \n /*\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 3428172..1b3efea 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -51,7 +51,7 @@ static struct cached_object {\n \tunsigned char sha1[20];\n \tenum object_type type;\n \tvoid *buf;\n-\tunsigned long size;\n+\tsize_t size;\n } *cached_objects;\n static int cached_object_nr, cached_object_alloc;\n \n@@ -818,8 +818,8 @@ static int check_packed_git_idx(const char *path, struct packed_git *p)\n \t\t * variable sized table containing 8-byte entries\n \t\t * for offsets larger than 2^31.\n \t\t */\n-\t\tunsigned long min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;\n-\t\tunsigned long max_size = min_size;\n+\t\tsize_t min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;\n+\t\tsize_t max_size = min_size;\n \t\tif (nr)\n \t\t\tmax_size += (nr - 1)*8;\n \t\tif (idx_size < min_size || idx_size > max_size) {\n@@ -1763,7 +1763,7 @@ static int open_sha1_file(const unsigned char *sha1, const char **path)\n  */\n static void *map_sha1_file_1(const char *path,\n \t\t\t     const unsigned char *sha1,\n-\t\t\t     unsigned long *size)\n+\t\t\t     size_t *size)\n {\n \tvoid *map;\n \tint fd;\n@@ -1790,13 +1790,13 @@ static void *map_sha1_file_1(const char *path,\n \treturn map;\n }\n \n-void *map_sha1_file(const unsigned char *sha1, unsigned long *size)\n+void *map_sha1_file(const unsigned char *sha1, size_t *size)\n {\n \treturn map_sha1_file_1(NULL, sha1, size);\n }\n \n-unsigned long unpack_object_header_buffer(const unsigned char *buf,\n-\t\tunsigned long len, enum object_type *type, size_t *sizep)\n+size_t unpack_object_header_buffer(const unsigned char *buf,\n+\t\t\t\t   size_t len, enum object_type *type, size_t *sizep)\n {\n \tunsigned shift;\n \tsize_t size, c;\n@@ -1821,8 +1821,8 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,\n }\n \n static int unpack_sha1_short_header(git_zstream *stream,\n-\t\t\t\t    unsigned char *map, unsigned long mapsize,\n-\t\t\t\t    void *buffer, unsigned long bufsiz)\n+\t\t\t\t    unsigned char *map, size_t mapsize,\n+\t\t\t\t    void *buffer, size_t bufsiz)\n {\n \t/* Get the data stream */\n \tmemset(stream, 0, sizeof(*stream));\n@@ -1836,8 +1836,8 @@ static int unpack_sha1_short_header(git_zstream *stream,\n }\n \n int unpack_sha1_header(git_zstream *stream,\n-\t\t       unsigned char *map, unsigned long mapsize,\n-\t\t       void *buffer, unsigned long bufsiz)\n+\t\t       unsigned char *map, size_t mapsize,\n+\t\t       void *buffer, size_t bufsiz)\n {\n \tint status = unpack_sha1_short_header(stream, map, mapsize,\n \t\t\t\t\t      buffer, bufsiz);\n@@ -1852,8 +1852,8 @@ int unpack_sha1_header(git_zstream *stream,\n }\n \n static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,\n-\t\t\t\t\tunsigned long mapsize, void *buffer,\n-\t\t\t\t\tunsigned long bufsiz, struct strbuf *header)\n+\t\t\t\t\tsize_t mapsize, void *buffer,\n+\t\t\t\t\tsize_t bufsiz, struct strbuf *header)\n {\n \tint status;\n \n@@ -1887,11 +1887,11 @@ static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,\n \treturn -1;\n }\n \n-static void *unpack_sha1_rest(git_zstream *stream, void *buffer, unsigned long size, const unsigned char *sha1)\n+static void *unpack_sha1_rest(git_zstream *stream, void *buffer, size_t size, const unsigned char *sha1)\n {\n \tint bytes = strlen(buffer) + 1;\n \tunsigned char *buf = xmallocz(size);\n-\tunsigned long n;\n+\tsize_t n;\n \tint status = Z_OK;\n \n \tn = stream->total_out - bytes;\n@@ -1941,7 +1941,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,\n \t\t\t       unsigned int flags)\n {\n \tconst char *type_buf = hdr;\n-\tunsigned long size;\n+\tsize_t size;\n \tint type, type_len = 0;\n \n \t/*\n@@ -2006,9 +2006,9 @@ int parse_sha1_header(const char *hdr, size_t *sizep)\n \treturn parse_sha1_header_extended(hdr, &oi, 0);\n }\n \n-unsigned long get_size_from_delta(struct packed_git *p,\n-\t\t\t\t  struct pack_window **w_curs,\n-\t\t\t          off_t curpos)\n+size_t get_size_from_delta(struct packed_git *p,\n+\t\t\t   struct pack_window **w_curs,\n+\t\t\t   off_t curpos)\n {\n \tconst unsigned char *data;\n \tunsigned char delta_head[20], *in;\n@@ -2242,7 +2242,7 @@ struct delta_base_cache_entry {\n \tstruct delta_base_cache_key key;\n \tstruct list_head lru;\n \tvoid *data;\n-\tunsigned long size;\n+\tsize_t size;\n \tenum object_type type;\n };\n \n@@ -2339,7 +2339,7 @@ void clear_delta_base_cache(void)\n }\n \n static void add_delta_base_cache(struct packed_git *p, off_t base_offset,\n-\tvoid *base, unsigned long base_size, enum object_type type)\n+\tvoid *base, size_t base_size, enum object_type type)\n {\n \tstruct delta_base_cache_entry *ent = xmalloc(sizeof(*ent));\n \tstruct list_head *lru, *tmp;\n@@ -2453,7 +2453,7 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,\n static void *unpack_compressed_entry(struct packed_git *p,\n \t\t\t\t    struct pack_window **w_curs,\n \t\t\t\t    off_t curpos,\n-\t\t\t\t    unsigned long size)\n+\t\t\t\t    size_t size)\n {\n \tint st;\n \tgit_zstream stream;\n@@ -2500,7 +2500,7 @@ int do_check_packed_object_crc;\n struct unpack_entry_stack_ent {\n \toff_t obj_offset;\n \toff_t curpos;\n-\tunsigned long size;\n+\tsize_t size;\n };\n \n void *unpack_entry(struct packed_git *p, off_t obj_offset,\n@@ -2909,7 +2909,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,\n \t\t\t\t  int flags)\n {\n \tint status = 0;\n-\tunsigned long mapsize;\n+\tsize_t mapsize;\n \tvoid *map;\n \tgit_zstream stream;\n \tchar hdr[32];\n@@ -3088,7 +3088,7 @@ static void *read_packed_sha1(const unsigned char *sha1,\n \treturn data;\n }\n \n-int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,\n+int pretend_sha1_file(void *buf, size_t len, enum object_type type,\n \t\t      unsigned char *sha1)\n {\n \tstruct cached_object *co;\n@@ -3209,14 +3209,14 @@ void *read_object_with_reference(const unsigned char *sha1,\n \t}\n }\n \n-static void write_sha1_file_prepare(const void *buf, unsigned long len,\n+static void write_sha1_file_prepare(const void *buf, size_t len,\n                                     const char *type, unsigned char *sha1,\n                                     char *hdr, int *hdrlen)\n {\n \tgit_SHA_CTX c;\n \n \t/* Generate the header */\n-\t*hdrlen = xsnprintf(hdr, *hdrlen, \"%s %lu\", type, len)+1;\n+\t*hdrlen = xsnprintf(hdr, *hdrlen, \"%s %\" PRIuMAX, type, (uintmax_t)len)+1;\n \n \t/* Sha1.. */\n \tgit_SHA1_Init(&c);\n@@ -3275,7 +3275,7 @@ static int write_buffer(int fd, const void *buf, size_t len)\n \treturn 0;\n }\n \n-int hash_sha1_file(const void *buf, unsigned long len, const char *type,\n+int hash_sha1_file(const void *buf, size_t len, const char *type,\n                    unsigned char *sha1)\n {\n \tchar hdr[32];\n@@ -3339,7 +3339,7 @@ static int create_tmpfile(struct strbuf *tmp, const char *filename)\n }\n \n static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,\n-\t\t\t      const void *buf, unsigned long len, time_t mtime)\n+\t\t\t      const void *buf, size_t len, time_t mtime)\n {\n \tint fd, ret;\n \tunsigned char compressed[4096];\n@@ -3423,7 +3423,7 @@ static int freshen_packed_object(const unsigned char *sha1)\n \treturn 1;\n }\n \n-int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1)\n+int write_sha1_file(const void *buf, size_t len, const char *type, unsigned char *sha1)\n {\n \tchar hdr[32];\n \tint hdrlen = sizeof(hdr);\n@@ -3437,7 +3437,7 @@ int write_sha1_file(const void *buf, unsigned long len, const char *type, unsign\n \treturn write_loose_object(sha1, hdr, hdrlen, buf, len, 0);\n }\n \n-int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type,\n+int hash_sha1_file_literally(const void *buf, size_t len, const char *type,\n \t\t\t     unsigned char *sha1, unsigned flags)\n {\n \tchar *header;\n@@ -3929,14 +3929,14 @@ int for_each_packed_object(each_packed_object_fn cb, void *data, unsigned flags)\n \n static int check_stream_sha1(git_zstream *stream,\n \t\t\t     const char *hdr,\n-\t\t\t     unsigned long size,\n+\t\t\t     size_t size,\n \t\t\t     const char *path,\n \t\t\t     const unsigned char *expected_sha1)\n {\n \tgit_SHA_CTX c;\n \tunsigned char real_sha1[GIT_MAX_RAWSZ];\n \tunsigned char buf[4096];\n-\tunsigned long total_read;\n+\tsize_t total_read;\n \tint status = Z_OK;\n \n \tgit_SHA1_Init(&c);\n@@ -3992,7 +3992,7 @@ int read_loose_object(const char *path,\n {\n \tint ret = -1;\n \tvoid *map = NULL;\n-\tunsigned long mapsize;\n+\tsize_t mapsize;\n \tgit_zstream stream;\n \tchar hdr[32];\n \ndiff --git a/streaming.c b/streaming.c\nindex 04a8b99..448c4aa 100644\n--- a/streaming.c\n+++ b/streaming.c\n@@ -77,7 +77,7 @@ struct git_istream {\n \n \t\tstruct {\n \t\t\tvoid *mapped;\n-\t\t\tunsigned long mapsize;\n+\t\t\tsize_t mapsize;\n \t\t\tchar hdr[32];\n \t\t\tint hdr_avail;\n \t\t\tint hdr_used;\n-- \n2.1.4\n\n"},{"id":"326554","messageId":"1502914591-26215-7-git-send-email-martin@mail.zuhause","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"[Patch size_t V3 06/19] Use size_t for sha1","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:16:18Z","receivedAt":"2017-08-16T20:22:31Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"From: Martin Koegler <martin.koegler@chello.at>\n\nSigned-off-by: Martin Koegler <martin.koegler@chello.at>\n---\n block-sha1/sha1.c | 2 +-\n block-sha1/sha1.h | 2 +-\n ppc/sha1.c        | 2 +-\n ppc/sha1.h        | 2 +-\n sha1dc_git.c      | 2 +-\n sha1dc_git.h      | 2 +-\n 6 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/block-sha1/sha1.c b/block-sha1/sha1.c\nindex 22b125c..8681031 100644\n--- a/block-sha1/sha1.c\n+++ b/block-sha1/sha1.c\n@@ -203,7 +203,7 @@ void blk_SHA1_Init(blk_SHA_CTX *ctx)\n \tctx->H[4] = 0xc3d2e1f0;\n }\n \n-void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len)\n+void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, size_t len)\n {\n \tunsigned int lenW = ctx->size & 63;\n \ndiff --git a/block-sha1/sha1.h b/block-sha1/sha1.h\nindex 4df6747..9fb0441 100644\n--- a/block-sha1/sha1.h\n+++ b/block-sha1/sha1.h\n@@ -13,7 +13,7 @@ typedef struct {\n } blk_SHA_CTX;\n \n void blk_SHA1_Init(blk_SHA_CTX *ctx);\n-void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, unsigned long len);\n+void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, size_t len);\n void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx);\n \n #define platform_SHA_CTX\tblk_SHA_CTX\ndiff --git a/ppc/sha1.c b/ppc/sha1.c\nindex ec6a192..f0dfcfb 100644\n--- a/ppc/sha1.c\n+++ b/ppc/sha1.c\n@@ -25,7 +25,7 @@ int ppc_SHA1_Init(ppc_SHA_CTX *c)\n \treturn 0;\n }\n \n-int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *ptr, unsigned long n)\n+int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *ptr, size_t n)\n {\n \tunsigned long nb;\n \tconst unsigned char *p = ptr;\ndiff --git a/ppc/sha1.h b/ppc/sha1.h\nindex 9b24b32..52cac23 100644\n--- a/ppc/sha1.h\n+++ b/ppc/sha1.h\n@@ -16,7 +16,7 @@ typedef struct {\n } ppc_SHA_CTX;\n \n int ppc_SHA1_Init(ppc_SHA_CTX *c);\n-int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *p, unsigned long n);\n+int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *p, size_t n);\n int ppc_SHA1_Final(unsigned char *hash, ppc_SHA_CTX *c);\n \n #define platform_SHA_CTX\tppc_SHA_CTX\ndiff --git a/sha1dc_git.c b/sha1dc_git.c\nindex 4d32b4f..a9076bc 100644\n--- a/sha1dc_git.c\n+++ b/sha1dc_git.c\n@@ -11,7 +11,7 @@ void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)\n \t    sha1_to_hex(hash));\n }\n \n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, size_t len)\n {\n \tconst char *data = vdata;\n \t/* We expect an unsigned long, but sha1dc only takes an int */\ndiff --git a/sha1dc_git.h b/sha1dc_git.h\nindex a8a5c1d..f6051aa 100644\n--- a/sha1dc_git.h\n+++ b/sha1dc_git.h\n@@ -11,7 +11,7 @@ void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);\n /*\n  * Same as SHA1DCUpdate, but adjust types to match git's usual interface.\n  */\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, size_t len);\n \n #define platform_SHA_CTX SHA1_CTX\n #define platform_SHA1_Init SHA1DCInit\n-- \n2.1.4\n\n"},{"id":"326560","messageId":"xmqq1sobjiyn.fsf@gitster.mtv.corp.google.com","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"Re: [Patch size_t V3 00/19] use size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-16T21:33:52Z","receivedAt":"2017-08-16T21:34:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Koegler <martin.koegler@chello.at> writes:\n\n> From: Martin Koegler <martin.koegler@chello.at>\n>\n> This patchset is for next [24db08a6e8fed761d3bace7f2d5997806e20b9f7].\n> Its a complete collection of all patches. Some errors were fixed and\n> it sticks with off_t for length in (pack) files. Object sizes are handled\n> as size_t.\n\nThanks for an update.\n\nI am in the middle of today's integration cycle already, so I won't\nbe able to apply them to my tree, see how it interacts with various\nother topics, and if I can rebase it off of 'next' as of yesterday\n(I am hoping that I can update 'next' with a few new topics today)\nto give it a more appropriate base, at least until late this evening.  \n\nMaking it \"a complete collection\" is very much appreciated, as I can\nforget about random pieces that were picked up so far.  I haven't\nlooked at the patch text, but I agree that the use of off_t for\nsomething that could become a location in a file and use of size_t\nfor objects that we handle in-core would be a good place to start\n(and probably a good place to stop, at least for now).\n\n> Martin Koegler (19):\n>   delta: fix enconding size larger than an \"uint\" can hold\n>   Convert size datatype to size_t\n>   Convert zlib.c to size_t\n>   delta: Fix offset overflows\n>   Convert sha1_file.c to size_t\n>   Use size_t for sha1\n>   Convert parse_X_buffer to size_t\n>   Convert fsck.c & commit.c to size_t\n>   Convert cache functions to size_t\n>   Add overflow check to get_delta_hdr_size\n>   Use size_t for config parsing\n>   Convert pack-objects to size_t\n>   Convert index-pack to size_t\n>   Convert unpack-objects to size_t\n>   Convert archive functions to size_t\n>   Convert various things to size_t\n>   Convert ref-filter to size_t\n>   Convert tree-walk to size_t\n>   Convert xdiff-interface to size_t\n\nUsually we try to make these more like\n\n    delta: fix enconding size larger than an \"uint\" can hold\n    pack-objects: use size_t for sizes, not ulong\n    tree-walk: use size_t for sizes, not ulong\n\nor (perhaps even better for this series)\n\n    size_t: convert pack-objects away from ulong\n    size_t: convert tree-walk away from ulong\n    ...\n\nso that readers of \"git shortlog --no-merges\" can visually spot\na group of patches that are around the same theme.\n\n>  95 files changed, 525 insertions(+), 489 deletions(-)\n\nThat's a lot of changes.  Let's see how well it goes.\n\nThanks.\n"},{"id":"326562","messageId":"743056f2-da7b-5fe1-f0d7-2ee040479c69@ramsayjones.plus.com","threadId":"46607","inReplyTo":"1502914591-26215-14-git-send-email-martin@mail.zuhause","subject":"Re: [Patch size_t V3 13/19] Convert index-pack to size_t","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2017-08-16T21:42:57Z","receivedAt":"2017-08-16T21:43:05Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 16/08/17 21:16, Martin Koegler wrote:\n> From: Martin Koegler <martin.koegler@chello.at>\n> \n> Signed-off-by: Martin Koegler <martin.koegler@chello.at>\n> ---\n>  builtin/index-pack.c | 26 +++++++++++++-------------\n>  1 file changed, 13 insertions(+), 13 deletions(-)\n> \n> diff --git a/builtin/index-pack.c b/builtin/index-pack.c\n> index 7f3ccd0..bf2d728 100644\n> --- a/builtin/index-pack.c\n> +++ b/builtin/index-pack.c\n> @@ -435,7 +435,7 @@ static int is_delta_type(enum object_type type)\n>  \treturn (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);\n>  }\n>  \n> -static void *unpack_entry_data(off_t offset, unsigned long size,\n> +static void *unpack_entry_data(off_t offset, size_t size,\n>  \t\t\t       enum object_type type, unsigned char *sha1)\n>  {\n>  \tstatic char fixed_buf[8192];\n> @@ -444,10 +444,10 @@ static void *unpack_entry_data(off_t offset, unsigned long size,\n>  \tvoid *buf;\n>  \tgit_SHA_CTX c;\n>  \tchar hdr[32];\n> -\tint hdrlen;\n> +\tsize_t hdrlen;\n>  \n>  \tif (!is_delta_type(type)) {\n> -\t\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %lu\", typename(type), size) + 1;\n> +\t\thdrlen = xsnprintf(hdr, sizeof(hdr), \"%s %\" PRIuMAX, typename(type), (uintmax_t)size) + 1;\n>  \t\tgit_SHA1_Init(&c);\n>  \t\tgit_SHA1_Update(&c, hdr, hdrlen);\n>  \t} else\n> @@ -489,7 +489,7 @@ static void *unpack_raw_entry(struct object_entry *obj,\n>  \t\t\t      unsigned char *sha1)\n>  {\n>  \tunsigned char *p;\n> -\tunsigned long size, c;\n> +\tsize_t size, c;\n>  \toff_t base_offset;\n>  \tunsigned shift;\n>  \tvoid *data;\n> @@ -551,11 +551,11 @@ static void *unpack_raw_entry(struct object_entry *obj,\n>  }\n>  \n>  static void *unpack_data(struct object_entry *obj,\n> -\t\t\t int (*consume)(const unsigned char *, unsigned long, void *),\n> +\t\t\t int (*consume)(const unsigned char *, size_t, void *),\n>  \t\t\t void *cb_data)\n>  {\n>  \toff_t from = obj[0].idx.offset + obj[0].hdr_size;\n> -\toff_t len = obj[1].idx.offset - from;\n> +\tsize_t len = obj[1].idx.offset - from;\n\noff_t -> size_t.\n\nATB,\nRamsay Jones\n\n"},{"id":"326617","messageId":"xmqqwp62gk3c.fsf@gitster.mtv.corp.google.com","threadId":"46607","inReplyTo":"1502914591-26215-20-git-send-email-martin@mail.zuhause","subject":"Re: [Patch size_t V3 19/19] Convert xdiff-interface to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-17T17:49:59Z","receivedAt":"2017-08-17T17:50:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Koegler <martin.koegler@chello.at> writes:\n\n> diff --git a/combine-diff.c b/combine-diff.c\n> index acf39ec..ad5d177 100644\n> --- a/combine-diff.c\n> +++ b/combine-diff.c\n> @@ -343,7 +343,7 @@ struct combine_diff_state {\n>  \tstruct sline *lost_bucket;\n>  };\n>  \n> -static void consume_line(void *state_, char *line, unsigned long len)\n> +static void consume_line(void *state_, char *line, size_t len)\n>  {\n>  \tstruct combine_diff_state *state = state_;\n>  \tif (5 < len && !memcmp(\"@@ -\", line, 4)) {\n\nThis is a correct logical consequence of making consume_fn to take\nsize_t.\n\n> diff --git a/diff.c b/diff.c\n> index c12d062..f665f8d 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -406,7 +406,7 @@ static struct diff_tempfile {\n>  \tstruct tempfile tempfile;\n>  } diff_temp[2];\n>  \n> -typedef unsigned long (*sane_truncate_fn)(char *line, unsigned long len);\n> +typedef size_t (*sane_truncate_fn)(char *line, size_t len);\n\nIt turns out that this type, the member of this type in ecb struct, and\na conditional call to the function when it is not NULL, are all unused.\nIf this were used, this conversion is correct ;-)\n\n> @@ -4536,7 +4536,7 @@ struct patch_id_t {\n>  \tint patchlen;\n>  };\n>  \n> -static int remove_space(char *line, int len)\n> +static size_t remove_space(char *line, size_t len)\n>  {\n>  \tint i;\n>  \tchar *dst = line;\n\nThis function may also want to be rewritten.  The loop counter and\narray index \"i\" is used this way:\n\n\tfor (i = 0; i < len i++)\n\t\tif (!isspace((c = line[i]))\n\t\t\t*dst++ = c;\n\treturn dst - line;\n\nSo you are still risking data loss (later parts of line[] may not be\nscanned due to int possibly being narrower than size_t).\n\nTurning \"len\" and the return type into size_t is absolutely the\nright thing to do, and it is tempting to turn \"i\" also into size_t,\nbut we may just want to scan the thing with another pointer, i.e.\n\n        size_t remove_space(char *line, size_t len)\n        {\n                char *src = line;\n                char *dst = line;\n\n                while (src < line + len) {\n                        char c = *src++;\n                        if (!isspace(c))\n                                *dst++ = c;\n                }\n                return dst - line;\n        }\n\nChanges to size_t from types other than \"ulong\" is worth looking at\ntwice for a potential issue like this.\n\n> diff --git a/xdiff-interface.c b/xdiff-interface.c\n> index d82cd4a..f12285d 100644\n> --- a/xdiff-interface.c\n> +++ b/xdiff-interface.c\n> @@ -26,7 +26,7 @@ static int parse_num(char **cp_p, int *num_p)\n>  \treturn 0;\n>  }\n>  \n> -int parse_hunk_header(char *line, int len,\n> +int parse_hunk_header(char *line, size_t len,\n>  \t\t      int *ob, int *on,\n>  \t\t      int *nb, int *nn)\n>  {\n\nThis is a correct conversion for the purpose of this series, but the\nimplementation of this function before (and after) this patch is\nalready incorrect.  It does not pay any attention to \"len\", and\nneither the helper function this function uses, parse_num(), is\ntold how many bytes are remaining on the line to be parsed, so it\nwill happily go beyond \"len\".\n\nThe two things we may want to fix is obviously outside the scope of\nthis series, but they should be fixed (not necessarily by you) after\nthis series once the codebase solidifies, or before this series as\npreliminary clean-up.\n\nThanks.\n"},{"id":"326618","messageId":"xmqqshgqgjxx.fsf@gitster.mtv.corp.google.com","threadId":"46607","inReplyTo":"1502914591-26215-19-git-send-email-martin@mail.zuhause","subject":"Re: [Patch size_t V3 18/19] Convert tree-walk to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-17T17:53:14Z","receivedAt":"2017-08-17T17:53:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Koegler <martin.koegler@chello.at> writes:\n\n> From: Martin Koegler <martin.koegler@chello.at>\n>\n> Signed-off-by: Martin Koegler <martin.koegler@chello.at>\n> ---\n>  tree-walk.c | 17 +++++++++--------\n>  tree-walk.h |  4 ++--\n>  tree.h      |  2 +-\n>  3 files changed, 12 insertions(+), 11 deletions(-)\n\nIn this one, I did not find anything suspicious.\n\n> diff --git a/tree-walk.c b/tree-walk.c\n> index 7c9f9e3..a7d8b2a 100644\n> --- a/tree-walk.c\n> +++ b/tree-walk.c\n> @@ -22,10 +22,11 @@ static const char *get_mode(const char *str, unsigned int *modep)\n>  \treturn str;\n>  }\n>  \n> -static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned long size, struct strbuf *err)\n> +static int decode_tree_entry(struct tree_desc *desc, const char *buf, size_t size, struct strbuf *err)\n>  {\n>  \tconst char *path;\n> -\tunsigned int mode, len;\n> +\tunsigned int mode;\n> +\tsize_t len;\n>  \n>  \tif (size < 23 || buf[size - 21]) {\n>  \t\tstrbuf_addstr(err, _(\"too-short tree object\"));\n\nThe original was especially bad around here, as it didn't even use\nulong.  The conversion makes sense.\n\nThanks.\n"},{"id":"326620","messageId":"xmqqmv6ygjha.fsf@gitster.mtv.corp.google.com","threadId":"46607","inReplyTo":"1502914591-26215-18-git-send-email-martin@mail.zuhause","subject":"Re: [Patch size_t V3 17/19] Convert ref-filter to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-17T18:03:13Z","receivedAt":"2017-08-17T18:03:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Koegler <martin.koegler@chello.at> writes:\n\n> -static char *copy_subject(const char *buf, unsigned long len)\n> +static char *copy_subject(const char *buf, size_t len)\n>  {\n>  \tchar *r = xmemdupz(buf, len);\n>  \tint i;\n\nThis has the same \"we are still iterating with 'int i' over an array\nthat can be 'size_t len' long\" issue as I pointed out in 19/19.  The\nremedy is similar, i.e.\n\n\tstatic char *copy_subject(const char *buf, size_t len)\n\t{\n\t\tchar *ret = xmemdupz(buf, len);\n\t\tchar *cp;\n\n\t\tfor (cp = ret; cp < ret + len; cp++)\n\t\t\tif (*cp == '\\n')\n\t\t\t\t*cp = ' ';\n\t\treturn ret;\n\t}\n\nwhich should come either before the whole series or after the series\nsettles, not inside this series.\n\nI do also wonder if we want to do more for other control characters\n(e.g. CR, HT, etc.) in this function, though.  That is totally outside\nthe scope of this series and should be done independently.\n\n> @@ -898,7 +898,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam\n>  }\n>  \n>  /* See grab_values */\n> -static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)\n> +static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)\n>  {\n>  \tint i;\n>  \tint wholen = strlen(who);\n\nShouldn't this also become size_t, I wonder?\n\nI did not see anything fishy in the remaining parts I did not\ncomment on.\n\nThanks.\n"},{"id":"326621","messageId":"xmqqinhmgjfe.fsf@gitster.mtv.corp.google.com","threadId":"46607","inReplyTo":"xmqqmv6ygjha.fsf@gitster.mtv.corp.google.com","subject":"Re: [Patch size_t V3 17/19] Convert ref-filter to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-17T18:04:21Z","receivedAt":"2017-08-17T18:04:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> I did not see anything fishy in the remaining parts I did not\n> comment on.\n>\n> Thanks.\n\nWhat I meant was \"remainder of this patch 17/19\".  I am not claiming\nthat I read all other patches; I haven't, not yet anyway.\n"},{"id":"326635","messageId":"20170817202844.GA31284@tor.lan","threadId":"46607","inReplyTo":"1502914591-26215-2-git-send-email-martin@mail.zuhause","subject":"Re: [Patch size_t V3 01/19] delta: fix enconding size larger than an \"uint\" can hold","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2017-08-17T20:28:44Z","receivedAt":"2017-08-17T20:29:01Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Wed, Aug 16, 2017 at 10:16:13PM +0200, Martin Koegler wrote:\n> From: Martin Koegler <martin.koegler@chello.at>\n> \n> The current delta code produces incorrect pack objects for files > 4GB.\n\nThis may need a little bit more info (E.g. it does not fix anything on\na 32 bit Linux)\n\nHow about this:\nThe current delta code produces incorrect pack objects for files > 4GB\nwhen \"unsigned long\" has 32 bits and size_t 64 bits.\n\n"},{"id":"326636","messageId":"20170817203554.GB31284@tor.lan","threadId":"46607","inReplyTo":"1502914591-26215-1-git-send-email-martin@mail.zuhause","subject":"Re: [Patch size_t V3 00/19] use size_t","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2017-08-17T20:35:54Z","receivedAt":"2017-08-17T20:36:07Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Wed, Aug 16, 2017 at 10:16:12PM +0200, Martin Koegler wrote:\n> From: Martin Koegler <martin.koegler@chello.at>\n> \n> This patchset is for next [24db08a6e8fed761d3bace7f2d5997806e20b9f7].\n\nI applied it succesfully, and run the test suite on a 32 bit system.\nThe Laptop reported one brekage in t0040:\nt0040-parse-options.sh   not ok 19 - OPT_MAGNITUDE() 3giga\n\nBeside some t5561-http-backend.sh (which are most probably not caused\nby this patch.\n\nThe raspi had 2 deadlocks, like \"git push --signed dst noop ff +noff\"\nor\ntrash directory.t5541-http-push-smart/gpghome --sign -u committer@example.com\nEven this most probably not caused by the patch. (and the test is still running)\n\nWell done, and on which platforms did you test ?\n\n"},{"id":"326679","messageId":"20170818070824.GA3401@mail.zuhause","threadId":"46607","inReplyTo":"20170817203554.GB31284@tor.lan","subject":"Re: [Patch size_t V3 00/19] use size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-18T07:08:25Z","receivedAt":"2017-08-18T07:08:43Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"On Thu, Aug 17, 2017 at 10:35:54PM +0200, Torsten Bögershausen wrote:\n> On Wed, Aug 16, 2017 at 10:16:12PM +0200, Martin Koegler wrote:\n> > From: Martin Koegler <martin.koegler@chello.at>\n> > \n> > This patchset is for next [24db08a6e8fed761d3bace7f2d5997806e20b9f7].\n> \n> I applied it succesfully, and run the test suite on a 32 bit system.\n> The Laptop reported one brekage in t0040:\n> t0040-parse-options.sh   not ok 19 - OPT_MAGNITUDE() 3giga\n\nI missed test-parse-options.c - I'll post an updated versions considering all comments.\n\nparse-options takes the variable as void* - so the compilers also fails to recognize the usage\nof incompatible types.\n \n> Beside some t5561-http-backend.sh (which are most probably not caused\n> by this patch.\n> \n> The raspi had 2 deadlocks, like \"git push --signed dst noop ff +noff\"\n> or\n> trash directory.t5541-http-push-smart/gpghome --sign -u committer@example.com\n> Even this most probably not caused by the patch. (and the test is still running)\n> \n> Well done, and on which platforms did you test ?\n\nLinux 64. \n\nRegards,\nMartin\n"},{"id":"326852","messageId":"xmqqziat5sz9.fsf@gitster.mtv.corp.google.com","threadId":"46607","inReplyTo":"1502914591-26215-17-git-send-email-martin@mail.zuhause","subject":"Re: [Patch size_t V3 16/19] Convert various things to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-21T06:34:50Z","receivedAt":"2017-08-21T06:35:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Koegler <martin.koegler@chello.at> writes:\n\n> From: Martin Koegler <martin.koegler@chello.at>\n>\n> Signed-off-by: Martin Koegler <martin.koegler@chello.at>\n> ---\n>  bisect.c                | 2 +-\n>  blame.c                 | 2 +-\n>  builtin/fmt-merge-msg.c | 2 +-\n>  builtin/mktag.c         | 2 +-\n>  dir.c                   | 4 ++--\n>  dir.h                   | 2 +-\n>  6 files changed, 7 insertions(+), 7 deletions(-)\n>\n> diff --git a/bisect.c b/bisect.c\n> index 2549eaf..0580c82 100644\n> --- a/bisect.c\n> +++ b/bisect.c\n> @@ -131,7 +131,7 @@ static void show_list(const char *debug, int counted, int nr,\n>  \t\tstruct commit *commit = p->item;\n>  \t\tunsigned flags = commit->object.flags;\n>  \t\tenum object_type type;\n> -\t\tunsigned long size;\n> +\t\tsize_t size;\n>  \t\tchar *buf = read_sha1_file(commit->object.sha1, &type, &size);\n\nHmph.  At this point in the series, read_sha1_file() has already\nbeen modified to take size_t, but before this patch this caller used\nto pass a pointer to ulong, so between these two places in the\nseries the code wouldn't have compiled.  \n\nBut the end result is obviously consistent.\n\n> diff --git a/blame.c b/blame.c\n> index 739a280..f628b42 100644\n> --- a/blame.c\n> +++ b/blame.c\n> @@ -1621,7 +1621,7 @@ static const char *get_next_line(const char *start, const char *end)\n>  static int prepare_lines(struct blame_scoreboard *sb)\n>  {\n>  \tconst char *buf = sb->final_buf;\n> -\tunsigned long len = sb->final_buf_size;\n> +\tsize_t len = sb->final_buf_size;\n>  \tconst char *end = buf + len;\n>  \tconst char *p;\n>  \tint *lineno;\n\nThe final_buf_size member has already been made to size_t, and this\ncode used to receive it in ulong, which is OK for size_t <= ulong\nplatforms (which is about everybody).  OK.\n\n> diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\n> index 61ab796..3faf100 100644\n> --- a/builtin/fmt-merge-msg.c\n> +++ b/builtin/fmt-merge-msg.c\n> @@ -464,7 +464,7 @@ static void fmt_merge_msg_title(struct strbuf *out,\n>  static void fmt_tag_signature(struct strbuf *tagbuf,\n>  \t\t\t      struct strbuf *sig,\n>  \t\t\t      const char *buf,\n> -\t\t\t      unsigned long len)\n> +\t\t\t      size_t len)\n>  {\n>  \tconst char *tag_body = strstr(buf, \"\\n\\n\");\n>  \tif (tag_body) {\n\nThe callers have been passing size_t but due to the above, size_t\nthe callers had were coerced into ulong before this function used\nit.  Again, as long as size_t <= ulong, that was fine, and this\nmakes things even more consistent.  Good.\n\n> diff --git a/builtin/mktag.c b/builtin/mktag.c\n> index 0663106..ff919a7 100644\n> --- a/builtin/mktag.c\n> +++ b/builtin/mktag.c\n> @@ -34,7 +34,7 @@ static int verify_object(const unsigned char *sha1, const char *expected_type)\n>  \treturn ret;\n>  }\n>  \n> -static int verify_tag(char *buffer, unsigned long size)\n> +static int verify_tag(char *buffer, size_t size)\n>  {\n>  \tint typelen;\n>  \tchar type[20];\n\nThe only caller of this function was passing .len member of a\nstrbuf, which has been size_t forever, so this is exactly the same\nsituation as fmt_tag_signature() above.  Good.\n\n> diff --git a/dir.c b/dir.c\n> index f161c26..0c7c767 100644\n> --- a/dir.c\n> +++ b/dir.c\n> @@ -180,7 +180,7 @@ static size_t common_prefix_len(const struct pathspec *pathspec)\n>   */\n>  char *common_prefix(const struct pathspec *pathspec)\n>  {\n> -\tunsigned long len = common_prefix_len(pathspec);\n> +\tsize_t len = common_prefix_len(pathspec);\n>  \n>  \treturn len ? xmemdupz(pathspec->items[0].match, len) : NULL;\n>  }\n\nxmemdupz() takes size_t, so this could have been truncating \"len\"\nthat is ulong before this change, but common_prefix_len() returns\nsize_t anyway, so there wasn't any information loss.  This change\njust makes the code to use the correct type that is sufficiently\nwide.  Good.\n\n> @@ -2673,7 +2673,7 @@ static void load_sha1_stat(struct sha1_stat *sha1_stat,\n>  \tsha1_stat->valid = 1;\n>  }\n>  \n> -struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz)\n> +struct untracked_cache *read_untracked_extension(const void *data, size_t sz)\n>  {\n>  \tstruct untracked_cache *uc;\n>  \tstruct read_data rd;\n\nDitto.  The sole caller had size_t, that used to be promoted to\nulong in the old code but with thie patch, things become consistent.\n\nOverall it looks good to me.\n\nThe \"bisect.c\" one feels a bit odd, though; I'd expect it to be done\nwhen read_sha1_file() is made to take a pointer to size_t to avoid\nintermediate breakage.\n\nThanks.\n"},{"id":"326853","messageId":"xmqqvalh5smc.fsf@gitster.mtv.corp.google.com","threadId":"46607","inReplyTo":"1502914591-26215-16-git-send-email-martin@mail.zuhause","subject":"Re: [Patch size_t V3 15/19] Convert archive functions to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-21T06:42:35Z","receivedAt":"2017-08-21T06:42:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Koegler <martin.koegler@chello.at> writes:\n\n> From: Martin Koegler <martin.koegler@chello.at>\n>\n> Signed-off-by: Martin Koegler <martin.koegler@chello.at>\n> ---\n>  archive-tar.c | 16 ++++++++--------\n>  archive-zip.c | 22 +++++++++++-----------\n>  2 files changed, 19 insertions(+), 19 deletions(-)\n\nI feel that this needs a careful review from somebody who knows the\ndefinition of archive formats well.\n\nI am reasonably confident to say that the part of this patch that\nupdates the variable used to interact with zlib to size_t.  Use of\nfixed-width uint32_t for CRC32 may also be correct, I would think.\n\nBut for all the other changes, it makes me nervous to see that\nsize_t is used to describe size of things in an archive, and makes\nme suspect that some may want to be off_t, because an archive is a\nconcatenation of files, whose sizes are better measured in off_t\nrather than size_t.\n\n\n\n> diff --git a/archive-tar.c b/archive-tar.c\n> index 719673d..ee56b2b 100644\n> --- a/archive-tar.c\n> +++ b/archive-tar.c\n> @@ -12,7 +12,7 @@\n>  #define BLOCKSIZE\t(RECORDSIZE * 20)\n>  \n>  static char block[BLOCKSIZE];\n> -static unsigned long offset;\n> +static size_t offset;\n>  \n>  static int tar_umask = 002;\n>  \n> @@ -50,12 +50,12 @@ static void write_if_needed(void)\n>   * queues up writes, so that all our write(2) calls write exactly one\n>   * full block; pads writes to RECORDSIZE\n>   */\n> -static void do_write_blocked(const void *data, unsigned long size)\n> +static void do_write_blocked(const void *data, size_t size)\n>  {\n>  \tconst char *buf = data;\n>  \n>  \tif (offset) {\n> -\t\tunsigned long chunk = BLOCKSIZE - offset;\n> +\t\tsize_t chunk = BLOCKSIZE - offset;\n>  \t\tif (size < chunk)\n>  \t\t\tchunk = size;\n>  \t\tmemcpy(block + offset, buf, chunk);\n> @@ -77,7 +77,7 @@ static void do_write_blocked(const void *data, unsigned long size)\n>  \n>  static void finish_record(void)\n>  {\n> -\tunsigned long tail;\n> +\tsize_t tail;\n>  \ttail = offset % RECORDSIZE;\n>  \tif (tail)  {\n>  \t\tmemset(block + offset, 0, RECORDSIZE - tail);\n> @@ -86,7 +86,7 @@ static void finish_record(void)\n>  \twrite_if_needed();\n>  }\n>  \n> -static void write_blocked(const void *data, unsigned long size)\n> +static void write_blocked(const void *data, size_t size)\n>  {\n>  \tdo_write_blocked(data, size);\n>  \tfinish_record();\n> @@ -198,10 +198,10 @@ static size_t get_path_prefix(const char *path, size_t pathlen, size_t maxlen)\n>  \n>  static void prepare_header(struct archiver_args *args,\n>  \t\t\t   struct ustar_header *header,\n> -\t\t\t   unsigned int mode, unsigned long size)\n> +\t\t\t   unsigned int mode, size_t size)\n>  {\n>  \txsnprintf(header->mode, sizeof(header->mode), \"%07o\", mode & 07777);\n> -\txsnprintf(header->size, sizeof(header->size), \"%011lo\", S_ISREG(mode) ? size : 0);\n> +\txsnprintf(header->size, sizeof(header->size), \"%011lo\", S_ISREG(mode) ? (unsigned long)size : 0);\n>  \txsnprintf(header->mtime, sizeof(header->mtime), \"%011lo\", (unsigned long) args->time);\n>  \n>  \txsnprintf(header->uid, sizeof(header->uid), \"%07o\", 0);\n> @@ -219,7 +219,7 @@ static void prepare_header(struct archiver_args *args,\n>  \n>  static void write_extended_header(struct archiver_args *args,\n>  \t\t\t\t  const unsigned char *sha1,\n> -\t\t\t\t  const void *buffer, unsigned long size)\n> +\t\t\t\t  const void *buffer, size_t size)\n>  {\n>  \tstruct ustar_header header;\n>  \tunsigned int mode;\n> diff --git a/archive-zip.c b/archive-zip.c\n> index 4492d64..3a54d80 100644\n> --- a/archive-zip.c\n> +++ b/archive-zip.c\n> @@ -186,12 +186,12 @@ static uint32_t clamp32(uintmax_t n)\n>  \treturn (n < max) ? n : max;\n>  }\n>  \n> -static void *zlib_deflate_raw(void *data, unsigned long size,\n> +static void *zlib_deflate_raw(void *data, size_t size,\n>  \t\t\t      int compression_level,\n> -\t\t\t      unsigned long *compressed_size)\n> +\t\t\t      size_t *compressed_size)\n>  {\n>  \tgit_zstream stream;\n> -\tunsigned long maxsize;\n> +\tsize_t maxsize;\n>  \tvoid *buffer;\n>  \tint result;\n>  \n> @@ -219,9 +219,9 @@ static void *zlib_deflate_raw(void *data, unsigned long size,\n>  \treturn buffer;\n>  }\n>  \n> -static void write_zip_data_desc(unsigned long size,\n> -\t\t\t\tunsigned long compressed_size,\n> -\t\t\t\tunsigned long crc)\n> +static void write_zip_data_desc(size_t size,\n> +\t\t\t\tsize_t compressed_size,\n> +\t\t\t\tuint32_t crc)\n>  {\n>  \tif (size >= 0xffffffff || compressed_size >= 0xffffffff) {\n>  \t\tstruct zip64_data_desc trailer;\n> @@ -243,9 +243,9 @@ static void write_zip_data_desc(unsigned long size,\n>  }\n>  \n>  static void set_zip_header_data_desc(struct zip_local_header *header,\n> -\t\t\t\t     unsigned long size,\n> -\t\t\t\t     unsigned long compressed_size,\n> -\t\t\t\t     unsigned long crc)\n> +\t\t\t\t     size_t size,\n> +\t\t\t\t     size_t compressed_size,\n> +\t\t\t\t     uint32_t crc)\n>  {\n>  \tcopy_le32(header->crc32, crc);\n>  \tcopy_le32(header->compressed_size, compressed_size);\n> @@ -287,8 +287,8 @@ static int write_zip_entry(struct archiver_args *args,\n>  \tsize_t header_extra_size = ZIP_EXTRA_MTIME_SIZE;\n>  \tint need_zip64_extra = 0;\n>  \tunsigned long attr2;\n> -\tunsigned long compressed_size;\n> -\tunsigned long crc;\n> +\tsize_t compressed_size;\n> +\tuint32_t crc;\n>  \tint method;\n>  \tunsigned char *out;\n>  \tvoid *deflated = NULL;\n"},{"id":"326919","messageId":"20170822011904.2mow7ejlr22y7ova@genre.crustytoothpaste.net","threadId":"46607","inReplyTo":"xmqqvalh5smc.fsf@gitster.mtv.corp.google.com","subject":"Re: [Patch size_t V3 15/19] Convert archive functions to size_t","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2017-08-22T01:19:04Z","receivedAt":"2017-08-22T01:19:19Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Sun, Aug 20, 2017 at 11:42:35PM -0700, Junio C Hamano wrote:\n> Martin Koegler <martin.koegler@chello.at> writes:\n> \n> > From: Martin Koegler <martin.koegler@chello.at>\n> >\n> > Signed-off-by: Martin Koegler <martin.koegler@chello.at>\n> > ---\n> >  archive-tar.c | 16 ++++++++--------\n> >  archive-zip.c | 22 +++++++++++-----------\n> >  2 files changed, 19 insertions(+), 19 deletions(-)\n> \n> I feel that this needs a careful review from somebody who knows the\n> definition of archive formats well.\n> \n> I am reasonably confident to say that the part of this patch that\n> updates the variable used to interact with zlib to size_t.  Use of\n> fixed-width uint32_t for CRC32 may also be correct, I would think.\n> \n> But for all the other changes, it makes me nervous to see that\n> size_t is used to describe size of things in an archive, and makes\n> me suspect that some may want to be off_t, because an archive is a\n> concatenation of files, whose sizes are better measured in off_t\n> rather than size_t.\n\nI can't speak for Zip archives, but I'm familiar with tar.\n\n> > diff --git a/archive-tar.c b/archive-tar.c\n> > index 719673d..ee56b2b 100644\n> > --- a/archive-tar.c\n> > +++ b/archive-tar.c\n> > @@ -12,7 +12,7 @@\n> >  #define BLOCKSIZE\t(RECORDSIZE * 20)\n> >  \n> >  static char block[BLOCKSIZE];\n> > -static unsigned long offset;\n> > +static size_t offset;\n\nThis is fine.  The value has to be smaller than BLOCKSIZE.\n\n> >  \n> >  static int tar_umask = 002;\n> >  \n> > @@ -50,12 +50,12 @@ static void write_if_needed(void)\n> >   * queues up writes, so that all our write(2) calls write exactly one\n> >   * full block; pads writes to RECORDSIZE\n> >   */\n> > -static void do_write_blocked(const void *data, unsigned long size)\n> > +static void do_write_blocked(const void *data, size_t size)\n\nThis is fine because it's only called from write_blocked, which is only\ncalled on (a) extended headers, (b) global extended headers, and (c)\nfiles below the big file threshold.\n\nWe already restrict the big file threshold to unsigned long (in config\nparsing), which will be no larger than size_t, and we can't allocate a\nbuffer to load data into memory that is larger than size_t, so this\nshould always be safe.\n\n> >  {\n> >  \tconst char *buf = data;\n> >  \n> >  \tif (offset) {\n> > -\t\tunsigned long chunk = BLOCKSIZE - offset;\n> > +\t\tsize_t chunk = BLOCKSIZE - offset;\n\nThis is safe because it's smaller than BLOCKSIZE.\n\n> >  \t\tif (size < chunk)\n> >  \t\t\tchunk = size;\n> >  \t\tmemcpy(block + offset, buf, chunk);\n> > @@ -77,7 +77,7 @@ static void do_write_blocked(const void *data, unsigned long size)\n> >  \n> >  static void finish_record(void)\n> >  {\n> > -\tunsigned long tail;\n> > +\tsize_t tail;\n> >  \ttail = offset % RECORDSIZE;\n\nThis is safe because it's smaller than RECORDSIZE.\n\n> >  \tif (tail)  {\n> >  \t\tmemset(block + offset, 0, RECORDSIZE - tail);\n> > @@ -86,7 +86,7 @@ static void finish_record(void)\n> >  \twrite_if_needed();\n> >  }\n> >  \n> > -static void write_blocked(const void *data, unsigned long size)\n> > +static void write_blocked(const void *data, size_t size)\n\nThis is safe for the same reason do_write_blocked is safe.\n\n> >  {\n> >  \tdo_write_blocked(data, size);\n> >  \tfinish_record();\n> > @@ -198,10 +198,10 @@ static size_t get_path_prefix(const char *path, size_t pathlen, size_t maxlen)\n> >  \n> >  static void prepare_header(struct archiver_args *args,\n> >  \t\t\t   struct ustar_header *header,\n> > -\t\t\t   unsigned int mode, unsigned long size)\n> > +\t\t\t   unsigned int mode, size_t size)\n> >  {\n> >  \txsnprintf(header->mode, sizeof(header->mode), \"%07o\", mode & 07777);\n> > -\txsnprintf(header->size, sizeof(header->size), \"%011lo\", S_ISREG(mode) ? size : 0);\n> > +\txsnprintf(header->size, sizeof(header->size), \"%011lo\", S_ISREG(mode) ? (unsigned long)size : 0);\n\nThese two definitely need to be off_t.  These could be up to 2^33 and\nsize_t may only be 32 bits.\n\n> >  \txsnprintf(header->mtime, sizeof(header->mtime), \"%011lo\", (unsigned long) args->time);\n> >  \n> >  \txsnprintf(header->uid, sizeof(header->uid), \"%07o\", 0);\n> > @@ -219,7 +219,7 @@ static void prepare_header(struct archiver_args *args,\n> >  \n> >  static void write_extended_header(struct archiver_args *args,\n> >  \t\t\t\t  const unsigned char *sha1,\n> > -\t\t\t\t  const void *buffer, unsigned long size)\n> > +\t\t\t\t  const void *buffer, size_t size)\n\nThis is fine as it points to a strbuf length.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\nhttps://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"327158","messageId":"0a045197-199a-b1bc-f0bb-9ecf96ad2b50@kdbg.org","threadId":"46607","inReplyTo":"1502914591-26215-12-git-send-email-martin@mail.zuhause","subject":"Re: [Patch size_t V3 11/19] Use size_t for config parsing","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2017-08-24T20:29:22Z","receivedAt":"2017-08-24T20:29:30Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 16.08.2017 um 22:16 schrieb Martin Koegler:\n> +int git_parse_size_t(const char *value, size_t *ret)\n> +{\n> +\tuintmax_t tmp;\n> +\tif (!git_parse_unsigned(value, &tmp, maximum_signed_value_of_type(size_t)))\n> +\t\treturn 0;\n> +\t*ret = tmp;\n> +\treturn 1;\n> +}\n> +\n\nI think this requires the following on top:\n\ndiff --git a/config.c b/config.c\nindex 81d46602f9..b3075aa1c4 100644\n--- a/config.c\n+++ b/config.c\n@@ -866,7 +866,7 @@ static int git_parse_ssize_t(const char *value, ssize_t *ret)\n int git_parse_size_t(const char *value, size_t *ret)\n {\n \tuintmax_t tmp;\n-\tif (!git_parse_unsigned(value, &tmp, maximum_signed_value_of_type(size_t)))\n+\tif (!git_parse_unsigned(value, &tmp, maximum_unsigned_value_of_type(size_t)))\n \t\treturn 0;\n \t*ret = tmp;\n \treturn 1;\n"}]}