{"thread":{"id":"46575","subject":"[PATCH 4/9] Convert archive functions to size_t","startedAt":"2017-08-12T08:47:34Z","lastAt":"2017-08-17T10:38:28Z","messageCount":27,"participants":["Martin Koegler","Torsten Bögershausen","Martin Ågren","Ramsay Jones","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"326197","messageId":"1502527643-21944-4-git-send-email-martin@mail.zuhause","threadId":"46575","inReplyTo":"1502527643-21944-1-git-send-email-martin@mail.zuhause","subject":"[PATCH 4/9] Convert archive functions to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-12T08:47:18Z","receivedAt":"2017-08-12T08:47:34Z","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\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":"326198","messageId":"1502527643-21944-3-git-send-email-martin@mail.zuhause","threadId":"46575","inReplyTo":"1502527643-21944-1-git-send-email-martin@mail.zuhause","subject":"[PATCH 3/9] Convert unpack-objects to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-12T08:47:17Z","receivedAt":"2017-08-12T08:47:36Z","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":"326199","messageId":"1502527643-21944-8-git-send-email-martin@mail.zuhause","threadId":"46575","inReplyTo":"1502527643-21944-1-git-send-email-martin@mail.zuhause","subject":"[PATCH 8/9] Convert tree-walk to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-12T08:47:22Z","receivedAt":"2017-08-12T08:47: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\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":"326200","messageId":"1502527643-21944-5-git-send-email-martin@mail.zuhause","threadId":"46575","inReplyTo":"1502527643-21944-1-git-send-email-martin@mail.zuhause","subject":"[PATCH 5/9] Convert various things to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-12T08:47:19Z","receivedAt":"2017-08-12T08:47:42Z","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\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":"326201","messageId":"1502527643-21944-7-git-send-email-martin@mail.zuhause","threadId":"46575","inReplyTo":"1502527643-21944-1-git-send-email-martin@mail.zuhause","subject":"[PATCH 7/9] Convert ref-filter to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-12T08:47:21Z","receivedAt":"2017-08-12T08:47:44Z","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":"326202","messageId":"1502527643-21944-9-git-send-email-martin@mail.zuhause","threadId":"46575","inReplyTo":"1502527643-21944-1-git-send-email-martin@mail.zuhause","subject":"[PATCH 9/9] Convert xdiff-interface to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-12T08:47:23Z","receivedAt":"2017-08-12T08:47:47Z","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  |  6 +++---\n xdiff-interface.h  |  6 +++---\n 5 files changed, 23 insertions(+), 23 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 dd6ff0a..1f56205 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -464,7 +464,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@@ -519,7 +519,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@@ -1522,7 +1522,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@@ -1651,7 +1651,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@@ -1962,10 +1962,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@@ -1995,7 +1995,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 *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);\n@@ -2199,7 +2199,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@@ -2854,7 +2854,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@@ -2877,7 +2877,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@@ -3692,7 +3692,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@@ -5301,7 +5301,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@@ -5314,10 +5314,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..65cb08b 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\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..c7c1676 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, int size_t,\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":"326203","messageId":"1502527643-21944-6-git-send-email-martin@mail.zuhause","threadId":"46575","inReplyTo":"1502527643-21944-1-git-send-email-martin@mail.zuhause","subject":"[PATCH 6/9] Use size_t for config parsing","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-12T08:47:20Z","receivedAt":"2017-08-12T08:47:50Z","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               |  1 +\n 3 files changed, 26 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex f8db283..0086da7 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 831cf8b..444b1d1 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+static 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 fb76729..c264ee8 100644\n--- a/config.h\n+++ b/config.h\n@@ -54,6 +54,7 @@ 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":"326204","messageId":"1502527643-21944-2-git-send-email-martin@mail.zuhause","threadId":"46575","inReplyTo":"1502527643-21944-1-git-send-email-martin@mail.zuhause","subject":"[PATCH 2/9] Convert index-pack to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-12T08:47:16Z","receivedAt":"2017-08-12T08:47:53Z","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":"326205","messageId":"1502527643-21944-1-git-send-email-martin@mail.zuhause","threadId":"46575","inReplyTo":null,"subject":"[PATCH 1/9] Convert pack-objects to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-12T08:47:15Z","receivedAt":"2017-08-12T08:56:46Z","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 | 48 ++++++++++++++++++++++++------------------------\n 1 file changed, 24 insertions(+), 24 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex aa70f80..f8db283 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,17 +350,17 @@ 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 \tstruct revindex_entry *revidx;\n \toff_t offset;\n \tenum object_type type = entry->type;\n-\toff_t datalen;\n+\tsize_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 \n-- \n2.1.4\n\n"},{"id":"326209","messageId":"20170812095915.GA5768@tor.lan","threadId":"46575","inReplyTo":"1502527643-21944-1-git-send-email-martin@mail.zuhause","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2017-08-12T09:59:15Z","receivedAt":"2017-08-12T09:59:34Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"Thanks for working on this - unfortunatly the patch does not apply on\ngit.git/master.\n\nWhich baseline did you use ?\n\n"},{"id":"326214","messageId":"CAN0heSqu0evvo7dFPwWvgEthoafCVZmJKbRftBbHRhtN_du4HQ@mail.gmail.com","threadId":"46575","inReplyTo":"1502527643-21944-5-git-send-email-martin@mail.zuhause","subject":"Re: [PATCH 5/9] Convert various things to size_t","fromName":"Martin Ågren","fromEmail":"martin.agren@gmail.com","sentAt":"2017-08-12T13:27:21Z","receivedAt":"2017-08-12T13:27:28Z","isPatch":true,"sender":{"key":"martin.agren@gmail.com","avatar":null},"body":"On 12 August 2017 at 10:47, Martin Koegler <martin.koegler@chello.at> wrote:\n> From: Martin Koegler <martin.koegler@chello.at>\n>\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>                 struct commit *commit = p->item;\n>                 unsigned flags = commit->object.flags;\n>                 enum object_type type;\n> -               unsigned long size;\n> +               size_t size;\n>                 char *buf = read_sha1_file(commit->object.sha1, &type, &size);\n>                 const char *subject_start;\n>                 int subject_len;\n\nWould this need to be done in a patch where read_sha1_file is converted?\n"},{"id":"326216","messageId":"87fc215e-b860-10f5-5c5e-60652502fae8@ramsayjones.plus.com","threadId":"46575","inReplyTo":"1502527643-21944-1-git-send-email-martin@mail.zuhause","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2017-08-12T13:47:25Z","receivedAt":"2017-08-12T13:47:34Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 12/08/17 09:47, 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/pack-objects.c | 48 ++++++++++++++++++++++++------------------------\n>  1 file changed, 24 insertions(+), 24 deletions(-)\n> \n> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\n> index aa70f80..f8db283 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,17 +350,17 @@ 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>  \tstruct revindex_entry *revidx;\n>  \toff_t offset;\n>  \tenum object_type type = entry->type;\n> -\toff_t datalen;\n> +\tsize_t datalen;\n\nOn 32-bit Linux, off_t is 64-bit and size_t is 32-bit.\n\nLater in this function, datalen is set the the difference of\ntwo (revidx) off_t offsets. I haven't applied and tried this\non my 32-bit Linux install yet (that installation only gets\nbooted about once a week), but I suspect a 'possible data-loss'\nwarning.\n\nFor other reasons, I don't think it is not possible for\na 32-bit system to create a packfile with an individual object\nof size > 4GB anyway, so this may not be a problem in practice.\n(a 32-bit system should be able to read such a packfile, presumably\ncreated on a 64-bit system, and refuse to load such an object, of\ncourse).\n\nATB,\nRamsay Jones\n"},{"id":"326218","messageId":"0f19234c-524e-7d93-4700-c44aa1e6f3a6@ramsayjones.plus.com","threadId":"46575","inReplyTo":"1502527643-21944-2-git-send-email-martin@mail.zuhause","subject":"Re: [PATCH 2/9] Convert index-pack to size_t","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2017-08-12T13:51:13Z","receivedAt":"2017-08-12T13:51:20Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 12/08/17 09:47, 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\nSimilar comment to previous patch.\n\nATB,\nRamsay Jones\n\n"},{"id":"326219","messageId":"CAN0heSpViT-Nz8OO7Bww3Fbm=mzA6wvm0EfgfRjsz+cVfvu3Yw@mail.gmail.com","threadId":"46575","inReplyTo":"1502527643-21944-3-git-send-email-martin@mail.zuhause","subject":"Re: [PATCH 3/9] Convert unpack-objects to size_t","fromName":"Martin Ågren","fromEmail":"martin.agren@gmail.com","sentAt":"2017-08-12T14:07:50Z","receivedAt":"2017-08-12T14:07:55Z","isPatch":true,"sender":{"key":"martin.agren@gmail.com","avatar":null},"body":"On 12 August 2017 at 10:47, Martin Koegler <martin.koegler@chello.at> wrote:\n> From: Martin Koegler <martin.koegler@chello.at>\n>\n> Signed-off-by: Martin Koegler <martin.koegler@chello.at>\n> ---\n>  builtin/unpack-objects.c | 20 ++++++++++----------\n>  1 file changed, 10 insertions(+), 10 deletions(-)\n>\n> diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\n> index 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>         char *buffer;\n> -       unsigned long size;\n> +       size_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>         return 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>         struct obj_buffer *obj;\n>         obj = xcalloc(1, sizeof(struct obj_buffer));\n> @@ -93,7 +93,7 @@ static void use(int bytes)\n>                 die(_(\"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>         git_zstream stream;\n>         void *buf = xmallocz(size);\n\n\"size\" is handed over to a \"git_zstream\" and goes through zlib.c,\neventually ending up in zlib, which is outside Git's control, and which\nseems to work with \"uLong\"s. How do these kind of changes interact with\nzlib? For example, I wonder about this line further down in get_data:\n\nif (stream.total_out == size && ret == Z_STREAM_END)\n\nIf total_out isn't converted, I guess this would never hit if \"size\" is\ntoo large. And if total_out /is/ converted, I guess we'd risk truncation\nin zlib_pre_call in zlib.c. Maybe that might cause Git and zlib to have\ndifferent ideas about how much data is available and/or should be\nprocessed. Maybe we could then hit things like this in git.c:\n\nif (s->z.total_out != s->total_out + bytes_produced)\n        die(\"BUG: total_out mismatch\");\n\nI am not very familiar with zlib, so apologies if this is just noise...\n\nMartin\n"},{"id":"326243","messageId":"20170813174821.GA30330@mail.zuhause","threadId":"46575","inReplyTo":"CAN0heSqu0evvo7dFPwWvgEthoafCVZmJKbRftBbHRhtN_du4HQ@mail.gmail.com","subject":"Re: [PATCH 5/9] Convert various things to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-13T17:48:21Z","receivedAt":"2017-08-13T18:04:07Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"On Sat, Aug 12, 2017 at 03:27:21PM +0200, Martin Ågren wrote:\n> On 12 August 2017 at 10:47, Martin Koegler <martin.koegler@chello.at> wrote:\n> > From: Martin Koegler <martin.koegler@chello.at>\n> >\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> >                 struct commit *commit = p->item;\n> >                 unsigned flags = commit->object.flags;\n> >                 enum object_type type;\n> > -               unsigned long size;\n> > +               size_t size;\n> >                 char *buf = read_sha1_file(commit->object.sha1, &type, &size);\n> >                 const char *subject_start;\n> >                 int subject_len;\n> \n> Would this need to be done in a patch where read_sha1_file is converted?\n\nI missed this first, because it is debug code requiring a code change to be enabled. \n\nIt probably should be merged in my second patch. On the other hand that patch is already considered too large.\n\nRegards,\nMartin\n"},{"id":"326244","messageId":"20170813182552.GA31079@mail.zuhause","threadId":"46575","inReplyTo":"CAN0heSpViT-Nz8OO7Bww3Fbm=mzA6wvm0EfgfRjsz+cVfvu3Yw@mail.gmail.com","subject":"Re: [PATCH 3/9] Convert unpack-objects to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-13T18:25:52Z","receivedAt":"2017-08-13T18:26:05Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"On Sat, Aug 12, 2017 at 04:07:50PM +0200, Martin Ågren wrote:\n> On 12 August 2017 at 10:47, Martin Koegler <martin.koegler@chello.at> wrote:\n> \"size\" is handed over to a \"git_zstream\" and goes through zlib.c,\n> eventually ending up in zlib, which is outside Git's control, and which\n> seems to work with \"uLong\"s. How do these kind of changes interact with\n> zlib? For example, I wonder about this line further down in get_data:\n> \n> if (stream.total_out == size && ret == Z_STREAM_END)\n> \n> If total_out isn't converted, I guess this would never hit if \"size\" is\n> too large. And if total_out /is/ converted, I guess we'd risk truncation\n\nI posted a patch changing git_zstream.\n\n> in zlib_pre_call in zlib.c. Maybe that might cause Git and zlib to have\n> different ideas about how much data is available and/or should be\n> processed. Maybe we could then hit things like this in git.c:\n> \n> if (s->z.total_out != s->total_out + bytes_produced)\n>         die(\"BUG: total_out mismatch\");\n> \n> I am not very familiar with zlib, so apologies if this is just noise...\n\nYou are right, if sizeof(size_t) != sizeof(unsigned long), there can be truncations.\n\nCurrently, an object size is read/passed as ulong including to the memory allocation functions.\n(x)malloc & Co take a length - so the whole GIT code might assume a larger object size than the\nmemory allocation functions.\nMigrating everything to size_t means, that we move the truncation locations to places, where values \nenter/leave GIT.\n\nMy patches are just a starting point to fix the size handling. They concentrate of fixing data types - \nnot avoiding any possible overflow.  Merging them will already be a challenging task, because they \ntouch many functions and will likely conflict with other changes (eg. moving functions).\n\nRegards,\nMartin\n\n"},{"id":"326245","messageId":"20170813182723.GB31079@mail.zuhause","threadId":"46575","inReplyTo":"20170812095915.GA5768@tor.lan","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-13T18:27:23Z","receivedAt":"2017-08-13T18:27:37Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"On Sat, Aug 12, 2017 at 11:59:15AM +0200, Torsten Bögershausen wrote:\n> Thanks for working on this - unfortunatly the patch does not apply on\n> git.git/master.\n> \n> Which baseline did you use ?\n\nnext - 98096fd7a85b93626db8757f944f2d8ffdf7e96a\nIt accumulated to 19 patches.\n\nRegards,\nMartin \n"},{"id":"326246","messageId":"20170813183026.GC31079@mail.zuhause","threadId":"46575","inReplyTo":"87fc215e-b860-10f5-5c5e-60652502fae8@ramsayjones.plus.com","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-13T18:30:26Z","receivedAt":"2017-08-13T18:30:38Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"On Sat, Aug 12, 2017 at 02:47:25PM +0100, Ramsay Jones wrote:\n> On 32-bit Linux, off_t is 64-bit and size_t is 32-bit.\n\n--- t.c ---\n#include <stddef.h>\n#include <stdio.h>\n\nint main()\n{\nprintf(\"%d %d\\n\", sizeof(size_t), sizeof(off_t));\n}\n------------\n$ gcc -m32 -o t t.c\n$ ./t.c\n4 4\n\nSo is that really true?\n\nRegards,\nMartin \n"},{"id":"326257","messageId":"627042be-ab86-e9da-8c4e-5aac3278f5c6@ramsayjones.plus.com","threadId":"46575","inReplyTo":"20170813183026.GC31079@mail.zuhause","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2017-08-13T19:45:04Z","receivedAt":"2017-08-13T19:45:14Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 13/08/17 19:30, Martin Koegler wrote:\n> On Sat, Aug 12, 2017 at 02:47:25PM +0100, Ramsay Jones wrote:\n>> On 32-bit Linux, off_t is 64-bit and size_t is 32-bit.\n> \n> --- t.c ---\n> #include <stddef.h>\n> #include <stdio.h>\n> \n> int main()\n> {\n> printf(\"%d %d\\n\", sizeof(size_t), sizeof(off_t));\n> }\n> ------------\n> $ gcc -m32 -o t t.c\n> $ ./t.c\n> 4 4\n> \n> So is that really true?\n\nIt should be, see commit b97e911643 (\"Support for large files\non 32bit systems.\", 17-02-2007), where you can see that the\n_FILE_OFFSET_BITS macro is set to 64. This asks <stdio.h> et.al.,\nto use the \"Large File System\" API and a 64-bit off_t.\n\nI can't boot my 32-bit installation at the moment, and it seems\nthat my 64-bit multilib system is not playing ball:\n\n  $ gcc -m32 -D_FILE_OFFSET_BITS=64 -o t t.c\n  In file included from /usr/include/stdio.h:27:0,\n                   from t.c:2:\n  /usr/include/features.h:367:25: fatal error: sys/cdefs.h: No such file or directory\n  compilation terminated.\n  $ \n\nATB,\nRamsay Jones\n\n"},{"id":"326258","messageId":"xmqqtw1bw1v6.fsf@gitster.mtv.corp.google.com","threadId":"46575","inReplyTo":"627042be-ab86-e9da-8c4e-5aac3278f5c6@ramsayjones.plus.com","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-13T22:15:41Z","receivedAt":"2017-08-13T22:15:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n\n> It should be, see commit b97e911643 (\"Support for large files\n> on 32bit systems.\", 17-02-2007), where you can see that the\n> _FILE_OFFSET_BITS macro is set to 64. This asks <stdio.h> et.al.,\n> to use the \"Large File System\" API and a 64-bit off_t.\n\nCorrect.  Roughly speaking, we should view off_t as size of things\nyou can store in a file, and size_t as size of things you can have\nin core.  When we allocate a region of memory, and then repeatedly\nfill it with some data and hand that memory to a helper function\ne.g. git_deflate(), each of these calls should expect to get data\nwhose size can be representable by size_t, and if that is shorter\nthan ulong which we currently use, we are artificially limiting our\npotential by using a type that is narrower than necessary.  \n\nThe result from these helper functions that are repeatedly called\nmay be sent to a file as the output from the loop.  If that logic in\nthe outer loop wants to keep a tally of the total size of data they\nprocessed, that number may not be fit in size_t and instead may\nrequire off_t.\n\nOne interesting question is which of these two types we should use\nfor the size of objects Git uses.  \n\nMost of the \"interesting\" operations done by Git require that the\nthing is in core as a whole before we can do anything (e.g. compare\ntwo such things to produce delta, have one in core and apply patch),\nso it is tempting that we deal with size_t, but at the lowest level\nto serve as a SCM, i.e. recording the state of a file at each\nversion, we actually should be able to exceed the in-core\nlimit---both \"git add\" of a huge file whose contents would not fit\nin-core and \"git checkout\" of a huge blob whose inflated contents\nwould not fit in-core should (in theory, modulo bugs) be able to\nexercise the streaming interface to handle such case without holding\neverything in-core at once.  So from that point of view, even size_t\nmay not be the \"correct\" type to use.\n"},{"id":"326281","messageId":"xmqqfucuw00a.fsf@gitster.mtv.corp.google.com","threadId":"46575","inReplyTo":"xmqqtw1bw1v6.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-14T17:08:05Z","receivedAt":"2017-08-14T17:08:14Z","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> One interesting question is which of these two types we should use\n> for the size of objects Git uses.  \n>\n> Most of the \"interesting\" operations done by Git require that the\n> thing is in core as a whole before we can do anything (e.g. compare\n> two such things to produce delta, have one in core and apply patch),\n> so it is tempting that we deal with size_t, but at the lowest level\n> to serve as a SCM, i.e. recording the state of a file at each\n> version, we actually should be able to exceed the in-core\n> limit---both \"git add\" of a huge file whose contents would not fit\n> in-core and \"git checkout\" of a huge blob whose inflated contents\n> would not fit in-core should (in theory, modulo bugs) be able to\n> exercise the streaming interface to handle such case without holding\n> everything in-core at once.  So from that point of view, even size_t\n> may not be the \"correct\" type to use.\n\nA few additions to the above observations.\n\n - We have varint that encodes how far the location from a delta\n   representation of an object to its base object in the packfile.\n   Both encoding and decoding sides in the current code use off_t to\n   represent this offset, so we can already reference an object that\n   is far in the same packfile as a base.\n\n - I think it is OK in practice to limit the size of individual\n   objects to size_t (i.e. on 32-bit arch, you cannot interact with\n   a repository with an object whose size exceeds 4GB).  Using off_t\n   would allow occasional ultra-huge objects that can only be added\n   and checked in via the streaming API on such a platform, but I\n   suspect that it may become too much of a hassle to maintain.\n\n   It may help reducing the maintenance if we introduced obj_size_t\n   that is defined to be size_t for now, so that we can later swap\n   it to ofs_t or some larger type when we know we do need to\n   support objects whose size cannot be expressed in size_t, but I\n   do not offhand know what the pros-and-cons with such an approach\n   would look like.\n\nThanks.\n"},{"id":"326299","messageId":"c49628e0-6a57-34d6-6727-f8111b80cbab@ramsayjones.plus.com","threadId":"46575","inReplyTo":"xmqqfucuw00a.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2017-08-14T19:31:50Z","receivedAt":"2017-08-14T19:31:59Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 14/08/17 18:08, Junio C Hamano wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n>> One interesting question is which of these two types we should use\n>> for the size of objects Git uses.  \n>>\n>> Most of the \"interesting\" operations done by Git require that the\n>> thing is in core as a whole before we can do anything (e.g. compare\n>> two such things to produce delta, have one in core and apply patch),\n>> so it is tempting that we deal with size_t, but at the lowest level\n>> to serve as a SCM, i.e. recording the state of a file at each\n>> version, we actually should be able to exceed the in-core\n>> limit---both \"git add\" of a huge file whose contents would not fit\n>> in-core and \"git checkout\" of a huge blob whose inflated contents\n>> would not fit in-core should (in theory, modulo bugs) be able to\n>> exercise the streaming interface to handle such case without holding\n>> everything in-core at once.  So from that point of view, even size_t\n>> may not be the \"correct\" type to use.\n> \n> A few additions to the above observations.\n> \n>  - We have varint that encodes how far the location from a delta\n>    representation of an object to its base object in the packfile.\n>    Both encoding and decoding sides in the current code use off_t to\n>    represent this offset, so we can already reference an object that\n>    is far in the same packfile as a base.\n> \n>  - I think it is OK in practice to limit the size of individual\n>    objects to size_t (i.e. on 32-bit arch, you cannot interact with\n>    a repository with an object whose size exceeds 4GB).  Using off_t\n>    would allow occasional ultra-huge objects that can only be added\n>    and checked in via the streaming API on such a platform, but I\n>    suspect that it may become too much of a hassle to maintain.\n\nIn a previous comment, I said that (on 32-bit Linux) it was likely\nthat an object of > 4GB could not be handled correctly anyway. (more\nlikely > 2GB). This was based on the code from (quite some) years ago.\nIn particular, before you added the \"streaming API\". So, maybe a 32-bit\narch _should_ be able to handle objects as large as the LFS API allows.\n(Ignoring, for the moment, that I think anybody who puts files of that\nsize into an SCM probably gets what they deserve. :-P ).\n\nThe two patches I commented on, however, changed the type of some\nvariables from off_t to size_t. In general, the patches did not\nseem to make anything worse, but these type changes could potentially\ndo harm. Hence my comment. (I still haven't tried the patches on my\n32-bit Linux system. I only boot it up about once a week, and I would\nrather wait until the patches are in the 'pu' branch before testing).\n\nATB,\nRamsay Jones\n\n"},{"id":"326303","messageId":"xmqq378tvs3o.fsf@gitster.mtv.corp.google.com","threadId":"46575","inReplyTo":"c49628e0-6a57-34d6-6727-f8111b80cbab@ramsayjones.plus.com","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-08-14T19:58:51Z","receivedAt":"2017-08-14T19:58:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n\n> In a previous comment, I said that (on 32-bit Linux) it was likely\n> that an object of > 4GB could not be handled correctly anyway. (more\n> likely > 2GB). This was based on the code from (quite some) years ago.\n> In particular, before you added the \"streaming API\". So, maybe a 32-bit\n> arch _should_ be able to handle objects as large as the LFS API allows.\n> (Ignoring, for the moment, that I think anybody who puts files of that\n> size into an SCM probably gets what they deserve. :-P ).\n>\n> The two patches I commented on, however, changed the type of some\n> variables from off_t to size_t. In general, the patches did not\n> seem to make anything worse, but these type changes could potentially\n> do harm. Hence my comment. (I still haven't tried the patches on my\n> 32-bit Linux system. I only boot it up about once a week, and I would\n> rather wait until the patches are in the 'pu' branch before testing).\n\nWe are in perfect agreement.\n\nI didn't mean to say that it is OK to replace off_t with size_t\nwithout a good reason, especially when the current code (at least\nthe part I looked at anyway, like the OFS_DELTA part) seems to use\noff_t correctly, and your review comments are very much appreciated,\nso is the effort started by Martin to take us in the direction of\nusing types more appropriate than \"ulong\".\n"},{"id":"326308","messageId":"20170814203235.GA4293@tor.lan","threadId":"46575","inReplyTo":"c49628e0-6a57-34d6-6727-f8111b80cbab@ramsayjones.plus.com","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2017-08-14T20:32:35Z","receivedAt":"2017-08-14T20:32:56Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Mon, Aug 14, 2017 at 08:31:50PM +0100, Ramsay Jones wrote:\n> \n> \n> On 14/08/17 18:08, Junio C Hamano wrote:\n> > Junio C Hamano <gitster@pobox.com> writes:\n> > \n> >> One interesting question is which of these two types we should use\n> >> for the size of objects Git uses.  \n> >>\n> >> Most of the \"interesting\" operations done by Git require that the\n> >> thing is in core as a whole before we can do anything (e.g. compare\n> >> two such things to produce delta, have one in core and apply patch),\n> >> so it is tempting that we deal with size_t, but at the lowest level\n> >> to serve as a SCM, i.e. recording the state of a file at each\n> >> version, we actually should be able to exceed the in-core\n> >> limit---both \"git add\" of a huge file whose contents would not fit\n> >> in-core and \"git checkout\" of a huge blob whose inflated contents\n> >> would not fit in-core should (in theory, modulo bugs) be able to\n> >> exercise the streaming interface to handle such case without holding\n> >> everything in-core at once.  So from that point of view, even size_t\n> >> may not be the \"correct\" type to use.\n> > \n> > A few additions to the above observations.\n> > \n> >  - We have varint that encodes how far the location from a delta\n> >    representation of an object to its base object in the packfile.\n> >    Both encoding and decoding sides in the current code use off_t to\n> >    represent this offset, so we can already reference an object that\n> >    is far in the same packfile as a base.\n> > \n> >  - I think it is OK in practice to limit the size of individual\n> >    objects to size_t (i.e. on 32-bit arch, you cannot interact with\n> >    a repository with an object whose size exceeds 4GB).  Using off_t\n> >    would allow occasional ultra-huge objects that can only be added\n> >    and checked in via the streaming API on such a platform, but I\n> >    suspect that it may become too much of a hassle to maintain.\n> \n> In a previous comment, I said that (on 32-bit Linux) it was likely\n> that an object of > 4GB could not be handled correctly anyway. (more\n> likely > 2GB). This was based on the code from (quite some) years ago.\n> In particular, before you added the \"streaming API\". So, maybe a 32-bit\n> arch _should_ be able to handle objects as large as the LFS API allows.\n> (Ignoring, for the moment, that I think anybody who puts files of that\n> size into an SCM probably gets what they deserve. :-P ).\n\nIn general, yes.\nI had a patch that allowed a 32 bit linux to commit a file >4GB.\nThere is however a restriction: The file must not yet be known to the\nindex. Otherwise the \"diff\" machinery kicks in, and tries to\ncompare the \"old\" and the \"new\" versions, which means that -both-\nmust fit into \"memory\" at the same time. Memory means here the available\naddress space rather then real memory.\nSo there may be room for improvements for 32 bit systems, but that is another\nstory, which can be developped independent of the ulong->size_t conversion.\n\n> \n> The two patches I commented on, however, changed the type of some\n> variables from off_t to size_t. In general, the patches did not\n> seem to make anything worse, but these type changes could potentially\n> do harm. Hence my comment. (I still haven't tried the patches on my\n> 32-bit Linux system. I only boot it up about once a week, and I would\n> rather wait until the patches are in the 'pu' branch before testing).\n> \n> ATB,\n> Ramsay Jones\n> \n\nAnd here (in agreement with the answer from Junio):\nWe should not change any off_t into size_t, since that means a possible\ndowngrade.\nWhenever an off_t is converted into size_t, a function in git-compat-util.h is\nused:\n\nstatic inline size_t xsize_t(off_t len)\n{\n\tif (len > (size_t) len)\n\t\tdie(\"Cannot handle files this big\");\n\treturn (size_t)len;\n}\n\nHaving written this, it may be a good idea to define a similar function\nxulong() which is used when we do calls into zlib.\n\nThanks to Martin for working on this.\nIf there is a branch on a public repo, I can e.g. run the test suite on\ndifferent systems.\n"},{"id":"326353","messageId":"ddcd8831-e520-39eb-7826-de3285d2b991@ramsayjones.plus.com","threadId":"46575","inReplyTo":"20170814203235.GA4293@tor.lan","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2017-08-15T00:30:22Z","receivedAt":"2017-08-15T00:30:30Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 14/08/17 21:32, Torsten Bögershausen wrote:\n> In general, yes.\n> I had a patch that allowed a 32 bit linux to commit a file >4GB.\n> There is however a restriction: The file must not yet be known to the\n> index. Otherwise the \"diff\" machinery kicks in, and tries to\n> compare the \"old\" and the \"new\" versions, which means that -both-\n> must fit into \"memory\" at the same time. Memory means here the available\n> address space rather then real memory.\n> So there may be room for improvements for 32 bit systems, but that is another\n> story, which can be developped independent of the ulong->size_t conversion.\n\nOh, I absolutely agree.\n\n> Thanks to Martin for working on this.\n\nIndeed! Thanks Martin.\n\nATB,\nRamsay Jones\n\n\n"},{"id":"326555","messageId":"20170816202238.GA3008@mail.zuhause","threadId":"46575","inReplyTo":"xmqqfucuw00a.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Martin Koegler","fromEmail":"martin.koegler@chello.at","sentAt":"2017-08-16T20:22:39Z","receivedAt":"2017-08-16T20:22:56Z","isPatch":true,"sender":{"key":"martin.koegler@chello.at","avatar":"https://avatars.githubusercontent.com/u/1859030?v=4"},"body":"On Mon, Aug 14, 2017 at 10:08:05AM -0700, Junio C Hamano wrote:\n>    It may help reducing the maintenance if we introduced obj_size_t\n>    that is defined to be size_t for now, so that we can later swap\n>    it to ofs_t or some larger type when we know we do need to\n>    support objects whose size cannot be expressed in size_t, but I\n>    do not offhand know what the pros-and-cons with such an approach\n>    would look like.\n\nWhere should the use of obj_size_t end and the use of size_t start? \n\nWe often determine a object size and then pass it to malloc. \nWe would start with a larger datatyp and then truncate for memory allocation, which use size_t.\n\nRegards,\nMartin\n"},{"id":"326598","messageId":"20170817103804.GA18336@tor.lan","threadId":"46575","inReplyTo":"20170816202238.GA3008@mail.zuhause","subject":"Re: [PATCH 1/9] Convert pack-objects to size_t","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2017-08-17T10:38:04Z","receivedAt":"2017-08-17T10:38:28Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Wed, Aug 16, 2017 at 10:22:39PM +0200, Martin Koegler wrote:\n> On Mon, Aug 14, 2017 at 10:08:05AM -0700, Junio C Hamano wrote:\n> >    It may help reducing the maintenance if we introduced obj_size_t\n> >    that is defined to be size_t for now, so that we can later swap\n> >    it to ofs_t or some larger type when we know we do need to\n> >    support objects whose size cannot be expressed in size_t, but I\n> >    do not offhand know what the pros-and-cons with such an approach\n> >    would look like.\n> \n> Where should the use of obj_size_t end and the use of size_t start? \n> \n> We often determine a object size and then pass it to malloc. \n> We would start with a larger datatyp and then truncate for memory allocation, which use size_t.\n\nThe truncation is done with xsize_t:\nThe \"old\" sha1_file.c has something like this:\n    idx_size = xsize_t(st.st_size);\n\nI personally don't think that obj_size_t gives us so much.\nThere are \"objects\" which are \"on disk\", and they may have a length off_t,\nAnd there are \"objects\" loaded into memory, and they have a length size_t.\nAnd everybody can check that we use the right type.\nAdditionally I don't like it very much, when object size in memory is counted\nin a 64 bit value (and this will happen if  obj_size_ = off_t == 64bit)\n\nAnyhow, to answer your question:\nAll calles xmalloc() must be prepared like this:\n\np = xmalloc(xsize_t(size_of_object));\n\nThat should do the trick.\n\n> \n> Regards,\n> Martin\n"}]}