git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Koegler <martin.koegler@chello.at>
To: git@vger.kernel.org, gitster@pobox.com, Johannes.Schindelin@gmx.de
Cc: Martin Koegler <martin.koegler@chello.at>
Subject: [PATCH 8/9] Convert tree-walk to size_t
Date: Sat, 12 Aug 2017 10:47:22 +0200	[thread overview]
Message-ID: <1502527643-21944-8-git-send-email-martin@mail.zuhause> (raw)
In-Reply-To: <1502527643-21944-1-git-send-email-martin@mail.zuhause>

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

Signed-off-by: Martin Koegler <martin.koegler@chello.at>
---
 tree-walk.c | 17 +++++++++--------
 tree-walk.h |  4 ++--
 tree.h      |  2 +-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/tree-walk.c b/tree-walk.c
index 7c9f9e3..a7d8b2a 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -22,10 +22,11 @@ static const char *get_mode(const char *str, unsigned int *modep)
 	return str;
 }
 
-static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned long size, struct strbuf *err)
+static int decode_tree_entry(struct tree_desc *desc, const char *buf, size_t size, struct strbuf *err)
 {
 	const char *path;
-	unsigned int mode, len;
+	unsigned int mode;
+	size_t len;
 
 	if (size < 23 || buf[size - 21]) {
 		strbuf_addstr(err, _("too-short tree object"));
@@ -51,7 +52,7 @@ static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned l
 	return 0;
 }
 
-static int init_tree_desc_internal(struct tree_desc *desc, const void *buffer, unsigned long size, struct strbuf *err)
+static int init_tree_desc_internal(struct tree_desc *desc, const void *buffer, size_t size, struct strbuf *err)
 {
 	desc->buffer = buffer;
 	desc->size = size;
@@ -60,7 +61,7 @@ static int init_tree_desc_internal(struct tree_desc *desc, const void *buffer, u
 	return 0;
 }
 
-void init_tree_desc(struct tree_desc *desc, const void *buffer, unsigned long size)
+void init_tree_desc(struct tree_desc *desc, const void *buffer, size_t size)
 {
 	struct strbuf err = STRBUF_INIT;
 	if (init_tree_desc_internal(desc, buffer, size, &err))
@@ -68,7 +69,7 @@ void init_tree_desc(struct tree_desc *desc, const void *buffer, unsigned long si
 	strbuf_release(&err);
 }
 
-int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, unsigned long size)
+int init_tree_desc_gently(struct tree_desc *desc, const void *buffer, size_t size)
 {
 	struct strbuf err = STRBUF_INIT;
 	int result = init_tree_desc_internal(desc, buffer, size, &err);
@@ -106,8 +107,8 @@ static int update_tree_entry_internal(struct tree_desc *desc, struct strbuf *err
 {
 	const void *buf = desc->buffer;
 	const unsigned char *end = desc->entry.oid->hash + 20;
-	unsigned long size = desc->size;
-	unsigned long len = end - (const unsigned char *)buf;
+	size_t size = desc->size;
+	size_t len = end - (const unsigned char *)buf;
 
 	if (size < len)
 		die(_("too-short tree file"));
@@ -487,7 +488,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
 
 struct dir_state {
 	void *tree;
-	unsigned long size;
+	size_t size;
 	unsigned char sha1[20];
 };
 
diff --git a/tree-walk.h b/tree-walk.h
index 68bb78b..9160cc2 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -32,8 +32,8 @@ static inline int tree_entry_len(const struct name_entry *ne)
 
 void update_tree_entry(struct tree_desc *);
 int update_tree_entry_gently(struct tree_desc *);
-void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size);
-int init_tree_desc_gently(struct tree_desc *desc, const void *buf, unsigned long size);
+void init_tree_desc(struct tree_desc *desc, const void *buf, size_t size);
+int init_tree_desc_gently(struct tree_desc *desc, const void *buf, size_t size);
 
 /*
  * Helper function that does both tree_entry_extract() and update_tree_entry()
diff --git a/tree.h b/tree.h
index 1dac7fc..69b9233 100644
--- a/tree.h
+++ b/tree.h
@@ -9,7 +9,7 @@ struct strbuf;
 struct tree {
 	struct object object;
 	void *buffer;
-	unsigned long size;
+	size_t size;
 };
 
 struct tree *lookup_tree(const struct object_id *oid);
-- 
2.1.4


  parent reply	other threads:[~2017-08-12  8:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-12  8:47 [PATCH 1/9] Convert pack-objects to size_t Martin Koegler
2017-08-12  8:47 ` [PATCH 2/9] Convert index-pack " Martin Koegler
2017-08-12 13:51   ` Ramsay Jones
2017-08-12  8:47 ` [PATCH 3/9] Convert unpack-objects " Martin Koegler
2017-08-12 14:07   ` Martin Ågren
2017-08-13 18:25     ` Martin Koegler
2017-08-12  8:47 ` [PATCH 4/9] Convert archive functions " Martin Koegler
2017-08-12  8:47 ` [PATCH 5/9] Convert various things " Martin Koegler
2017-08-12 13:27   ` Martin Ågren
2017-08-13 17:48     ` Martin Koegler
2017-08-12  8:47 ` [PATCH 6/9] Use size_t for config parsing Martin Koegler
2017-08-12  8:47 ` [PATCH 7/9] Convert ref-filter to size_t Martin Koegler
2017-08-12  8:47 ` Martin Koegler [this message]
2017-08-12  8:47 ` [PATCH 9/9] Convert xdiff-interface " Martin Koegler
2017-08-12  9:59 ` [PATCH 1/9] Convert pack-objects " Torsten Bögershausen
2017-08-13 18:27   ` Martin Koegler
2017-08-12 13:47 ` Ramsay Jones
2017-08-13 18:30   ` Martin Koegler
2017-08-13 19:45     ` Ramsay Jones
2017-08-13 22:15       ` Junio C Hamano
2017-08-14 17:08         ` Junio C Hamano
2017-08-14 19:31           ` Ramsay Jones
2017-08-14 19:58             ` Junio C Hamano
2017-08-14 20:32             ` Torsten Bögershausen
2017-08-15  0:30               ` Ramsay Jones
2017-08-16 20:22           ` Martin Koegler
2017-08-17 10:38             ` Torsten Bögershausen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1502527643-21944-8-git-send-email-martin@mail.zuhause \
    --to=martin.koegler@chello.at \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).