git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 5/9] Convert sha1_file.c to size_t
@ 2017-08-10 19:25 Martin Koegler
  2017-08-10 19:25 ` [PATCH 6/9] Use size_t for sha1 Martin Koegler
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Martin Koegler @ 2017-08-10 19:25 UTC (permalink / raw)
  To: git, gitster, Johannes.Schindelin; +Cc: Martin Koegler

From: Martin Koegler <martin.koegler@chello.at>

Signed-off-by: Martin Koegler <martin.koegler@chello.at>
---
 cache.h     | 16 +++++++--------
 sha1_file.c | 68 ++++++++++++++++++++++++++++++-------------------------------
 streaming.c |  2 +-
 3 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/cache.h b/cache.h
index 9185763..9322303 100644
--- a/cache.h
+++ b/cache.h
@@ -1189,15 +1189,15 @@ static inline const unsigned char *lookup_replace_object(const unsigned char *sh
 
 /* Read and unpack a sha1 file into memory, write memory to a sha1 file */
 extern int sha1_object_info(const unsigned char *, size_t *);
-extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);
-extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
-extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, unsigned char *sha1, unsigned flags);
-extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
+extern int hash_sha1_file(const void *buf, size_t len, const char *type, unsigned char *sha1);
+extern int write_sha1_file(const void *buf, size_t len, const char *type, unsigned char *return_sha1);
+extern int hash_sha1_file_literally(const void *buf, size_t len, const char *type, unsigned char *sha1, unsigned flags);
+extern int pretend_sha1_file(void *, size_t, enum object_type, unsigned char *);
 extern int force_object_loose(const unsigned char *sha1, time_t mtime);
 extern int git_open_cloexec(const char *name, int flags);
 #define git_open(name) git_open_cloexec(name, O_RDONLY)
-extern void *map_sha1_file(const unsigned char *sha1, unsigned long *size);
-extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);
+extern void *map_sha1_file(const unsigned char *sha1, size_t *size);
+extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, size_t mapsize, void *buffer, size_t bufsiz);
 extern int parse_sha1_header(const char *hdr, size_t *sizep);
 
 /* global flag to enable extra checks when accessing packed objects */
@@ -1723,8 +1723,8 @@ extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *)
 
 extern int is_pack_valid(struct packed_git *);
 extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, size_t *);
-extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, size_t *sizep);
-extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
+extern size_t unpack_object_header_buffer(const unsigned char *buf, size_t len, enum object_type *type, size_t *sizep);
+extern size_t get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
 extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, size_t *);
 
 /*
diff --git a/sha1_file.c b/sha1_file.c
index 3428172..1b3efea 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -51,7 +51,7 @@ static struct cached_object {
 	unsigned char sha1[20];
 	enum object_type type;
 	void *buf;
-	unsigned long size;
+	size_t size;
 } *cached_objects;
 static int cached_object_nr, cached_object_alloc;
 
@@ -818,8 +818,8 @@ static int check_packed_git_idx(const char *path, struct packed_git *p)
 		 * variable sized table containing 8-byte entries
 		 * for offsets larger than 2^31.
 		 */
-		unsigned long min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;
-		unsigned long max_size = min_size;
+		size_t min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;
+		size_t max_size = min_size;
 		if (nr)
 			max_size += (nr - 1)*8;
 		if (idx_size < min_size || idx_size > max_size) {
@@ -1763,7 +1763,7 @@ static int open_sha1_file(const unsigned char *sha1, const char **path)
  */
 static void *map_sha1_file_1(const char *path,
 			     const unsigned char *sha1,
-			     unsigned long *size)
+			     size_t *size)
 {
 	void *map;
 	int fd;
@@ -1790,13 +1790,13 @@ static void *map_sha1_file_1(const char *path,
 	return map;
 }
 
-void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
+void *map_sha1_file(const unsigned char *sha1, size_t *size)
 {
 	return map_sha1_file_1(NULL, sha1, size);
 }
 
-unsigned long unpack_object_header_buffer(const unsigned char *buf,
-		unsigned long len, enum object_type *type, size_t *sizep)
+size_t unpack_object_header_buffer(const unsigned char *buf,
+				   size_t len, enum object_type *type, size_t *sizep)
 {
 	unsigned shift;
 	size_t size, c;
@@ -1821,8 +1821,8 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,
 }
 
 static int unpack_sha1_short_header(git_zstream *stream,
-				    unsigned char *map, unsigned long mapsize,
-				    void *buffer, unsigned long bufsiz)
+				    unsigned char *map, size_t mapsize,
+				    void *buffer, size_t bufsiz)
 {
 	/* Get the data stream */
 	memset(stream, 0, sizeof(*stream));
@@ -1836,8 +1836,8 @@ static int unpack_sha1_short_header(git_zstream *stream,
 }
 
 int unpack_sha1_header(git_zstream *stream,
-		       unsigned char *map, unsigned long mapsize,
-		       void *buffer, unsigned long bufsiz)
+		       unsigned char *map, size_t mapsize,
+		       void *buffer, size_t bufsiz)
 {
 	int status = unpack_sha1_short_header(stream, map, mapsize,
 					      buffer, bufsiz);
@@ -1852,8 +1852,8 @@ int unpack_sha1_header(git_zstream *stream,
 }
 
 static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,
-					unsigned long mapsize, void *buffer,
-					unsigned long bufsiz, struct strbuf *header)
+					size_t mapsize, void *buffer,
+					size_t bufsiz, struct strbuf *header)
 {
 	int status;
 
@@ -1887,11 +1887,11 @@ static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,
 	return -1;
 }
 
-static void *unpack_sha1_rest(git_zstream *stream, void *buffer, unsigned long size, const unsigned char *sha1)
+static void *unpack_sha1_rest(git_zstream *stream, void *buffer, size_t size, const unsigned char *sha1)
 {
 	int bytes = strlen(buffer) + 1;
 	unsigned char *buf = xmallocz(size);
-	unsigned long n;
+	size_t n;
 	int status = Z_OK;
 
 	n = stream->total_out - bytes;
@@ -1941,7 +1941,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,
 			       unsigned int flags)
 {
 	const char *type_buf = hdr;
-	unsigned long size;
+	size_t size;
 	int type, type_len = 0;
 
 	/*
@@ -2006,9 +2006,9 @@ int parse_sha1_header(const char *hdr, size_t *sizep)
 	return parse_sha1_header_extended(hdr, &oi, 0);
 }
 
-unsigned long get_size_from_delta(struct packed_git *p,
-				  struct pack_window **w_curs,
-			          off_t curpos)
+size_t get_size_from_delta(struct packed_git *p,
+			   struct pack_window **w_curs,
+			   off_t curpos)
 {
 	const unsigned char *data;
 	unsigned char delta_head[20], *in;
@@ -2242,7 +2242,7 @@ struct delta_base_cache_entry {
 	struct delta_base_cache_key key;
 	struct list_head lru;
 	void *data;
-	unsigned long size;
+	size_t size;
 	enum object_type type;
 };
 
@@ -2339,7 +2339,7 @@ void clear_delta_base_cache(void)
 }
 
 static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
-	void *base, unsigned long base_size, enum object_type type)
+	void *base, size_t base_size, enum object_type type)
 {
 	struct delta_base_cache_entry *ent = xmalloc(sizeof(*ent));
 	struct list_head *lru, *tmp;
@@ -2453,7 +2453,7 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,
 static void *unpack_compressed_entry(struct packed_git *p,
 				    struct pack_window **w_curs,
 				    off_t curpos,
-				    unsigned long size)
+				    size_t size)
 {
 	int st;
 	git_zstream stream;
@@ -2500,7 +2500,7 @@ int do_check_packed_object_crc;
 struct unpack_entry_stack_ent {
 	off_t obj_offset;
 	off_t curpos;
-	unsigned long size;
+	size_t size;
 };
 
 void *unpack_entry(struct packed_git *p, off_t obj_offset,
@@ -2909,7 +2909,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,
 				  int flags)
 {
 	int status = 0;
-	unsigned long mapsize;
+	size_t mapsize;
 	void *map;
 	git_zstream stream;
 	char hdr[32];
@@ -3088,7 +3088,7 @@ static void *read_packed_sha1(const unsigned char *sha1,
 	return data;
 }
 
-int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,
+int pretend_sha1_file(void *buf, size_t len, enum object_type type,
 		      unsigned char *sha1)
 {
 	struct cached_object *co;
@@ -3209,14 +3209,14 @@ void *read_object_with_reference(const unsigned char *sha1,
 	}
 }
 
-static void write_sha1_file_prepare(const void *buf, unsigned long len,
+static void write_sha1_file_prepare(const void *buf, size_t len,
                                     const char *type, unsigned char *sha1,
                                     char *hdr, int *hdrlen)
 {
 	git_SHA_CTX c;
 
 	/* Generate the header */
-	*hdrlen = xsnprintf(hdr, *hdrlen, "%s %lu", type, len)+1;
+	*hdrlen = xsnprintf(hdr, *hdrlen, "%s %" PRIuMAX, type, (uintmax_t)len)+1;
 
 	/* Sha1.. */
 	git_SHA1_Init(&c);
@@ -3275,7 +3275,7 @@ static int write_buffer(int fd, const void *buf, size_t len)
 	return 0;
 }
 
-int hash_sha1_file(const void *buf, unsigned long len, const char *type,
+int hash_sha1_file(const void *buf, size_t len, const char *type,
                    unsigned char *sha1)
 {
 	char hdr[32];
@@ -3339,7 +3339,7 @@ static int create_tmpfile(struct strbuf *tmp, const char *filename)
 }
 
 static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
-			      const void *buf, unsigned long len, time_t mtime)
+			      const void *buf, size_t len, time_t mtime)
 {
 	int fd, ret;
 	unsigned char compressed[4096];
@@ -3423,7 +3423,7 @@ static int freshen_packed_object(const unsigned char *sha1)
 	return 1;
 }
 
-int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1)
+int write_sha1_file(const void *buf, size_t len, const char *type, unsigned char *sha1)
 {
 	char hdr[32];
 	int hdrlen = sizeof(hdr);
@@ -3437,7 +3437,7 @@ int write_sha1_file(const void *buf, unsigned long len, const char *type, unsign
 	return write_loose_object(sha1, hdr, hdrlen, buf, len, 0);
 }
 
-int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type,
+int hash_sha1_file_literally(const void *buf, size_t len, const char *type,
 			     unsigned char *sha1, unsigned flags)
 {
 	char *header;
@@ -3929,14 +3929,14 @@ int for_each_packed_object(each_packed_object_fn cb, void *data, unsigned flags)
 
 static int check_stream_sha1(git_zstream *stream,
 			     const char *hdr,
-			     unsigned long size,
+			     size_t size,
 			     const char *path,
 			     const unsigned char *expected_sha1)
 {
 	git_SHA_CTX c;
 	unsigned char real_sha1[GIT_MAX_RAWSZ];
 	unsigned char buf[4096];
-	unsigned long total_read;
+	size_t total_read;
 	int status = Z_OK;
 
 	git_SHA1_Init(&c);
@@ -3992,7 +3992,7 @@ int read_loose_object(const char *path,
 {
 	int ret = -1;
 	void *map = NULL;
-	unsigned long mapsize;
+	size_t mapsize;
 	git_zstream stream;
 	char hdr[32];
 
diff --git a/streaming.c b/streaming.c
index 04a8b99..448c4aa 100644
--- a/streaming.c
+++ b/streaming.c
@@ -77,7 +77,7 @@ struct git_istream {
 
 		struct {
 			void *mapped;
-			unsigned long mapsize;
+			size_t mapsize;
 			char hdr[32];
 			int hdr_avail;
 			int hdr_used;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 6/9] Use size_t for sha1
  2017-08-10 19:25 [PATCH 5/9] Convert sha1_file.c to size_t Martin Koegler
@ 2017-08-10 19:25 ` Martin Koegler
  2017-08-10 19:25 ` [PATCH 8/9] Convert fsck.c & commit.c to size_t Martin Koegler
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Martin Koegler @ 2017-08-10 19:25 UTC (permalink / raw)
  To: git, gitster, Johannes.Schindelin; +Cc: Martin Koegler

From: Martin Koegler <martin.koegler@chello.at>

Signed-off-by: Martin Koegler <martin.koegler@chello.at>
---
 block-sha1/sha1.c | 2 +-
 block-sha1/sha1.h | 2 +-
 ppc/sha1.c        | 2 +-
 ppc/sha1.h        | 2 +-
 sha1dc_git.c      | 2 +-
 sha1dc_git.h      | 2 +-
 sha1dc_git_ext.h  | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c
index 22b125c..8681031 100644
--- a/block-sha1/sha1.c
+++ b/block-sha1/sha1.c
@@ -203,7 +203,7 @@ void blk_SHA1_Init(blk_SHA_CTX *ctx)
 	ctx->H[4] = 0xc3d2e1f0;
 }
 
-void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, unsigned long len)
+void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *data, size_t len)
 {
 	unsigned int lenW = ctx->size & 63;
 
diff --git a/block-sha1/sha1.h b/block-sha1/sha1.h
index 4df6747..9fb0441 100644
--- a/block-sha1/sha1.h
+++ b/block-sha1/sha1.h
@@ -13,7 +13,7 @@ typedef struct {
 } blk_SHA_CTX;
 
 void blk_SHA1_Init(blk_SHA_CTX *ctx);
-void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, unsigned long len);
+void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, size_t len);
 void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx);
 
 #define platform_SHA_CTX	blk_SHA_CTX
diff --git a/ppc/sha1.c b/ppc/sha1.c
index ec6a192..f0dfcfb 100644
--- a/ppc/sha1.c
+++ b/ppc/sha1.c
@@ -25,7 +25,7 @@ int ppc_SHA1_Init(ppc_SHA_CTX *c)
 	return 0;
 }
 
-int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *ptr, unsigned long n)
+int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *ptr, size_t n)
 {
 	unsigned long nb;
 	const unsigned char *p = ptr;
diff --git a/ppc/sha1.h b/ppc/sha1.h
index 9b24b32..52cac23 100644
--- a/ppc/sha1.h
+++ b/ppc/sha1.h
@@ -16,7 +16,7 @@ typedef struct {
 } ppc_SHA_CTX;
 
 int ppc_SHA1_Init(ppc_SHA_CTX *c);
-int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *p, unsigned long n);
+int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *p, size_t n);
 int ppc_SHA1_Final(unsigned char *hash, ppc_SHA_CTX *c);
 
 #define platform_SHA_CTX	ppc_SHA_CTX
diff --git a/sha1dc_git.c b/sha1dc_git.c
index 4d32b4f..a9076bc 100644
--- a/sha1dc_git.c
+++ b/sha1dc_git.c
@@ -11,7 +11,7 @@ void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)
 	    sha1_to_hex(hash));
 }
 
-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)
+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, size_t len)
 {
 	const char *data = vdata;
 	/* We expect an unsigned long, but sha1dc only takes an int */
diff --git a/sha1dc_git.h b/sha1dc_git.h
index a8a5c1d..f6051aa 100644
--- a/sha1dc_git.h
+++ b/sha1dc_git.h
@@ -11,7 +11,7 @@ void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);
 /*
  * Same as SHA1DCUpdate, but adjust types to match git's usual interface.
  */
-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);
+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, size_t len);
 
 #define platform_SHA_CTX SHA1_CTX
 #define platform_SHA1_Init SHA1DCInit
diff --git a/sha1dc_git_ext.h b/sha1dc_git_ext.h
index d0ea8ce..aede828 100644
--- a/sha1dc_git_ext.h
+++ b/sha1dc_git_ext.h
@@ -17,7 +17,7 @@ void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);
 /*
  * Same as SHA1DCUpdate, but adjust types to match git's usual interface.
  */
-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);
+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, size_t len);
 
 #define platform_SHA_CTX SHA1_CTX
 #define platform_SHA1_Init git_SHA1DCInit
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 8/9] Convert fsck.c & commit.c to size_t
  2017-08-10 19:25 [PATCH 5/9] Convert sha1_file.c to size_t Martin Koegler
  2017-08-10 19:25 ` [PATCH 6/9] Use size_t for sha1 Martin Koegler
