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

[PATCH] fix up strtoul_ui error handling

From
Andy Whitcroft <apw@shadowen.org>
Date
Apr 19, 2007, 02:08 UTC
Message-ID
<37ce3db845caa21ba45c15d4f829ece1@pinky>
In-Reply-To
<871witxicn.fsf@rho.meyering.net>

Two scanf() calls were converted to strtoul_ui() but the return values were not updated to match. scanf() returns the number of matched "values" which for this usage is 1 on success. strtoul_ui() return 0 on success. Update these call sites to match.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
	Without this patch svnimport fails to add files as
	update-index --cacheinfo fails.
---
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 9205c9f..8f98991 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -627,7 +627,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 				if (i+3 >= argc)
 					die("git-update-index: --cacheinfo <mode> <sha1> <path>");
 
-				if ((strtoul_ui(argv[i+1], 8, &mode) != 1) ||
+				if (strtoul_ui(argv[i+1], 8, &mode) ||
 				    get_sha1_hex(argv[i+2], sha1) ||
 				    add_cacheinfo(mode, sha1, argv[i+3], 0))
 					die("git-update-index: --cacheinfo"
diff --git a/convert-objects.c b/convert-objects.c
index cf03bcf..cefbceb 100644
--- a/convert-objects.c
+++ b/convert-objects.c
@@ -88,7 +88,7 @@ static int write_subdirectory(void *buffer, unsigned long size, const char *base
 		unsigned int mode;
 		char *slash, *origpath;
 
-		if (!path || strtoul_ui(buffer, 8, &mode) != 1)
+		if (!path || strtoul_ui(buffer, 8, &mode))
 			die("bad tree conversion");
 		mode = convert_mode(mode);
 		path++;
Previous: Jim MeyeringNext: Junio C Hamano
Message 4 of 5 in “sscanf/strtoul: parse integers robustly”
  1. Jim MeyeringApr 9, 2007
  2. Junio C HamanoApr 11, 2007
  3. Jim MeyeringApr 11, 2007
  4. fix up strtoul_ui error handlingAndy Whitcroft, Apr 19, 2007
  5. Junio C HamanoApr 19, 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.