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

[PATCH 1/4] Prefer %d over %i in printf format strings.

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jan 27, 2007, 06:51 UTC
Message-ID
<20070127065156.GA10380@spearce.org>

The git project seems to prefer using %d when formatting signed integer values. These handful of locations were noticed by Junio as not conforming. At least one of them was my fault, perhaps the others were too. :-)

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 builtin-describe.c |    2 +-
 receive-pack.c     |    2 +-
 sha1_file.c        |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin-describe.c b/builtin-describe.c
index 4921eee..f8afb9c 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -182,7 +182,7 @@ static void describe(const char *arg, int last_one)
 		fprintf(stderr, "traversed %lu commits\n", seen_commits);
 		if (gave_up_on) {
 			fprintf(stderr,
-				"more than %i tags found; listed %i most recent\n"
+				"more than %d tags found; listed %d most recent\n"
 				"gave up search at %s\n",
 				max_candidates, max_candidates,
 				sha1_to_hex(gave_up_on->object.sha1));
diff --git a/receive-pack.c b/receive-pack.c
index 7d26326..19bc685 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -317,7 +317,7 @@ static const char *unpack(void)
 		char keep_arg[256];
 		char packname[46];
 
-		s = sprintf(keep_arg, "--keep=receive-pack %i on ", getpid());
+		s = sprintf(keep_arg, "--keep=receive-pack %d on ", getpid());
 		if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
 			strcpy(keep_arg + s, "localhost");
 
diff --git a/sha1_file.c b/sha1_file.c
index 498665e..335b4b4 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1326,7 +1326,7 @@ void *unpack_entry(struct packed_git *p, unsigned long offset,
 		retval = unpack_compressed_entry(p, &w_curs, offset, size);
 		break;
 	default:
-		die("unknown object type %i in %s", kind, p->pack_name);
+		die("unknown object type %d in %s", kind, p->pack_name);
 	}
 	unuse_pack(&w_curs);
 	return retval;
-- 
1.5.0.rc2.g8a816
Message 1 of 1 in “Prefer %d over %i in printf format strings.”
  1. 1/4 Prefer %d over %i in printf format strings.Shawn O. Pearce, Jan 27, 2007

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.