git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Whitcroft <apw@shadowen.org>
To: git@vger.kernel.org
Subject: [PATCH] fix up strtoul_ui error handling
Date: Thu, 19 Apr 2007 03:08:15 +0100	[thread overview]
Message-ID: <37ce3db845caa21ba45c15d4f829ece1@pinky> (raw)
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++;

  parent reply	other threads:[~2007-04-19  2:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-09 23:01 sscanf/strtoul: parse integers robustly Jim Meyering
2007-04-11  7:55 ` Junio C Hamano
2007-04-11 13:52   ` Jim Meyering
2007-04-19  2:08 ` Andy Whitcroft [this message]
2007-04-19  2:26   ` [PATCH] fix up strtoul_ui error handling Junio C Hamano

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=37ce3db845caa21ba45c15d4f829ece1@pinky \
    --to=apw@shadowen.org \
    --cc=git@vger.kernel.org \
    /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).