git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[Patch size_t V3 17/19] Convert ref-filter to size_t

From
Martin Koegler <martin.koegler@chello.at>
Date
Aug 16, 2017, 20:16 UTC
Message-ID
<1502914591-26215-18-git-send-email-martin@mail.zuhause>
In-Reply-To
<1502914591-26215-1-git-send-email-martin@mail.zuhause>
From: Martin Koegler <martin.koegler@chello.at>
Signed-off-by: Martin Koegler <martin.koegler@chello.at>
---
 ref-filter.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/ref-filter.c b/ref-filter.c
index 5c903a5..30f249c 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -724,7 +724,7 @@ static int grab_objectname(const char *name, const unsigned char *sha1,
 }
 
 /* See grab_values */
-static void grab_common_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)
+static void grab_common_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)
 {
 	int i;
 
@@ -739,7 +739,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
 			v->s = typename(obj->type);
 		else if (!strcmp(name, "objectsize")) {
 			v->value = sz;
-			v->s = xstrfmt("%lu", sz);
+			v->s = xstrfmt("%" PRIuMAX, (uintmax_t)sz);
 		}
 		else if (deref)
 			grab_objectname(name, obj->oid.hash, v, &used_atom[i]);
@@ -747,7 +747,7 @@ static void grab_common_values(struct atom_value *val, int deref, struct object
 }
 
 /* See grab_values */
-static void grab_tag_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)
+static void grab_tag_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)
 {
 	int i;
 	struct tag *tag = (struct tag *) obj;
@@ -769,7 +769,7 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *ob
 }
 
 /* See grab_values */
-static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)
+static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)
 {
 	int i;
 	struct commit *commit = (struct commit *) obj;
@@ -786,7 +786,7 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object
 		}
 		else if (!strcmp(name, "numparent")) {
 			v->value = commit_list_count(commit->parents);
-			v->s = xstrfmt("%lu", (unsigned long)v->value);
+			v->s = xstrfmt("%" PRIuMAX, (uintmax_t)v->value);
 		}
 		else if (!strcmp(name, "parent")) {
 			struct commit_list *parents;
@@ -802,7 +802,7 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object
 	}
 }
 
-static const char *find_wholine(const char *who, int wholen, const char *buf, unsigned long sz)
+static const char *find_wholine(const char *who, int wholen, const char *buf, size_t sz)
 {
 	const char *eol;
 	while (*buf) {
@@ -848,7 +848,7 @@ static const char *copy_email(const char *buf)
 	return xmemdupz(email, eoemail + 1 - email);
 }
 
-static char *copy_subject(const char *buf, unsigned long len)
+static char *copy_subject(const char *buf, size_t len)
 {
 	char *r = xmemdupz(buf, len);
 	int i;
@@ -898,7 +898,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
 }
 
 /* See grab_values */
-static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)
+static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)
 {
 	int i;
 	int wholen = strlen(who);
@@ -957,11 +957,11 @@ static void grab_person(const char *who, struct atom_value *val, int deref, stru
 	}
 }
 
-static void find_subpos(const char *buf, unsigned long sz,
-			const char **sub, unsigned long *sublen,
-			const char **body, unsigned long *bodylen,
-			unsigned long *nonsiglen,
-			const char **sig, unsigned long *siglen)
+static void find_subpos(const char *buf, size_t sz,
+			const char **sub, size_t *sublen,
+			const char **body, size_t *bodylen,
+			size_t *nonsiglen,
+			const char **sig, size_t *siglen)
 {
 	const char *eol;
 	/* skip past header until we hit empty line */
@@ -1005,7 +1005,7 @@ static void find_subpos(const char *buf, unsigned long sz,
  * If 'lines' is greater than 0, append that many lines from the given
  * 'buf' of length 'size' to the given strbuf.
  */
-static void append_lines(struct strbuf *out, const char *buf, unsigned long size, int lines)
+static void append_lines(struct strbuf *out, const char *buf, size_t size, int lines)
 {
 	int i;
 	const char *sp, *eol;
@@ -1026,11 +1026,11 @@ static void append_lines(struct strbuf *out, const char *buf, unsigned long size
 }
 
 /* See grab_values */
-static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)
+static void grab_sub_body_contents(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)
 {
 	int i;
 	const char *subpos = NULL, *bodypos = NULL, *sigpos = NULL;
-	unsigned long sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;
+	size_t sublen = 0, bodylen = 0, nonsiglen = 0, siglen = 0;
 
 	for (i = 0; i < used_atom_cnt; i++) {
 		struct used_atom *atom = &used_atom[i];
@@ -1100,7 +1100,7 @@ static void fill_missing_values(struct atom_value *val)
  * pointed at by the ref itself; otherwise it is the object the
  * ref (which is a tag) refers to.
  */
-static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)
+static void grab_values(struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)
 {
 	grab_common_values(val, deref, obj, buf, sz);
 	switch (obj->type) {
-- 
2.1.4
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 33 in “use size_t”
  1. 00/19 use size_tMartin Koegler, Aug 16, 2017
  2. 03/19 Convert zlib.c to size_tMartin Koegler, Aug 16, 2017
  3. 01/19 delta: fix enconding size larger than an "uint" can holdMartin Koegler, Aug 16, 2017
  4. Torsten BögershausenAug 17, 2017
  5. 08/19 Convert fsck.c & commit.c to size_tMartin Koegler, Aug 16, 2017
  6. 11/19 Use size_t for config parsingMartin Koegler, Aug 16, 2017
  7. Johannes SixtAug 24, 2017
  8. 04/19 delta: Fix offset overflowsMartin Koegler, Aug 16, 2017
  9. 12/19 Convert pack-objects to size_tMartin Koegler, Aug 16, 2017
  10. 19/19 Convert xdiff-interface to size_tMartin Koegler, Aug 16, 2017
  11. Junio C HamanoAug 17, 2017
  12. 17/19 Convert ref-filter to size_tMartin Koegler, Aug 16, 2017
  13. Junio C HamanoAug 17, 2017
  14. Junio C HamanoAug 17, 2017
  15. 10/19 Add overflow check to get_delta_hdr_sizeMartin Koegler, Aug 16, 2017
  16. 18/19 Convert tree-walk to size_tMartin Koegler, Aug 16, 2017
  17. Junio C HamanoAug 17, 2017
  18. 16/19 Convert various things to size_tMartin Koegler, Aug 16, 2017
  19. Junio C HamanoAug 21, 2017
  20. 15/19 Convert archive functions to size_tMartin Koegler, Aug 16, 2017
  21. Junio C HamanoAug 21, 2017
  22. brian m. carlsonAug 22, 2017
  23. 07/19 Convert parse_X_buffer to size_tMartin Koegler, Aug 16, 2017
  24. 14/19 Convert unpack-objects to size_tMartin Koegler, Aug 16, 2017
  25. 13/19 Convert index-pack to size_tMartin Koegler, Aug 16, 2017
  26. Ramsay JonesAug 16, 2017
  27. 02/19 Convert size datatype to size_tMartin Koegler, Aug 16, 2017
  28. 09/19 Convert cache functions to size_tMartin Koegler, Aug 16, 2017
  29. 05/19 Convert sha1_file.c to size_tMartin Koegler, Aug 16, 2017
  30. 06/19 Use size_t for sha1Martin Koegler, Aug 16, 2017
  31. Junio C HamanoAug 16, 2017
  32. Torsten BögershausenAug 17, 2017
  33. Martin KoeglerAug 18, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.