@ 2017-08-10 19:25 ` Martin Koegler
  2017-08-10 19:25 ` [PATCH 9/9] Convert cache functions " Martin Koegler
  2017-08-10 22:27 ` [PATCH 5/9] Convert sha1_file.c " Junio C Hamano
  3 siblings, 0 replies; 6+ messages in thread
From: Martin Koegler @ 2017-08-10 19:25 UTC (permalink / raw)
  To: git, gitster, Johannes.Schindelin; +Cc: Martin Koegler

From: Martin Koegler <martin.koegler@chello.at>

Signed-off-by: Martin Koegler <martin.koegler@chello.at>
---
 builtin/replace.c |  2 +-
 commit.c          | 14 +++++++-------
 commit.h          |  8 ++++----
 fsck.c            | 14 +++++++-------
 fsck.h            |  2 +-
 5 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/builtin/replace.c b/builtin/replace.c
index f4a85a1..dcd0d1e 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -391,7 +391,7 @@ static int create_graft(int argc, const char **argv, int force)
 	struct commit *commit;
 	struct strbuf buf = STRBUF_INIT;
 	const char *buffer;
-	unsigned long size;
+	size_t size;
 
 	if (get_oid(old_ref, &old) < 0)
 		die(_("Not a valid object name: '%s'"), old_ref);
diff --git a/commit.c b/commit.c
index 79decc2..5ebac6a 100644
--- a/commit.c
+++ b/commit.c
@@ -231,19 +231,19 @@ int unregister_shallow(const struct object_id *oid)
 
 struct commit_buffer {
 	void *buffer;
-	unsigned long size;
+	size_t size;
 };
 define_commit_slab(buffer_slab, struct commit_buffer);
 static struct buffer_slab buffer_slab = COMMIT_SLAB_INIT(1, buffer_slab);
 
-void set_commit_buffer(struct commit *commit, void *buffer, unsigned long size)
+void set_commit_buffer(struct commit *commit, void *buffer, size_t size)
 {
 	struct commit_buffer *v = buffer_slab_at(&buffer_slab, commit);
 	v->buffer = buffer;
 	v->size = size;
 }
 
-const void *get_cached_commit_buffer(const struct commit *commit, unsigned long *sizep)
+const void *get_cached_commit_buffer(const struct commit *commit, size_t *sizep)
 {
 	struct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);
 	if (!v) {
@@ -256,7 +256,7 @@ const void *get_cached_commit_buffer(const struct commit *commit, unsigned long
 	return v->buffer;
 }
 
-const void *get_commit_buffer(const struct commit *commit, unsigned long *sizep)
+const void *get_commit_buffer(const struct commit *commit, size_t *sizep)
 {
 	const void *ret = get_cached_commit_buffer(commit, sizep);
 	if (!ret) {
@@ -291,7 +291,7 @@ void free_commit_buffer(struct commit *commit)
 	}
 }
 
-const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)
+const void *detach_commit_buffer(struct commit *commit, size_t *sizep)
 {
 	struct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);
 	void *ret;
@@ -1128,7 +1128,7 @@ int parse_signed_commit(const struct commit *commit,
 			struct strbuf *payload, struct strbuf *signature)
 {
 
-	unsigned long size;
+	size_t size;
 	const char *buffer = get_commit_buffer(commit, &size);
 	int in_signature, saw_signature = -1;
 	const char *line, *tail;
@@ -1284,7 +1284,7 @@ struct commit_extra_header *read_commit_extra_headers(struct commit *commit,
 						      const char **exclude)
 {
 	struct commit_extra_header *extra = NULL;
-	unsigned long size;
+	size_t size;
 	const char *buffer = get_commit_buffer(commit, &size);
 	extra = read_commit_extra_header_lines(buffer, size, exclude);
 	unuse_commit_buffer(commit, buffer);
diff --git a/commit.h b/commit.h
index 82e966e..fd44de3 100644
--- a/commit.h
+++ b/commit.h
@@ -70,20 +70,20 @@ void parse_commit_or_die(struct commit *item);
  * Associate an object buffer with the commit. The ownership of the
  * memory is handed over to the commit, and must be free()-able.
  */
-void set_commit_buffer(struct commit *, void *buffer, unsigned long size);
+void set_commit_buffer(struct commit *, void *buffer, size_t size);
 
 /*
  * Get any cached object buffer associated with the commit. Returns NULL
  * if none. The resulting memory should not be freed.
  */
-const void *get_cached_commit_buffer(const struct commit *, unsigned long *size);
+const void *get_cached_commit_buffer(const struct commit *, size_t *size);
 
 /*
  * Get the commit's object contents, either from cache or by reading the object
  * from disk. The resulting memory should not be modified, and must be given
  * to unuse_commit_buffer when the caller is done.
  */
-const void *get_commit_buffer(const struct commit *, unsigned long *size);
+const void *get_commit_buffer(const struct commit *, size_t *size);
 
 /*
  * Tell the commit subsytem that we are done with a particular commit buffer.
@@ -102,7 +102,7 @@ void free_commit_buffer(struct commit *);
  * Disassociate any cached object buffer from the commit, but do not free it.
  * The buffer (or NULL, if none) is returned.
  */
-const void *detach_commit_buffer(struct commit *, unsigned long *sizep);
+const void *detach_commit_buffer(struct commit *, size_t *sizep);
 
 /* Find beginning and length of commit subject. */
 int find_commit_subject(const char *commit_buffer, const char **subject);
diff --git a/fsck.c b/fsck.c
index feca3a8..9039373 100644
--- a/fsck.c
+++ b/fsck.c
@@ -632,18 +632,18 @@ static int fsck_tree(struct tree *item, struct fsck_options *options)
 	return retval;
 }
 
-static int verify_headers(const void *data, unsigned long size,
+static int verify_headers(const void *data, size_t size,
 			  struct object *obj, struct fsck_options *options)
 {
 	const char *buffer = (const char *)data;
-	unsigned long i;
+	size_t i;
 
 	for (i = 0; i < size; i++) {
 		switch (buffer[i]) {
 		case '\0':
 			return report(options, obj,
 				FSCK_MSG_NUL_IN_HEADER,
-				"unterminated header: NUL at offset %ld", i);
+				"unterminated header: NUL at offset %" PRIuMAX, (uintmax_t)i);
 		case '\n':
 			if (i + 1 < size && buffer[i + 1] == '\n')
 				return 0;
@@ -708,7 +708,7 @@ static int fsck_ident(const char **ident, struct object *obj, struct fsck_option
 }
 
 static int fsck_commit_buffer(struct commit *commit, const char *buffer,
-	unsigned long size, struct fsck_options *options)
+	size_t size, struct fsck_options *options)
 {
 	unsigned char tree_sha1[20], sha1[20];
 	struct commit_graft *graft;
@@ -786,7 +786,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
 }
 
 static int fsck_commit(struct commit *commit, const char *data,
-	unsigned long size, struct fsck_options *options)
+	size_t size, struct fsck_options *options)
 {
 	const char *buffer = data ?  data : get_commit_buffer(commit, &size);
 	int ret = fsck_commit_buffer(commit, buffer, size, options);
@@ -890,7 +890,7 @@ static int fsck_tag_buffer(struct tag *tag, const char *data,
 }
 
 static int fsck_tag(struct tag *tag, const char *data,
-	unsigned long size, struct fsck_options *options)
+	size_t size, struct fsck_options *options)
 {
 	struct object *tagged = tag->tagged;
 
@@ -900,7 +900,7 @@ static int fsck_tag(struct tag *tag, const char *data,
 	return fsck_tag_buffer(tag, data, size, options);
 }
 
-int fsck_object(struct object *obj, void *data, unsigned long size,
+int fsck_object(struct object *obj, void *data, size_t size,
 	struct fsck_options *options)
 {
 	if (!obj)
diff --git a/fsck.h b/fsck.h
index 4525510..3de5807 100644
--- a/fsck.h
+++ b/fsck.h
@@ -50,7 +50,7 @@ struct fsck_options {
  */
 int fsck_walk(struct object *obj, void *data, struct fsck_options *options);
 /* If NULL is passed for data, we assume the object is local and read it. */
-int fsck_object(struct object *obj, void *data, unsigned long size,
+int fsck_object(struct object *obj, void *data, size_t size,
 	struct fsck_options *options);
 
 #endif
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 9/9] Convert cache functions to size_t
  2017-08-10 19:25 [PATCH 5/9] Convert sha1_file.c to size_t Martin Koegler
  2017-08-10 19:25 ` [PATCH 6/9] Use size_t for sha1 Martin Koegler
  2017-08-10 19:25 ` [PATCH 8/9] Convert fsck.c & commit.c to size_t Martin Koegler
@ 2017-08-10 19:25 ` Martin Koegler
  2017-08-10 22:27 ` [PATCH 5/9] Convert sha1_file.c " Junio C Hamano
  3 siblings, 0 replies; 6+ messages in thread
From: Martin Koegler @ 2017-08-10 19:25 UTC (permalink / raw)
  To: git, gitster, Johannes.Schindelin; +Cc: Martin Koegler

From: Martin Koegler <martin.koegler@chello.at>

Signed-off-by: Martin Koegler <martin.koegler@chello.at>
---
 cache-tree.c  |  6 +++---
 cache-tree.h  |  2 +-
 cache.h       |  6 +++---
 convert.c     | 18 +++++++++---------
 environment.c |  4 ++--
 read-cache.c  | 18 +++++++++---------
 6 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/cache-tree.c b/cache-tree.c
index 2440d1d..77b3253 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -485,10 +485,10 @@ void cache_tree_write(struct strbuf *sb, struct cache_tree *root)
 	write_one(sb, root, "", 0);
 }
 
-static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
+static struct cache_tree *read_one(const char **buffer, size_t *size_p)
 {
 	const char *buf = *buffer;
-	unsigned long size = *size_p;
+	size_t size = *size_p;
 	const char *cp;
 	char *ep;
 	struct cache_tree *it;
@@ -568,7 +568,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
 	return NULL;
 }
 
-struct cache_tree *cache_tree_read(const char *buffer, unsigned long size)
+struct cache_tree *cache_tree_read(const char *buffer, size_t size)
 {
 	if (buffer[0])
 		return NULL; /* not the whole tree */
diff --git a/cache-tree.h b/cache-tree.h
index f7b9cab..df59e6e 100644
--- a/cache-tree.h
+++ b/cache-tree.h
@@ -28,7 +28,7 @@ void cache_tree_invalidate_path(struct index_state *, const char *);
 struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *);
 
 void cache_tree_write(struct strbuf *, struct cache_tree *root);
-struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
+struct cache_tree *cache_tree_read(const char *buffer, size_t size);
 
 int cache_tree_fully_valid(struct cache_tree *);
 int cache_tree_update(struct index_state *, int);
diff --git a/cache.h b/cache.h
index 9322303..f77d9ec 100644
--- a/cache.h
+++ b/cache.h
@@ -667,7 +667,7 @@ extern int chmod_index_entry(struct index_state *, struct cache_entry *ce, char
 extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b);
 extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce);
 extern int index_name_is_other(const struct index_state *, const char *, int);
-extern void *read_blob_data_from_index(const struct index_state *, const char *, unsigned long *);
+extern void *read_blob_data_from_index(const struct index_state *, const char *, size_t *);
 
 /* do stat comparison even if CE_VALID is true */
 #define CE_MATCH_IGNORE_VALID		01
@@ -743,8 +743,8 @@ extern int pack_compression_level;
 extern size_t packed_git_window_size;
 extern size_t packed_git_limit;
 extern size_t delta_base_cache_limit;
-extern unsigned long big_file_threshold;
-extern unsigned long pack_size_limit_cfg;
+extern size_t big_file_threshold;
+extern size_t pack_size_limit_cfg;
 
 /*
  * Accessors for the core.sharedrepository config which lazy-load the value
diff --git a/convert.c b/convert.c
index 1012462..445599b 100644
--- a/convert.c
+++ b/convert.c
@@ -41,9 +41,9 @@ struct text_stat {
 	unsigned printable, nonprintable;
 };
 
-static void gather_stats(const char *buf, unsigned long size, struct text_stat *stats)
+static void gather_stats(const char *buf, size_t size, struct text_stat *stats)
 {
-	unsigned long i;
+	size_t i;
 
 	memset(stats, 0, sizeof(*stats));
 
@@ -90,7 +90,7 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *
  * The same heuristics as diff.c::mmfile_is_binary()
  * We treat files with bare CR as binary
  */
-static int convert_is_binary(unsigned long size, const struct text_stat *stats)
+static int convert_is_binary(size_t size, const struct text_stat *stats)
 {
 	if (stats->lonecr)
 		return 1;
@@ -101,7 +101,7 @@ static int convert_is_binary(unsigned long size, const struct text_stat *stats)
 	return 0;
 }
 
-static unsigned int gather_convert_stats(const char *data, unsigned long size)
+static unsigned int gather_convert_stats(const char *data, size_t size)
 {
 	struct text_stat stats;
 	int ret = 0;
@@ -118,7 +118,7 @@ static unsigned int gather_convert_stats(const char *data, unsigned long size)
 	return ret;
 }
 
-static const char *gather_convert_stats_ascii(const char *data, unsigned long size)
+static const char *gather_convert_stats_ascii(const char *data, size_t size)
 {
 	unsigned int convert_stats = gather_convert_stats(data, size);
 
@@ -140,7 +140,7 @@ const char *get_cached_convert_stats_ascii(const struct index_state *istate,
 					   const char *path)
 {
 	const char *ret;
-	unsigned long sz;
+	size_t sz;
 	void *data = read_blob_data_from_index(istate, path, &sz);
 	ret = gather_convert_stats_ascii(data, sz);
 	free(data);
@@ -222,7 +222,7 @@ static void check_safe_crlf(const char *path, enum crlf_action crlf_action,
 
 static int has_cr_in_index(const struct index_state *istate, const char *path)
 {
-	unsigned long sz;
+	size_t sz;
 	void *data;
 	int has_cr;
 
@@ -384,7 +384,7 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,
 
 struct filter_params {
 	const char *src;
-	unsigned long size;
+	size_t size;
 	int fd;
 	const char *cmd;
 	const char *path;
@@ -798,7 +798,7 @@ static int read_convert_config(const char *var, const char *value, void *cb)
 	return 0;
 }
 
-static int count_ident(const char *cp, unsigned long size)
+static int count_ident(const char *cp, size_t size)
 {
 	/*
 	 * "$Id: 0000000000000000000000000000000000000000 $" <=> "$Id$"
diff --git a/environment.c b/environment.c
index 3fd4b10..7cf201f 100644
--- a/environment.c
+++ b/environment.c
@@ -40,7 +40,7 @@ int fsync_object_files;
 size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
 size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
 size_t delta_base_cache_limit = 96 * 1024 * 1024;
-unsigned long big_file_threshold = 512 * 1024 * 1024;
+size_t big_file_threshold = 512 * 1024 * 1024;
 int pager_use_color = 1;
 const char *editor_program;
 const char *askpass_program;
@@ -63,7 +63,7 @@ int grafts_replace_parents = 1;
 int core_apply_sparse_checkout;
 int merge_log_config = -1;
 int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
-unsigned long pack_size_limit_cfg;
+size_t pack_size_limit_cfg;
 enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
 enum log_refs_config log_all_ref_updates = LOG_REFS_UNSET;
 
diff --git a/read-cache.c b/read-cache.c
index 854a5d6..8a32619 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1509,7 +1509,7 @@ struct ondisk_cache_entry_extended {
 /* Allow fsck to force verification of the index checksum. */
 int verify_index_checksum;
 
-static int verify_hdr(struct cache_header *hdr, unsigned long size)
+static int verify_hdr(struct cache_header *hdr, size_t size)
 {
 	git_SHA_CTX c;
 	unsigned char sha1[20];
@@ -1533,7 +1533,7 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
 }
 
 static int read_index_extension(struct index_state *istate,
-				const char *ext, void *data, unsigned long sz)
+				const char *ext, void *data, size_t sz)
 {
 	switch (CACHE_EXT(ext)) {
 	case CACHE_EXT_TREE:
@@ -1602,7 +1602,7 @@ static struct cache_entry *cache_entry_from_ondisk(struct ondisk_cache_entry *on
  * number of bytes to be stripped from the end of the previous name,
  * and the bytes to append to the result, to come up with its name.
  */
-static unsigned long expand_name_field(struct strbuf *name, const char *cp_)
+static size_t expand_name_field(struct strbuf *name, const char *cp_)
 {
 	const unsigned char *ep, *cp = (const unsigned char *)cp_;
 	size_t len = decode_varint(&cp);
@@ -1617,7 +1617,7 @@ static unsigned long expand_name_field(struct strbuf *name, const char *cp_)
 }
 
 static struct cache_entry *create_from_disk(struct ondisk_cache_entry *ondisk,
-					    unsigned long *ent_size,
+					    size_t *ent_size,
 					    struct strbuf *previous_name)
 {
 	struct cache_entry *ce;
@@ -1651,7 +1651,7 @@ static struct cache_entry *create_from_disk(struct ondisk_cache_entry *ondisk,
 
 		*ent_size = ondisk_ce_size(ce);
 	} else {
-		unsigned long consumed;
+		size_t consumed;
 		consumed = expand_name_field(previous_name, name);
 		ce = cache_entry_from_ondisk(ondisk, flags,
 					     previous_name->buf,
@@ -1728,7 +1728,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 {
 	int fd, i;
 	struct stat st;
-	unsigned long src_offset;
+	size_t src_offset;
 	struct cache_header *hdr;
 	void *mmap;
 	size_t mmap_size;
@@ -1778,7 +1778,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
 	for (i = 0; i < istate->cache_nr; i++) {
 		struct ondisk_cache_entry *disk_ce;
 		struct cache_entry *ce;
-		unsigned long consumed;
+		size_t consumed;
 
 		disk_ce = (struct ondisk_cache_entry *)((char *)mmap + src_offset);
 		ce = create_from_disk(disk_ce, &consumed, previous_name);
@@ -1914,7 +1914,7 @@ int unmerged_index(const struct index_state *istate)
 
 #define WRITE_BUFFER_SIZE 8192
 static unsigned char write_buffer[WRITE_BUFFER_SIZE];
-static unsigned long write_buffer_len;
+static size_t write_buffer_len;
 
 static int ce_write_flush(git_SHA_CTX *context, int fd)
 {
@@ -2580,7 +2580,7 @@ int index_name_is_other(const struct index_state *istate, const char *name,
 }
 
 void *read_blob_data_from_index(const struct index_state *istate,
-				const char *path, unsigned long *size)
+				const char *path, size_t *size)
 {
 	int pos, len;
 	size_t sz;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 5/9] Convert sha1_file.c to size_t
  2017-08-10 19:25 [PATCH 5/9] Convert sha1_file.c to size_t Martin Koegler
                   ` (2 preceding siblings ...)
  2017-08-10 19:25 ` [PATCH 9/9] Convert cache functions " Martin Koegler
@ 2017-08-10 22:27 ` Junio C Hamano
  2017-08-11  7:06   ` Martin Koegler
  3 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2017-08-10 22:27 UTC (permalink / raw)
  To: Martin Koegler; +Cc: git, Johannes.Schindelin

Martin Koegler <martin.koegler@chello.at> writes:

> From: Martin Koegler <martin.koegler@chello.at>
>
> Signed-off-by: Martin Koegler <martin.koegler@chello.at>
> ---

Please do not start your patch series from 5/9 when there is no 1/9,
2/9, 3/9, and 4/9.  It is seriously confusing.

I am guessing that you are trying to split the series into
manageable pieces by going per call graph and codeflow.  I think it
is a more sensible approach than a single huge ball of wax we saw
earlier.

It may take me a while to get back to this topic before I finish
reviewing other new topics in flight and also merging down existing
topics so that the codebase will become reasonably stable for a
topic that is invasive like this one can safely land.  Please be
patient.

Thanks.

>  cache.h     | 16 +++++++--------
>  sha1_file.c | 68 ++++++++++++++++++++++++++++++-------------------------------
>  streaming.c |  2 +-
>  3 files changed, 43 insertions(+), 43 deletions(-)
>
> diff --git a/cache.h b/cache.h
> index 9185763..9322303 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -1189,15 +1189,15 @@ static inline const unsigned char *lookup_replace_object(const unsigned char *sh
>  
>  /* Read and unpack a sha1 file into memory, write memory to a sha1 file */
>  extern int sha1_object_info(const unsigned char *, size_t *);
> -extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);
> -extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
> -extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, unsigned char *sha1, unsigned flags);
> -extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
> +extern int hash_sha1_file(const void *buf, size_t len, const char *type, unsigned char *sha1);
> +extern int write_sha1_file(const void *buf, size_t len, const char *type, unsigned char *return_sha1);
> +extern int hash_sha1_file_literally(const void *buf, size_t len, const char *type, unsigned char *sha1, unsigned flags);
> +extern int pretend_sha1_file(void *, size_t, enum object_type, unsigned char *);
>  extern int force_object_loose(const unsigned char *sha1, time_t mtime);
>  extern int git_open_cloexec(const char *name, int flags);
>  #define git_open(name) git_open_cloexec(name, O_RDONLY)
> -extern void *map_sha1_file(const unsigned char *sha1, unsigned long *size);
> -extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);
> +extern void *map_sha1_file(const unsigned char *sha1, size_t *size);
> +extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, size_t mapsize, void *buffer, size_t bufsiz);
>  extern int parse_sha1_header(const char *hdr, size_t *sizep);
>  
>  /* global flag to enable extra checks when accessing packed objects */
> @@ -1723,8 +1723,8 @@ extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *)
>  
>  extern int is_pack_valid(struct packed_git *);
>  extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, size_t *);
> -extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, size_t *sizep);
> -extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
> +extern size_t unpack_object_header_buffer(const unsigned char *buf, size_t len, enum object_type *type, size_t *sizep);
> +extern size_t get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
>  extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, size_t *);
>  
>  /*
> diff --git a/sha1_file.c b/sha1_file.c
> index 3428172..1b3efea 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -51,7 +51,7 @@ static struct cached_object {
>  	unsigned char sha1[20];
>  	enum object_type type;
>  	void *buf;
> -	unsigned long size;
> +	size_t size;
>  } *cached_objects;
>  static int cached_object_nr, cached_object_alloc;
>  
> @@ -818,8 +818,8 @@ static int check_packed_git_idx(const char *path, struct packed_git *p)
>  		 * variable sized table containing 8-byte entries
>  		 * for offsets larger than 2^31.
>  		 */
> -		unsigned long min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;
> -		unsigned long max_size = min_size;
> +		size_t min_size = 8 + 4*256 + nr*(20 + 4 + 4) + 20 + 20;
> +		size_t max_size = min_size;
>  		if (nr)
>  			max_size += (nr - 1)*8;
>  		if (idx_size < min_size || idx_size > max_size) {
> @@ -1763,7 +1763,7 @@ static int open_sha1_file(const unsigned char *sha1, const char **path)
>   */
>  static void *map_sha1_file_1(const char *path,
>  			     const unsigned char *sha1,
> -			     unsigned long *size)
> +			     size_t *size)
>  {
>  	void *map;
>  	int fd;
> @@ -1790,13 +1790,13 @@ static void *map_sha1_file_1(const char *path,
>  	return map;
>  }
>  
> -void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
> +void *map_sha1_file(const unsigned char *sha1, size_t *size)
>  {
>  	return map_sha1_file_1(NULL, sha1, size);
>  }
>  
> -unsigned long unpack_object_header_buffer(const unsigned char *buf,
> -		unsigned long len, enum object_type *type, size_t *sizep)
> +size_t unpack_object_header_buffer(const unsigned char *buf,
> +				   size_t len, enum object_type *type, size_t *sizep)
>  {
>  	unsigned shift;
>  	size_t size, c;
> @@ -1821,8 +1821,8 @@ unsigned long unpack_object_header_buffer(const unsigned char *buf,
>  }
>  
>  static int unpack_sha1_short_header(git_zstream *stream,
> -				    unsigned char *map, unsigned long mapsize,
> -				    void *buffer, unsigned long bufsiz)
> +				    unsigned char *map, size_t mapsize,
> +				    void *buffer, size_t bufsiz)
>  {
>  	/* Get the data stream */
>  	memset(stream, 0, sizeof(*stream));
> @@ -1836,8 +1836,8 @@ static int unpack_sha1_short_header(git_zstream *stream,
>  }
>  
>  int unpack_sha1_header(git_zstream *stream,
> -		       unsigned char *map, unsigned long mapsize,
> -		       void *buffer, unsigned long bufsiz)
> +		       unsigned char *map, size_t mapsize,
> +		       void *buffer, size_t bufsiz)
>  {
>  	int status = unpack_sha1_short_header(stream, map, mapsize,
>  					      buffer, bufsiz);
> @@ -1852,8 +1852,8 @@ int unpack_sha1_header(git_zstream *stream,
>  }
>  
>  static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,
> -					unsigned long mapsize, void *buffer,
> -					unsigned long bufsiz, struct strbuf *header)
> +					size_t mapsize, void *buffer,
> +					size_t bufsiz, struct strbuf *header)
>  {
>  	int status;
>  
> @@ -1887,11 +1887,11 @@ static int unpack_sha1_header_to_strbuf(git_zstream *stream, unsigned char *map,
>  	return -1;
>  }
>  
> -static void *unpack_sha1_rest(git_zstream *stream, void *buffer, unsigned long size, const unsigned char *sha1)
> +static void *unpack_sha1_rest(git_zstream *stream, void *buffer, size_t size, const unsigned char *sha1)
>  {
>  	int bytes = strlen(buffer) + 1;
>  	unsigned char *buf = xmallocz(size);
> -	unsigned long n;
> +	size_t n;
>  	int status = Z_OK;
>  
>  	n = stream->total_out - bytes;
> @@ -1941,7 +1941,7 @@ static int parse_sha1_header_extended(const char *hdr, struct object_info *oi,
>  			       unsigned int flags)
>  {
>  	const char *type_buf = hdr;
> -	unsigned long size;
> +	size_t size;
>  	int type, type_len = 0;
>  
>  	/*
> @@ -2006,9 +2006,9 @@ int parse_sha1_header(const char *hdr, size_t *sizep)
>  	return parse_sha1_header_extended(hdr, &oi, 0);
>  }
>  
> -unsigned long get_size_from_delta(struct packed_git *p,
> -				  struct pack_window **w_curs,
> -			          off_t curpos)
> +size_t get_size_from_delta(struct packed_git *p,
> +			   struct pack_window **w_curs,
> +			   off_t curpos)
>  {
>  	const unsigned char *data;
>  	unsigned char delta_head[20], *in;
> @@ -2242,7 +2242,7 @@ struct delta_base_cache_entry {
>  	struct delta_base_cache_key key;
>  	struct list_head lru;
>  	void *data;
> -	unsigned long size;
> +	size_t size;
>  	enum object_type type;
>  };
>  
> @@ -2339,7 +2339,7 @@ void clear_delta_base_cache(void)
>  }
>  
>  static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
> -	void *base, unsigned long base_size, enum object_type type)
> +	void *base, size_t base_size, enum object_type type)
>  {
>  	struct delta_base_cache_entry *ent = xmalloc(sizeof(*ent));
>  	struct list_head *lru, *tmp;
> @@ -2453,7 +2453,7 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,
>  static void *unpack_compressed_entry(struct packed_git *p,
>  				    struct pack_window **w_curs,
>  				    off_t curpos,
> -				    unsigned long size)
> +				    size_t size)
>  {
>  	int st;
>  	git_zstream stream;
> @@ -2500,7 +2500,7 @@ int do_check_packed_object_crc;
>  struct unpack_entry_stack_ent {
>  	off_t obj_offset;
>  	off_t curpos;
> -	unsigned long size;
> +	size_t size;
>  };
>  
>  void *unpack_entry(struct packed_git *p, off_t obj_offset,
> @@ -2909,7 +2909,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,
>  				  int flags)
>  {
>  	int status = 0;
> -	unsigned long mapsize;
> +	size_t mapsize;
>  	void *map;
>  	git_zstream stream;
>  	char hdr[32];
> @@ -3088,7 +3088,7 @@ static void *read_packed_sha1(const unsigned char *sha1,
>  	return data;
>  }
>  
> -int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,
> +int pretend_sha1_file(void *buf, size_t len, enum object_type type,
>  		      unsigned char *sha1)
>  {
>  	struct cached_object *co;
> @@ -3209,14 +3209,14 @@ void *read_object_with_reference(const unsigned char *sha1,
>  	}
>  }
>  
> -static void write_sha1_file_prepare(const void *buf, unsigned long len,
> +static void write_sha1_file_prepare(const void *buf, size_t len,
>                                      const char *type, unsigned char *sha1,
>                                      char *hdr, int *hdrlen)
>  {
>  	git_SHA_CTX c;
>  
>  	/* Generate the header */
> -	*hdrlen = xsnprintf(hdr, *hdrlen, "%s %lu", type, len)+1;
> +	*hdrlen = xsnprintf(hdr, *hdrlen, "%s %" PRIuMAX, type, (uintmax_t)len)+1;
>  
>  	/* Sha1.. */
>  	git_SHA1_Init(&c);
> @@ -3275,7 +3275,7 @@ static int write_buffer(int fd, const void *buf, size_t len)
>  	return 0;
>  }
>  
> -int hash_sha1_file(const void *buf, unsigned long len, const char *type,
> +int hash_sha1_file(const void *buf, size_t len, const char *type,
>                     unsigned char *sha1)
>  {
>  	char hdr[32];
> @@ -3339,7 +3339,7 @@ static int create_tmpfile(struct strbuf *tmp, const char *filename)
>  }
>  
>  static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
> -			      const void *buf, unsigned long len, time_t mtime)
> +			      const void *buf, size_t len, time_t mtime)
>  {
>  	int fd, ret;
>  	unsigned char compressed[4096];
> @@ -3423,7 +3423,7 @@ static int freshen_packed_object(const unsigned char *sha1)
>  	return 1;
>  }
>  
> -int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1)
> +int write_sha1_file(const void *buf, size_t len, const char *type, unsigned char *sha1)
>  {
>  	char hdr[32];
>  	int hdrlen = sizeof(hdr);
> @@ -3437,7 +3437,7 @@ int write_sha1_file(const void *buf, unsigned long len, const char *type, unsign
>  	return write_loose_object(sha1, hdr, hdrlen, buf, len, 0);
>  }
>  
> -int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type,
> +int hash_sha1_file_literally(const void *buf, size_t len, const char *type,
>  			     unsigned char *sha1, unsigned flags)
>  {
>  	char *header;
> @@ -3929,14 +3929,14 @@ int for_each_packed_object(each_packed_object_fn cb, void *data, unsigned flags)
>  
>  static int check_stream_sha1(git_zstream *stream,
>  			     const char *hdr,
> -			     unsigned long size,
> +			     size_t size,
>  			     const char *path,
>  			     const unsigned char *expected_sha1)
>  {
>  	git_SHA_CTX c;
>  	unsigned char real_sha1[GIT_MAX_RAWSZ];
>  	unsigned char buf[4096];
> -	unsigned long total_read;
> +	size_t total_read;
>  	int status = Z_OK;
>  
>  	git_SHA1_Init(&c);
> @@ -3992,7 +3992,7 @@ int read_loose_object(const char *path,
>  {
>  	int ret = -1;
>  	void *map = NULL;
> -	unsigned long mapsize;
> +	size_t mapsize;
>  	git_zstream stream;
>  	char hdr[32];
>  
> diff --git a/streaming.c b/streaming.c
> index 04a8b99..448c4aa 100644
> --- a/streaming.c
> +++ b/streaming.c
> @@ -77,7 +77,7 @@ struct git_istream {
>  
>  		struct {
>  			void *mapped;
> -			unsigned long mapsize;
> +			size_t mapsize;
>  			char hdr[32];
>  			int hdr_avail;
>  			int hdr_used;

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 5/9] Convert sha1_file.c to size_t
  2017-08-10 22:27 ` [PATCH 5/9] Convert sha1_file.c " Junio C Hamano
@ 2017-08-11  7:06   ` Martin Koegler
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Koegler @ 2017-08-11  7:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Martin Koegler, git, Johannes.Schindelin

On Thu, Aug 10, 2017 at 03:27:28PM -0700, Junio C Hamano wrote:
> Please do not start your patch series from 5/9 when there is no 1/9,
> 2/9, 3/9, and 4/9.  It is seriously confusing.
> 
> I am guessing that you are trying to split the series into
> manageable pieces by going per call graph and codeflow.  I think it
> is a more sensible approach than a single huge ball of wax we saw
> earlier.

The later patches are further changes extending the previous series. The first, large
patch can be splitted any more - it has alreay been generated by changing the delta code
and fixing other functions until the codebase is working again.

I didn't wanted to spam the mailing list with the same unchanged patches within a short timeframe.

Regards,
Martin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-08-11  7:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-10 19:25 [PATCH 5/9] Convert sha1_file.c to size_t Martin Koegler
2017-08-10 19:25 ` [PATCH 6/9] Use size_t for sha1 Martin Koegler
2017-08-10 19:25 ` [PATCH 8/9] Convert fsck.c & commit.c to size_t Martin Koegler
2017-08-10 19:25 ` [PATCH 9/9] Convert cache functions " Martin Koegler
2017-08-10 22:27 ` [PATCH 5/9] Convert sha1_file.c " Junio C Hamano
2017-08-11  7:06   ` Martin Koegler

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).