git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 00/41] Add and use error_errno() and warning_errno()
@ 2016-05-01 11:14 Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
                   ` (42 more replies)
  0 siblings, 43 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

This is a spinoff from my worktree-move topic. This series adds
die_errno() companions, error_errno() and warning_errno(), and use them
where applicable to reduce the amount of typing (in future). Changes
are split by file (which explains the huge number of patches). I leave
builtin/apply.c and refs/files-backend.c untouched because they are
currently hot zones.

Nguyễn Thái Ngọc Duy (41):
  usage.c: move format processing out of die_errno()
  usage.c: add warning_errno() and error_errno()
  bisect.c: use die_errno() and warning_errno()
  builtin/am.c: use error_errno()
  builtin/branch.c: use error_errno()
  builtin/fetch.c: use error_errno()
  builtin/help.c: use warning_errno()
  builtin/mailsplit.c: use error_errno()
  builtin/merge-file.c: use error_errno()
  builtin/pack-objects.c: use die_errno() and warning_errno()
  builtin/rm.c: use warning_errno()
  builtin/update-index.c: use error_errno()
  builtin/upload-archive.c: use error_errno()
  builtin/worktree.c: use error_errno()
  check-racy.c: use error_errno()
  combine-diff.c: use error_errno()
  compat/win32/syslog.c: use warning_errno()
  config.c: use error_errno()
  connected.c: use error_errno()
  copy.c: use error_errno()
  credential-cache--daemon.c: use warning_errno()
  diff-no-index.c: use error_errno()
  editor.c: use error_errno()
  entry.c: use error_errno()
  fast-import.c: use error_errno()
  gpg-interface.c: use error_errno()
  grep.c: use error_errno()
  http.c: use error_errno() and warning_errno()
  ident.c: use warning_errno()
  mailmap.c: use error_errno()
  reachable.c: use error_errno()
  rerere.c: use error_errno() and warning_errno()
  run-command.c: use error_errno()
  sequencer.c: use error_errno()
  server-info.c: use error_errno()
  sha1_file.c: use {error,die,warning}_errno()
  transport-helper.c: use error_errno()
  unpack-trees.c: use error_errno()
  upload-pack.c: use error_errno()
  vcs-svn: use error_errno()
  wrapper.c: use warning_errno()

 bisect.c                   |  7 +++----
 builtin/am.c               | 11 +++++------
 builtin/branch.c           |  3 +--
 builtin/fetch.c            |  4 ++--
 builtin/help.c             |  8 ++++----
 builtin/mailsplit.c        | 10 +++++-----
 builtin/merge-file.c       | 10 +++++-----
 builtin/pack-objects.c     |  8 +++-----
 builtin/rm.c               |  2 +-
 builtin/update-index.c     |  8 ++++----
 builtin/upload-archive.c   |  3 +--
 builtin/worktree.c         |  2 +-
 check-racy.c               |  2 +-
 combine-diff.c             |  3 +--
 compat/win32/syslog.c      |  6 +++---
 config.c                   | 22 +++++++++-------------
 connected.c                |  9 +++------
 copy.c                     |  6 +++---
 credential-cache--daemon.c |  4 ++--
 diff-no-index.c            |  3 +--
 editor.c                   |  3 +--
 entry.c                    | 10 ++++------
 fast-import.c              | 10 +++++-----
 git-compat-util.h          |  2 ++
 gpg-interface.c            |  6 ++----
 grep.c                     |  4 ++--
 http.c                     | 10 ++++------
 ident.c                    |  8 +++-----
 mailmap.c                  |  3 +--
 reachable.c                |  3 +--
 rerere.c                   | 18 +++++++-----------
 run-command.c              | 15 +++++++--------
 sequencer.c                |  3 +--
 server-info.c              |  2 +-
 sha1_file.c                | 32 +++++++++++++-------------------
 transport-helper.c         |  6 +++---
 unpack-trees.c             |  6 ++----
 upload-pack.c              |  3 +--
 usage.c                    | 44 ++++++++++++++++++++++++++++++++++----------
 vcs-svn/line_buffer.c      |  4 ++--
 vcs-svn/sliding_window.c   |  2 +-
 vcs-svn/svndiff.c          |  4 ++--
 vcs-svn/svndump.c          |  4 ++--
 wrapper.c                  |  4 ++--
 44 files changed, 161 insertions(+), 176 deletions(-)

-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply	[flat|nested] 145+ messages in thread

* [PATCH 01/41] usage.c: move format processing out of die_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 18:23   ` Eric Sunshine
  2016-05-01 11:14 ` [PATCH 02/41] usage.c: add warning_errno() and error_errno() Nguyễn Thái Ngọc Duy
                   ` (41 subsequent siblings)
  42 siblings, 1 reply; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

fmt_with_err() will be shared with the coming error_errno() and
warning_errno().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 usage.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/usage.c b/usage.c
index 82ff131..0dba0c5 100644
--- a/usage.c
+++ b/usage.c
@@ -109,19 +109,12 @@ void NORETURN die(const char *err, ...)
 	va_end(params);
 }
 
-void NORETURN die_errno(const char *fmt, ...)
+static const char *fmt_with_err(const char *fmt)
 {
-	va_list params;
-	char fmt_with_err[1024];
+	static char fmt_with_err[1024];
 	char str_error[256], *err;
 	int i, j;
 
-	if (die_is_recursing()) {
-		fputs("fatal: recursion detected in die_errno handler\n",
-			stderr);
-		exit(128);
-	}
-
 	err = strerror(errno);
 	for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {
 		if ((str_error[j++] = err[i++]) != '%')
@@ -137,9 +130,21 @@ void NORETURN die_errno(const char *fmt, ...)
 	}
 	str_error[j] = 0;
 	snprintf(fmt_with_err, sizeof(fmt_with_err), "%s: %s", fmt, str_error);
+	return fmt_with_err;
+}
+
+void NORETURN die_errno(const char *fmt, ...)
+{
+	va_list params;
+
+	if (die_is_recursing()) {
+		fputs("fatal: recursion detected in die_errno handler\n",
+			stderr);
+		exit(128);
+	}
 
 	va_start(params, fmt);
-	die_routine(fmt_with_err, params);
+	die_routine(fmt_with_err(fmt), params);
 	va_end(params);
 }
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 02/41] usage.c: add warning_errno() and error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 03/41] bisect.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (40 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Similar to die_errno(), these functions will append strerror()
automatically.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 git-compat-util.h |  2 ++
 usage.c           | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/git-compat-util.h b/git-compat-util.h
index 1f8b5f3..49d4029 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -409,7 +409,9 @@ extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf,
 extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
+extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
+extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 
 #ifndef NO_OPENSSL
 #ifdef APPLE_COMMON_CRYPTO
diff --git a/usage.c b/usage.c
index 0dba0c5..af1b7d1 100644
--- a/usage.c
+++ b/usage.c
@@ -148,6 +148,16 @@ void NORETURN die_errno(const char *fmt, ...)
 	va_end(params);
 }
 
+int error_errno(const char *fmt, ...)
+{
+	va_list params;
+
+	va_start(params, fmt);
+	error_routine(fmt_with_err(fmt), params);
+	va_end(params);
+	return -1;
+}
+
 #undef error
 int error(const char *err, ...)
 {
@@ -159,6 +169,15 @@ int error(const char *err, ...)
 	return -1;
 }
 
+void warning_errno(const char *warn, ...)
+{
+	va_list params;
+
+	va_start(params, warn);
+	warn_routine(fmt_with_err(warn), params);
+	va_end(params);
+}
+
 void warning(const char *warn, ...)
 {
 	va_list params;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 03/41] bisect.c: use die_errno() and warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 02/41] usage.c: add warning_errno() and error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 04/41] builtin/am.c: use error_errno() Nguyễn Thái Ngọc Duy
                   ` (39 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 bisect.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/bisect.c b/bisect.c
index 7996c29..6d93edb 100644
--- a/bisect.c
+++ b/bisect.c
@@ -860,8 +860,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
 	/* Create file BISECT_ANCESTORS_OK. */
 	fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);
 	if (fd < 0)
-		warning("could not create file '%s': %s",
-			filename, strerror(errno));
+		warning_errno("could not create file '%s'",
+			      filename);
 	else
 		close(fd);
  done:
@@ -910,8 +910,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
 			*read_good = "good";
 			return;
 		} else {
-			die("could not read file '%s': %s", filename,
-				strerror(errno));
+			die_errno("could not read file '%s'", filename);
 		}
 	} else {
 		strbuf_getline_lf(&str, fp);
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 04/41] builtin/am.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (2 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 03/41] bisect.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 05/41] builtin/branch.c: " Nguyễn Thái Ngọc Duy
                   ` (38 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/am.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index d003939..3dfe70b 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -769,15 +769,15 @@ static int split_mail_conv(mail_conv_fn fn, struct am_state *state,
 			in = fopen(*paths, "r");
 
 		if (!in)
-			return error(_("could not open '%s' for reading: %s"),
-					*paths, strerror(errno));
+			return error_errno(_("could not open '%s' for reading"),
+					   *paths);
 
 		mail = mkpath("%s/%0*d", state->dir, state->prec, i + 1);
 
 		out = fopen(mail, "w");
 		if (!out)
-			return error(_("could not open '%s' for writing: %s"),
-					mail, strerror(errno));
+			return error_errno(_("could not open '%s' for writing"),
+					   mail);
 
 		ret = fn(out, in, keep_cr);
 
@@ -857,8 +857,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
 
 	fp = fopen(*paths, "r");
 	if (!fp)
-		return error(_("could not open '%s' for reading: %s"), *paths,
-				strerror(errno));
+		return error_errno(_("could not open '%s' for reading"), *paths);
 
 	while (!strbuf_getline_lf(&sb, fp)) {
 		if (*sb.buf == '#')
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 05/41] builtin/branch.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (3 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 04/41] builtin/am.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 06/41] builtin/fetch.c: " Nguyễn Thái Ngọc Duy
                   ` (37 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/branch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index 0adba62..6f1572d 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -593,8 +593,7 @@ static int edit_branch_description(const char *branch_name)
 		    branch_name, comment_line_char);
 	if (write_file_gently(git_path(edit_description), "%s", buf.buf)) {
 		strbuf_release(&buf);
-		return error(_("could not write branch description template: %s"),
-			     strerror(errno));
+		return error_errno(_("could not write branch description template"));
 	}
 	strbuf_reset(&buf);
 	if (launch_editor(git_path(edit_description), &buf, NULL)) {
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 06/41] builtin/fetch.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (4 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 05/41] builtin/branch.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 07/41] builtin/help.c: use warning_errno() Nguyễn Thái Ngọc Duy
                   ` (36 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fetch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index f8455bd..1582ca7 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -607,7 +607,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 
 	fp = fopen(filename, "a");
 	if (!fp)
-		return error(_("cannot open %s: %s\n"), filename, strerror(errno));
+		return error_errno(_("cannot open %s"), filename);
 
 	if (raw_url)
 		url = transport_anonymize_url(raw_url);
@@ -848,7 +848,7 @@ static int truncate_fetch_head(void)
 	FILE *fp = fopen_for_writing(filename);
 
 	if (!fp)
-		return error(_("cannot open %s: %s\n"), filename, strerror(errno));
+		return error_errno(_("cannot open %s"), filename);
 	fclose(fp);
 	return 0;
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 07/41] builtin/help.c: use warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (5 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 06/41] builtin/fetch.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 08/41] builtin/mailsplit.c: use error_errno() Nguyễn Thái Ngọc Duy
                   ` (35 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/help.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/help.c b/builtin/help.c
index 3c55ce4..8848013 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -127,7 +127,7 @@ static void exec_woman_emacs(const char *path, const char *page)
 			path = "emacsclient";
 		strbuf_addf(&man_page, "(woman \"%s\")", page);
 		execlp(path, "emacsclient", "-e", man_page.buf, (char *)NULL);
-		warning(_("failed to exec '%s': %s"), path, strerror(errno));
+		warning_errno(_("failed to exec '%s'"), path);
 	}
 }
 
@@ -148,7 +148,7 @@ static void exec_man_konqueror(const char *path, const char *page)
 			path = "kfmclient";
 		strbuf_addf(&man_page, "man:%s(1)", page);
 		execlp(path, filename, "newTab", man_page.buf, (char *)NULL);
-		warning(_("failed to exec '%s': %s"), path, strerror(errno));
+		warning_errno(_("failed to exec '%s'"), path);
 	}
 }
 
@@ -157,7 +157,7 @@ static void exec_man_man(const char *path, const char *page)
 	if (!path)
 		path = "man";
 	execlp(path, "man", page, (char *)NULL);
-	warning(_("failed to exec '%s': %s"), path, strerror(errno));
+	warning_errno(_("failed to exec '%s'"), path);
 }
 
 static void exec_man_cmd(const char *cmd, const char *page)
@@ -165,7 +165,7 @@ static void exec_man_cmd(const char *cmd, const char *page)
 	struct strbuf shell_cmd = STRBUF_INIT;
 	strbuf_addf(&shell_cmd, "%s %s", cmd, page);
 	execl(SHELL_PATH, SHELL_PATH, "-c", shell_cmd.buf, (char *)NULL);
-	warning(_("failed to exec '%s': %s"), cmd, strerror(errno));
+	warning(_("failed to exec '%s'"), cmd);
 }
 
 static void add_man_viewer(const char *name)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 08/41] builtin/mailsplit.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (6 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 07/41] builtin/help.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 18:31   ` Eric Sunshine
  2016-05-01 11:14 ` [PATCH 09/41] builtin/merge-file.c: " Nguyễn Thái Ngọc Duy
                   ` (34 subsequent siblings)
  42 siblings, 1 reply; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/mailsplit.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
index 104277a..4859ede 100644
--- a/builtin/mailsplit.c
+++ b/builtin/mailsplit.c
@@ -109,7 +109,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)
 		if ((dir = opendir(name)) == NULL) {
 			if (errno == ENOENT)
 				continue;
-			error("cannot opendir %s (%s)", name, strerror(errno));
+			error_errno("cannot opendir %s", name);
 			goto out;
 		}
 
@@ -174,12 +174,12 @@ static int split_maildir(const char *maildir, const char *dir,
 
 		f = fopen(file, "r");
 		if (!f) {
-			error("cannot open mail %s (%s)", file, strerror(errno));
+			error_errno("cannot open mail %s", file);
 			goto out;
 		}
 
 		if (strbuf_getwholeline(&buf, f, '\n')) {
-			error("cannot read mail %s (%s)", file, strerror(errno));
+			error_errno("cannot read mail %s", file);
 			goto out;
 		}
 
@@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
 	int file_done = 0;
 
 	if (!f) {
-		error("cannot open mbox %s", file);
+		error_errno("cannot open mbox %s", file);
 		goto out;
 	}
 
@@ -318,7 +318,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)
 		}
 
 		if (stat(arg, &argstat) == -1) {
-			error("cannot stat %s (%s)", arg, strerror(errno));
+			error_errno("cannot stat %s", arg);
 			return 1;
 		}
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 09/41] builtin/merge-file.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (7 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 08/41] builtin/mailsplit.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 10/41] builtin/pack-objects.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (33 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/merge-file.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 5544705..13e22a2 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -62,8 +62,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 		usage_with_options(merge_file_usage, options);
 	if (quiet) {
 		if (!freopen("/dev/null", "w", stderr))
-			return error("failed to redirect stderr to /dev/null: "
-				     "%s", strerror(errno));
+			return error_errno("failed to redirect stderr to /dev/null");
 	}
 
 	if (prefix)
@@ -95,12 +94,13 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 		FILE *f = to_stdout ? stdout : fopen(fpath, "wb");
 
 		if (!f)
-			ret = error("Could not open %s for writing", filename);
+			ret = error_errno("Could not open %s for writing",
+					  filename);
 		else if (result.size &&
 			 fwrite(result.ptr, result.size, 1, f) != 1)
-			ret = error("Could not write to %s", filename);
+			ret = error_errno("Could not write to %s", filename);
 		else if (fclose(f))
-			ret = error("Could not close %s", filename);
+			ret = error_errno("Could not close %s", filename);
 		free(result.ptr);
 	}
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 10/41] builtin/pack-objects.c: use die_errno() and warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (8 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 09/41] builtin/merge-file.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 11/41] builtin/rm.c: use warning_errno() Nguyễn Thái Ngọc Duy
                   ` (32 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/pack-objects.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index a27de5b..e18e190 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -828,8 +828,7 @@ static void write_pack_file(void)
 			 * to preserve this property.
 			 */
 			if (stat(pack_tmp_name, &st) < 0) {
-				warning("failed to stat %s: %s",
-					pack_tmp_name, strerror(errno));
+				warning_errno("failed to stat %s", pack_tmp_name);
 			} else if (!last_mtime) {
 				last_mtime = st.st_mtime;
 			} else {
@@ -837,8 +836,7 @@ static void write_pack_file(void)
 				utb.actime = st.st_atime;
 				utb.modtime = --last_mtime;
 				if (utime(pack_tmp_name, &utb) < 0)
-					warning("failed utime() on %s: %s",
-						pack_tmp_name, strerror(errno));
+					warning_errno("failed utime() on %s", pack_tmp_name);
 			}
 
 			strbuf_addf(&tmpname, "%s-", base_name);
@@ -2020,7 +2018,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
 		ret = pthread_create(&p[i].thread, NULL,
 				     threaded_find_deltas, &p[i]);
 		if (ret)
-			die("unable to create thread: %s", strerror(ret));
+			die_errno("unable to create thread");
 		active_threads++;
 	}
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 11/41] builtin/rm.c: use warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (9 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 10/41] builtin/pack-objects.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 12/41] builtin/update-index.c: use error_errno() Nguyễn Thái Ngọc Duy
                   ` (31 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/rm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/rm.c b/builtin/rm.c
index 8829b09..13b9639 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only)
 
 		if (lstat(ce->name, &st) < 0) {
 			if (errno != ENOENT && errno != ENOTDIR)
-				warning("'%s': %s", ce->name, strerror(errno));
+				warning_errno("'%s'", ce->name);
 			/* It already vanished from the working tree */
 			continue;
 		}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 12/41] builtin/update-index.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (10 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 11/41] builtin/rm.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 18:40   ` Eric Sunshine
  2016-05-01 11:14 ` [PATCH 13/41] builtin/upload-archive.c: " Nguyễn Thái Ngọc Duy
                   ` (30 subsequent siblings)
  42 siblings, 1 reply; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

"err" is deleted because it just causes confusion when "errno" is also
used directly in process_lstat_error().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/update-index.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/update-index.c b/builtin/update-index.c
index 1c94ca5..0c539ed 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -251,11 +251,11 @@ static int remove_one_path(const char *path)
  *    succeeds.
  *  - permission error. That's never ok.
  */
-static int process_lstat_error(const char *path, int err)
+static int process_lstat_error(const char *path)
 {
-	if (err == ENOENT || err == ENOTDIR)
+	if (errno == ENOENT || errno == ENOTDIR)
 		return remove_one_path(path);
-	return error("lstat(\"%s\"): %s", path, strerror(errno));
+	return error_errno("lstat(\"%s\")", path);
 }
 
 static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)
@@ -382,7 +382,7 @@ static int process_path(const char *path)
 	 * what to do about the pathname!
 	 */
 	if (lstat(path, &st) < 0)
-		return process_lstat_error(path, errno);
+		return process_lstat_error(path);
 
 	if (S_ISDIR(st.st_mode))
 		return process_directory(path, len, &st);
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 13/41] builtin/upload-archive.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (11 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 12/41] builtin/update-index.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 14/41] builtin/worktree.c: " Nguyễn Thái Ngọc Duy
                   ` (29 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/upload-archive.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index dbfe14f..2caedf1 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -104,8 +104,7 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
 		pfd[1].events = POLLIN;
 		if (poll(pfd, 2, -1) < 0) {
 			if (errno != EINTR) {
-				error("poll failed resuming: %s",
-				      strerror(errno));
+				error_errno("poll failed resuming");
 				sleep(1);
 			}
 			continue;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 14/41] builtin/worktree.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (12 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 13/41] builtin/upload-archive.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 15/41] check-racy.c: " Nguyễn Thái Ngọc Duy
                   ` (28 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/worktree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index d8e3795..331ecf6 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -110,7 +110,7 @@ static void prune_worktrees(void)
 		if (ret < 0 && errno == ENOTDIR)
 			ret = unlink(path.buf);
 		if (ret)
-			error(_("failed to remove: %s"), strerror(errno));
+			error_errno(_("failed to remove '%s'"), path.buf);
 	}
 	closedir(dir);
 	if (!show_only)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 15/41] check-racy.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (13 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 14/41] builtin/worktree.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 16/41] combine-diff.c: " Nguyễn Thái Ngọc Duy
                   ` (27 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 check-racy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/check-racy.c b/check-racy.c
index 00d92a1..24b6542 100644
--- a/check-racy.c
+++ b/check-racy.c
@@ -12,7 +12,7 @@ int main(int ac, char **av)
 		struct stat st;
 
 		if (lstat(ce->name, &st)) {
-			error("lstat(%s): %s", ce->name, strerror(errno));
+			error_errno("lstat(%s)", ce->name);
 			continue;
 		}
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 16/41] combine-diff.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (14 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 15/41] check-racy.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 17/41] compat/win32/syslog.c: use warning_errno() Nguyễn Thái Ngọc Duy
                   ` (26 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 combine-diff.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/combine-diff.c b/combine-diff.c
index 0e1d4b0..8f2313d 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1005,8 +1005,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 			struct strbuf buf = STRBUF_INIT;
 
 			if (strbuf_readlink(&buf, elem->path, st.st_size) < 0) {
-				error("readlink(%s): %s", elem->path,
-				      strerror(errno));
+				error_errno("readlink(%s)", elem->path);
 				return;
 			}
 			result_size = buf.len;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 17/41] compat/win32/syslog.c: use warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (15 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 16/41] combine-diff.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 18:40   ` Eric Sunshine
  2016-05-01 11:14 ` [PATCH 18/41] config.c: use error_errno() Nguyễn Thái Ngọc Duy
                   ` (25 subsequent siblings)
  42 siblings, 1 reply; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 compat/win32/syslog.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c
index b905aea..1c2ae18 100644
--- a/compat/win32/syslog.c
+++ b/compat/win32/syslog.c
@@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...)
 	va_end(ap);
 
 	if (str_len < 0) {
-		warning("vsnprintf failed: '%s'", strerror(errno));
+		warning_errno("vsnprintf failed:");
 		return;
 	}
 
 	str = malloc(st_add(str_len, 1));
 	if (!str) {
-		warning("malloc failed: '%s'", strerror(errno));
+		warning_errno("malloc failed");
 		return;
 	}
 
@@ -45,7 +45,7 @@ void syslog(int priority, const char *fmt, ...)
 	while ((pos = strstr(str, "%1")) != NULL) {
 		str = realloc(str, st_add(++str_len, 1));
 		if (!str) {
-			warning("realloc failed: '%s'", strerror(errno));
+			warning_errno("realloc failed");
 			return;
 		}
 		memmove(pos + 2, pos + 1, strlen(pos));
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 18/41] config.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (16 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 17/41] compat/win32/syslog.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 19/41] connected.c: " Nguyễn Thái Ngọc Duy
                   ` (24 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 config.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/config.c b/config.c
index 10b5c95..80411e4 100644
--- a/config.c
+++ b/config.c
@@ -2012,7 +2012,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 	lock = xcalloc(1, sizeof(struct lock_file));
 	fd = hold_lock_file_for_update(lock, config_filename, 0);
 	if (fd < 0) {
-		error("could not lock config file %s: %s", config_filename, strerror(errno));
+		error_errno("could not lock config file %s", config_filename);
 		free(store.key);
 		ret = CONFIG_NO_LOCK;
 		goto out_free;
@@ -2026,8 +2026,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 		free(store.key);
 
 		if ( ENOENT != errno ) {
-			error("opening %s: %s", config_filename,
-			      strerror(errno));
+			error_errno("opening %s", config_filename);
 			ret = CONFIG_INVALID_FILE; /* same as "invalid config file" */
 			goto out_free;
 		}
@@ -2111,8 +2110,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 		if (contents == MAP_FAILED) {
 			if (errno == ENODEV && S_ISDIR(st.st_mode))
 				errno = EISDIR;
-			error("unable to mmap '%s': %s",
-			      config_filename, strerror(errno));
+			error_errno("unable to mmap '%s'", config_filename);
 			ret = CONFIG_INVALID_FILE;
 			contents = NULL;
 			goto out_free;
@@ -2121,8 +2119,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 		in_fd = -1;
 
 		if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
-			error("chmod on %s failed: %s",
-			      get_lock_file_path(lock), strerror(errno));
+			error_errno("chmod on %s failed", get_lock_file_path(lock));
 			ret = CONFIG_NO_WRITE;
 			goto out_free;
 		}
@@ -2178,8 +2175,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 	}
 
 	if (commit_lock_file(lock) < 0) {
-		error("could not write config file %s: %s", config_filename,
-		      strerror(errno));
+		error_errno("could not write config file %s", config_filename);
 		ret = CONFIG_NO_WRITE;
 		lock = NULL;
 		goto out_free;
@@ -2330,8 +2326,8 @@ int git_config_rename_section_in_file(const char *config_filename,
 	fstat(fileno(config_file), &st);
 
 	if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
-		ret = error("chmod on %s failed: %s",
-			    get_lock_file_path(lock), strerror(errno));
+		ret = error_errno("chmod on %s failed",
+				  get_lock_file_path(lock));
 		goto out;
 	}
 
@@ -2385,8 +2381,8 @@ int git_config_rename_section_in_file(const char *config_filename,
 	fclose(config_file);
 unlock_and_out:
 	if (commit_lock_file(lock) < 0)
-		ret = error("could not write config file %s: %s",
-			    config_filename, strerror(errno));
+		ret = error_errno("could not write config file %s",
+				  config_filename);
 out:
 	free(filename_buf);
 	return ret;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 19/41] connected.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (17 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 18/41] config.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 20/41] copy.c: " Nguyễn Thái Ngọc Duy
                   ` (23 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 connected.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/connected.c b/connected.c
index 299c560..bf1b12e 100644
--- a/connected.c
+++ b/connected.c
@@ -86,17 +86,14 @@ static int check_everything_connected_real(sha1_iterate_fn fn,
 		memcpy(commit, sha1_to_hex(sha1), 40);
 		if (write_in_full(rev_list.in, commit, 41) < 0) {
 			if (errno != EPIPE && errno != EINVAL)
-				error(_("failed write to rev-list: %s"),
-				      strerror(errno));
+				error_errno(_("failed write to rev-list"));
 			err = -1;
 			break;
 		}
 	} while (!fn(cb_data, sha1));
 
-	if (close(rev_list.in)) {
-		error(_("failed to close rev-list's stdin: %s"), strerror(errno));
-		err = -1;
-	}
+	if (close(rev_list.in))
+		err = error_errno(_("failed to close rev-list's stdin"));
 
 	sigchain_pop(SIGPIPE);
 	return finish_command(&rev_list) || err;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 20/41] copy.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (18 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 19/41] connected.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 21/41] credential-cache--daemon.c: use warning_errno() Nguyễn Thái Ngọc Duy
                   ` (22 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 copy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/copy.c b/copy.c
index 574fa1f..4de6a11 100644
--- a/copy.c
+++ b/copy.c
@@ -42,15 +42,15 @@ int copy_file(const char *dst, const char *src, int mode)
 	status = copy_fd(fdi, fdo);
 	switch (status) {
 	case COPY_READ_ERROR:
-		error("copy-fd: read returned %s", strerror(errno));
+		error_errno("copy-fd: read returned");
 		break;
 	case COPY_WRITE_ERROR:
-		error("copy-fd: write returned %s", strerror(errno));
+		error_errno("copy-fd: write returned");
 		break;
 	}
 	close(fdi);
 	if (close(fdo) != 0)
-		return error("%s: close error: %s", dst, strerror(errno));
+		return error_errno("%s: close error", dst);
 
 	if (!status && adjust_shared_perm(dst))
 		return -1;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 21/41] credential-cache--daemon.c: use warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (19 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 20/41] copy.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 22/41] diff-no-index.c: use error_errno() Nguyễn Thái Ngọc Duy
                   ` (21 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 credential-cache--daemon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
index 291c0fd..1f14d56 100644
--- a/credential-cache--daemon.c
+++ b/credential-cache--daemon.c
@@ -179,12 +179,12 @@ static int serve_cache_loop(int fd)
 
 		client = accept(fd, NULL, NULL);
 		if (client < 0) {
-			warning("accept failed: %s", strerror(errno));
+			warning_errno("accept failed");
 			return 1;
 		}
 		client2 = dup(client);
 		if (client2 < 0) {
-			warning("dup failed: %s", strerror(errno));
+			warning_errno("dup failed");
 			close(client);
 			return 1;
 		}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 22/41] diff-no-index.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (20 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 21/41] credential-cache--daemon.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 23/41] editor.c: " Nguyễn Thái Ngọc Duy
                   ` (20 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 diff-no-index.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/diff-no-index.c b/diff-no-index.c
index 03daadb..1f8999b 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -65,8 +65,7 @@ static int populate_from_stdin(struct diff_filespec *s)
 	size_t size = 0;
 
 	if (strbuf_read(&buf, 0, 0) < 0)
-		return error("error while reading from stdin %s",
-				     strerror(errno));
+		return error_errno("error while reading from stdin");
 
 	s->should_munmap = 0;
 	s->data = strbuf_detach(&buf, &size);
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 23/41] editor.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (21 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 22/41] diff-no-index.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 24/41] entry.c: " Nguyễn Thái Ngọc Duy
                   ` (19 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 editor.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/editor.c b/editor.c
index 01c644c..7519ede 100644
--- a/editor.c
+++ b/editor.c
@@ -63,7 +63,6 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
 	if (!buffer)
 		return 0;
 	if (strbuf_read_file(buffer, path, 0) < 0)
-		return error("could not read file '%s': %s",
-				path, strerror(errno));
+		return error_errno("could not read file '%s'", path);
 	return 0;
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 24/41] entry.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (22 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 23/41] editor.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 25/41] fast-import.c: " Nguyễn Thái Ngọc Duy
                   ` (18 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 entry.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/entry.c b/entry.c
index a410957..519e042 100644
--- a/entry.c
+++ b/entry.c
@@ -168,8 +168,8 @@ static int write_entry(struct cache_entry *ce,
 			ret = symlink(new, path);
 			free(new);
 			if (ret)
-				return error("unable to create symlink %s (%s)",
-					     path, strerror(errno));
+				return error_errno("unable to create symlink %s",
+						   path);
 			break;
 		}
 
@@ -186,8 +186,7 @@ static int write_entry(struct cache_entry *ce,
 		fd = open_output_fd(path, ce, to_tempfile);
 		if (fd < 0) {
 			free(new);
-			return error("unable to create file %s (%s)",
-				path, strerror(errno));
+			return error_errno("unable to create file %s", path);
 		}
 
 		wrote = write_in_full(fd, new, size);
@@ -284,8 +283,7 @@ int checkout_entry(struct cache_entry *ce,
 				return error("%s is a directory", path.buf);
 			remove_subtree(&path);
 		} else if (unlink(path.buf))
-			return error("unable to unlink old '%s' (%s)",
-				     path.buf, strerror(errno));
+			return error_errno("unable to unlink old '%s'", path.buf);
 	} else if (state->not_new)
 		return 0;
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 25/41] fast-import.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (23 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 24/41] entry.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 26/41] gpg-interface.c: " Nguyễn Thái Ngọc Duy
                   ` (17 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 fast-import.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index 9fc7093..21881d1 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -414,7 +414,7 @@ static void write_crash_report(const char *err)
 	struct recent_command *rc;
 
 	if (!rpt) {
-		error("can't write crash report %s: %s", loc, strerror(errno));
+		error_errno("can't write crash report %s", loc);
 		free(loc);
 		return;
 	}
@@ -1806,8 +1806,8 @@ static void dump_marks(void)
 		return;
 
 	if (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) {
-		failure |= error("Unable to write marks file %s: %s",
-			export_marks_file, strerror(errno));
+		failure |= error_errno("Unable to write marks file %s",
+				       export_marks_file);
 		return;
 	}
 
@@ -1822,8 +1822,8 @@ static void dump_marks(void)
 
 	dump_marks_helper(f, 0, marks);
 	if (commit_lock_file(&mark_lock)) {
-		failure |= error("Unable to write file %s: %s",
-			export_marks_file, strerror(errno));
+		failure |= error_errno("Unable to write file %s",
+				       export_marks_file);
 		return;
 	}
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 26/41] gpg-interface.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (24 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 25/41] fast-import.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 27/41] grep.c: " Nguyễn Thái Ngọc Duy
                   ` (16 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 gpg-interface.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/gpg-interface.c b/gpg-interface.c
index 2259938..c4b1e8c 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -219,11 +219,9 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
 	args_gpg[0] = gpg_program;
 	fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXXXXXX");
 	if (fd < 0)
-		return error(_("could not create temporary file '%s': %s"),
-			     path, strerror(errno));
+		return error_errno(_("could not create temporary file '%s'"), path);
 	if (write_in_full(fd, signature, signature_size) < 0)
-		return error(_("failed writing detached signature to '%s': %s"),
-			     path, strerror(errno));
+		return error_errno(_("failed writing detached signature to '%s'"), path);
 	close(fd);
 
 	gpg.argv = args_gpg;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 27/41] grep.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (25 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 26/41] gpg-interface.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 18:46   ` Eric Sunshine
  2016-05-01 11:14 ` [PATCH 28/41] http.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (15 subsequent siblings)
  42 siblings, 1 reply; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 grep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grep.c b/grep.c
index 528b652..87c1890 100644
--- a/grep.c
+++ b/grep.c
@@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)
 	if (lstat(filename, &st) < 0) {
 	err_ret:
 		if (errno != ENOENT)
-			error(_("'%s': %s"), filename, strerror(errno));
+			error_errno(_("'%s'"), filename);
 		return -1;
 	}
 	if (!S_ISREG(st.st_mode))
@@ -1743,7 +1743,7 @@ static int grep_source_load_file(struct grep_source *gs)
 		goto err_ret;
 	data = xmallocz(size);
 	if (st.st_size != read_in_full(i, data, size)) {
-		error(_("'%s': short read %s"), filename, strerror(errno));
+		error_errno(_("'%s': short read"), filename);
 		close(i);
 		free(data);
 		return -1;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 28/41] http.c: use error_errno() and warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (26 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 27/41] grep.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 29/41] ident.c: use warning_errno() Nguyễn Thái Ngọc Duy
                   ` (14 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 http.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/http.c b/http.c
index 4304b80..7565c93 100644
--- a/http.c
+++ b/http.c
@@ -446,8 +446,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)
 
 	rc = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&ka, len);
 	if (rc < 0)
-		warning("unable to set SO_KEEPALIVE on socket %s",
-			strerror(errno));
+		warning_errno("unable to set SO_KEEPALIVE on socket");
 
 	return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */
 }
@@ -1894,8 +1893,7 @@ struct http_object_request *new_http_object_request(const char *base_url,
 	}
 
 	if (freq->localfile < 0) {
-		error("Couldn't create temporary file %s: %s",
-		      freq->tmpfile, strerror(errno));
+		error_errno("Couldn't create temporary file %s", freq->tmpfile);
 		goto abort;
 	}
 
@@ -1940,8 +1938,8 @@ struct http_object_request *new_http_object_request(const char *base_url,
 			prev_posn = 0;
 			lseek(freq->localfile, 0, SEEK_SET);
 			if (ftruncate(freq->localfile, 0) < 0) {
-				error("Couldn't truncate temporary file %s: %s",
-					  freq->tmpfile, strerror(errno));
+				error_errno("Couldn't truncate temporary file %s",
+					    freq->tmpfile);
 				goto abort;
 			}
 		}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 29/41] ident.c: use warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (27 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 28/41] http.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 30/41] mailmap.c: use error_errno() Nguyễn Thái Ngọc Duy
                   ` (13 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 ident.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/ident.c b/ident.c
index 4fd82d1..139c528 100644
--- a/ident.c
+++ b/ident.c
@@ -75,14 +75,12 @@ static int add_mailname_host(struct strbuf *buf)
 	mailname = fopen("/etc/mailname", "r");
 	if (!mailname) {
 		if (errno != ENOENT)
-			warning("cannot open /etc/mailname: %s",
-				strerror(errno));
+			warning_errno("cannot open /etc/mailname");
 		return -1;
 	}
 	if (strbuf_getline(&mailnamebuf, mailname) == EOF) {
 		if (ferror(mailname))
-			warning("cannot read /etc/mailname: %s",
-				strerror(errno));
+			warning_errno("cannot read /etc/mailname");
 		strbuf_release(&mailnamebuf);
 		fclose(mailname);
 		return -1;
@@ -125,7 +123,7 @@ static void add_domainname(struct strbuf *out, int *is_bogus)
 	char buf[1024];
 
 	if (gethostname(buf, sizeof(buf))) {
-		warning("cannot get host name: %s", strerror(errno));
+		warning_errno("cannot get host name");
 		strbuf_addstr(out, "(none)");
 		*is_bogus = 1;
 		return;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 30/41] mailmap.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (28 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 29/41] ident.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 31/41] reachable.c: " Nguyễn Thái Ngọc Duy
                   ` (12 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 mailmap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mailmap.c b/mailmap.c
index 9726237..b5c521f 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -189,8 +189,7 @@ static int read_mailmap_file(struct string_list *map, const char *filename,
 	if (!f) {
 		if (errno == ENOENT)
 			return 0;
-		return error("unable to open mailmap at %s: %s",
-			     filename, strerror(errno));
+		return error_errno("unable to open mailmap at %s", filename);
 	}
 
 	while (fgets(buffer, sizeof(buffer), f) != NULL)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 31/41] reachable.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (29 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 30/41] mailmap.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 32/41] rerere.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (11 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 reachable.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/reachable.c b/reachable.c
index ed35201..d0199ca 100644
--- a/reachable.c
+++ b/reachable.c
@@ -119,8 +119,7 @@ static int add_recent_loose(const unsigned char *sha1,
 		 */
 		if (errno == ENOENT)
 			return 0;
-		return error("unable to stat %s: %s",
-			     sha1_to_hex(sha1), strerror(errno));
+		return error_errno("unable to stat %s", sha1_to_hex(sha1));
 	}
 
 	add_recent_object(sha1, st.st_mtime, data);
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 32/41] rerere.c: use error_errno() and warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (30 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 31/41] reachable.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 33/41] run-command.c: use error_errno() Nguyễn Thái Ngọc Duy
                   ` (10 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 rerere.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/rerere.c b/rerere.c
index c8b9f40..1810c04 100644
--- a/rerere.c
+++ b/rerere.c
@@ -501,8 +501,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
 		error("There were errors while writing %s (%s)",
 		      path, strerror(io.io.wrerror));
 	if (io.io.output && fclose(io.io.output))
-		io.io.wrerror = error("Failed to flush %s: %s",
-				      path, strerror(errno));
+		io.io.wrerror = error_errno("Failed to flush %s", path);
 
 	if (hunk_no < 0) {
 		if (output)
@@ -684,20 +683,17 @@ static int merge(const struct rerere_id *id, const char *path)
 	 * Mark that "postimage" was used to help gc.
 	 */
 	if (utime(rerere_path(id, "postimage"), NULL) < 0)
-		warning("failed utime() on %s: %s",
-			rerere_path(id, "postimage"),
-			strerror(errno));
+		warning_errno("failed utime() on %s",
+			      rerere_path(id, "postimage"));
 
 	/* Update "path" with the resolution */
 	f = fopen(path, "w");
 	if (!f)
-		return error("Could not open %s: %s", path,
-			     strerror(errno));
+		return error_errno("Could not open %s", path);
 	if (fwrite(result.ptr, result.size, 1, f) != 1)
-		error("Could not write %s: %s", path, strerror(errno));
+		error_errno("Could not write %s", path);
 	if (fclose(f))
-		return error("Writing %s failed: %s", path,
-			     strerror(errno));
+		return error_errno("Writing %s failed", path);
 
 out:
 	free(cur.ptr);
@@ -1071,7 +1067,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
 	if (unlink(filename))
 		return (errno == ENOENT
 			? error("no remembered resolution for %s", path)
-			: error("cannot unlink %s: %s", filename, strerror(errno)));
+			: error_errno("cannot unlink %s", filename));
 
 	/*
 	 * Update the preimage so that the user can resolve the
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 33/41] run-command.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (31 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 32/41] rerere.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 34/41] sequencer.c: " Nguyễn Thái Ngọc Duy
                   ` (9 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 run-command.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/run-command.c b/run-command.c
index e4593cd..842c8d1 100644
--- a/run-command.c
+++ b/run-command.c
@@ -233,7 +233,7 @@ static int wait_or_whine(pid_t pid, const char *argv0, int in_signal)
 
 	if (waiting < 0) {
 		failed_errno = errno;
-		error("waitpid for %s failed: %s", argv0, strerror(errno));
+		error_errno("waitpid for %s failed", argv0);
 	} else if (waiting != pid) {
 		error("waitpid is confused (%s)", argv0);
 	} else if (WIFSIGNALED(status)) {
@@ -420,8 +420,7 @@ fail_pipe:
 		}
 	}
 	if (cmd->pid < 0)
-		error("cannot fork() for %s: %s", cmd->argv[0],
-			strerror(errno));
+		error_errno("cannot fork() for %s", cmd->argv[0]);
 	else if (cmd->clean_on_exit)
 		mark_child_for_cleanup(cmd->pid);
 
@@ -482,7 +481,7 @@ fail_pipe:
 			cmd->dir, fhin, fhout, fherr);
 	failed_errno = errno;
 	if (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))
-		error("cannot spawn %s: %s", cmd->argv[0], strerror(errno));
+		error_errno("cannot spawn %s", cmd->argv[0]);
 	if (cmd->clean_on_exit && cmd->pid >= 0)
 		mark_child_for_cleanup(cmd->pid);
 
@@ -703,7 +702,7 @@ int start_async(struct async *async)
 		if (pipe(fdin) < 0) {
 			if (async->out > 0)
 				close(async->out);
-			return error("cannot create pipe: %s", strerror(errno));
+			return error_errno("cannot create pipe");
 		}
 		async->in = fdin[1];
 	}
@@ -715,7 +714,7 @@ int start_async(struct async *async)
 				close_pair(fdin);
 			else if (async->in)
 				close(async->in);
-			return error("cannot create pipe: %s", strerror(errno));
+			return error_errno("cannot create pipe");
 		}
 		async->out = fdout[0];
 	}
@@ -740,7 +739,7 @@ int start_async(struct async *async)
 
 	async->pid = fork();
 	if (async->pid < 0) {
-		error("fork (async) failed: %s", strerror(errno));
+		error_errno("fork (async) failed");
 		goto error;
 	}
 	if (!async->pid) {
@@ -787,7 +786,7 @@ int start_async(struct async *async)
 	{
 		int err = pthread_create(&async->tid, NULL, run_thread, async);
 		if (err) {
-			error("cannot create thread: %s", strerror(err));
+			error_errno("cannot create thread");
 			goto error;
 		}
 	}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 34/41] sequencer.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (32 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 33/41] run-command.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 35/41] server-info.c: " Nguyễn Thái Ngọc Duy
                   ` (8 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 sequencer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index e66f2fe..4687ad4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -875,8 +875,7 @@ static int sequencer_rollback(struct replay_opts *opts)
 		return rollback_single_pick();
 	}
 	if (!f)
-		return error(_("cannot open %s: %s"), git_path_head_file(),
-						strerror(errno));
+		return error_errno(_("cannot open %s"), git_path_head_file());
 	if (strbuf_getline_lf(&buf, f)) {
 		error(_("cannot read %s: %s"), git_path_head_file(),
 		      ferror(f) ?  strerror(errno) : _("unexpected end of file"));
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 35/41] server-info.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (33 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 34/41] sequencer.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 36/41] sha1_file.c: use {error,die,warning}_errno() Nguyễn Thái Ngọc Duy
                   ` (7 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 server-info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server-info.c b/server-info.c
index 5a86e29..75dd677 100644
--- a/server-info.c
+++ b/server-info.c
@@ -36,7 +36,7 @@ static int update_info_file(char *path, int (*generate)(FILE *))
 
 out:
 	if (ret) {
-		error("unable to update %s: %s", path, strerror(errno));
+		error_errno("unable to update %s", path);
 		if (fp)
 			fclose(fp);
 		else if (fd >= 0)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 36/41] sha1_file.c: use {error,die,warning}_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (34 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 35/41] server-info.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 37/41] transport-helper.c: use error_errno() Nguyễn Thái Ngọc Duy
                   ` (6 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 sha1_file.c | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index d0f2aa0..a7f45b3 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1107,9 +1107,8 @@ unsigned char *use_pack(struct packed_git *p,
 				PROT_READ, MAP_PRIVATE,
 				p->pack_fd, win->offset);
 			if (win->base == MAP_FAILED)
-				die("packfile %s cannot be mapped: %s",
-					p->pack_name,
-					strerror(errno));
+				die_errno("packfile %s cannot be mapped",
+					  p->pack_name);
 			if (!win->offset && win->len == p->pack_size
 				&& !p->do_not_close)
 				close_pack_fd(p);
@@ -1279,8 +1278,8 @@ static void prepare_packed_git_one(char *objdir, int local)
 	dir = opendir(path.buf);
 	if (!dir) {
 		if (errno != ENOENT)
-			error("unable to open object pack directory: %s: %s",
-			      path.buf, strerror(errno));
+			error_errno("unable to open object pack directory: %s",
+				    path.buf);
 		strbuf_release(&path);
 		return;
 	}
@@ -2984,7 +2983,7 @@ int finalize_object_file(const char *tmpfile, const char *filename)
 	unlink_or_warn(tmpfile);
 	if (ret) {
 		if (ret != EEXIST) {
-			return error("unable to write sha1 filename %s: %s", filename, strerror(ret));
+			return error_errno("unable to write sha1 filename %s", filename);
 		}
 		/* FIXME!!! Collision check here ? */
 	}
@@ -2998,7 +2997,7 @@ out:
 static int write_buffer(int fd, const void *buf, size_t len)
 {
 	if (write_in_full(fd, buf, len) < 0)
-		return error("file write error (%s)", strerror(errno));
+		return error_errno("file write error");
 	return 0;
 }
 
@@ -3081,7 +3080,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
 		if (errno == EACCES)
 			return error("insufficient permission for adding an object to repository database %s", get_object_directory());
 		else
-			return error("unable to create temporary file: %s", strerror(errno));
+			return error_errno("unable to create temporary file");
 	}
 
 	/* Set it up */
@@ -3126,8 +3125,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
 		utb.actime = mtime;
 		utb.modtime = mtime;
 		if (utime(tmp_file.buf, &utb) < 0)
-			warning("failed utime() on %s: %s",
-				tmp_file.buf, strerror(errno));
+			warning_errno("failed utime() on %s", tmp_file.buf);
 	}
 
 	return finalize_object_file(tmp_file.buf, filename);
@@ -3360,7 +3358,7 @@ static int index_core(unsigned char *sha1, int fd, size_t size,
 		if (size == read_in_full(fd, buf, size))
 			ret = index_mem(sha1, buf, size, type, path, flags);
 		else
-			ret = error("short read %s", strerror(errno));
+			ret = error_errno("short read");
 		free(buf);
 	} else {
 		void *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
@@ -3425,18 +3423,14 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned
 	case S_IFREG:
 		fd = open(path, O_RDONLY);
 		if (fd < 0)
-			return error("open(\"%s\"): %s", path,
-				     strerror(errno));
+			return error_errno("open(\"%s\")", path);
 		if (index_fd(sha1, fd, st, OBJ_BLOB, path, flags) < 0)
 			return error("%s: failed to insert into database",
 				     path);
 		break;
 	case S_IFLNK:
-		if (strbuf_readlink(&sb, path, st->st_size)) {
-			char *errstr = strerror(errno);
-			return error("readlink(\"%s\"): %s", path,
-			             errstr);
-		}
+		if (strbuf_readlink(&sb, path, st->st_size))
+			return error_errno("readlink(\"%s\")", path);
 		if (!(flags & HASH_WRITE_OBJECT))
 			hash_sha1_file(sb.buf, sb.len, blob_type, sha1);
 		else if (write_sha1_file(sb.buf, sb.len, blob_type, sha1))
@@ -3492,7 +3486,7 @@ static int for_each_file_in_obj_subdir(int subdir_nr,
 	if (!dir) {
 		if (errno == ENOENT)
 			return 0;
-		return error("unable to open %s: %s", path->buf, strerror(errno));
+		return error_errno("unable to open %s", path->buf);
 	}
 
 	while ((de = readdir(dir))) {
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 37/41] transport-helper.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (35 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 36/41] sha1_file.c: use {error,die,warning}_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 38/41] unpack-trees.c: " Nguyễn Thái Ngọc Duy
                   ` (5 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 transport-helper.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index b934183..f09fadc 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1166,7 +1166,7 @@ static int udt_do_read(struct unidirectional_transfer *t)
 	bytes = read(t->src, t->buf + t->bufuse, BUFFERSIZE - t->bufuse);
 	if (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN &&
 		errno != EINTR) {
-		error("read(%s) failed: %s", t->src_name, strerror(errno));
+		error_errno("read(%s) failed", t->src_name);
 		return -1;
 	} else if (bytes == 0) {
 		transfer_debug("%s EOF (with %i bytes in buffer)",
@@ -1193,7 +1193,7 @@ static int udt_do_write(struct unidirectional_transfer *t)
 	transfer_debug("%s is writable", t->dest_name);
 	bytes = xwrite(t->dest, t->buf, t->bufuse);
 	if (bytes < 0 && errno != EWOULDBLOCK) {
-		error("write(%s) failed: %s", t->dest_name, strerror(errno));
+		error_errno("write(%s) failed", t->dest_name);
 		return -1;
 	} else if (bytes > 0) {
 		t->bufuse -= bytes;
@@ -1306,7 +1306,7 @@ static int tloop_join(pid_t pid, const char *name)
 {
 	int tret;
 	if (waitpid(pid, &tret, 0) < 0) {
-		error("%s process failed to wait: %s", name, strerror(errno));
+		error_errno("%s process failed to wait", name);
 		return 1;
 	}
 	if (!WIFEXITED(tret) || WEXITSTATUS(tret)) {
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 38/41] unpack-trees.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (36 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 37/41] transport-helper.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 39/41] upload-pack.c: " Nguyễn Thái Ngọc Duy
                   ` (4 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 unpack-trees.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index 9f55cc2..bb0d142 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1499,8 +1499,7 @@ static int verify_absent_1(const struct cache_entry *ce,
 
 		path = xmemdupz(ce->name, len);
 		if (lstat(path, &st))
-			ret = error("cannot stat '%s': %s", path,
-					strerror(errno));
+			ret = error_errno("cannot stat '%s'", path);
 		else
 			ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,
 						 &st, error_type, o);
@@ -1508,8 +1507,7 @@ static int verify_absent_1(const struct cache_entry *ce,
 		return ret;
 	} else if (lstat(ce->name, &st)) {
 		if (errno != ENOENT)
-			return error("cannot stat '%s': %s", ce->name,
-				     strerror(errno));
+			return error_errno("cannot stat '%s'", ce->name);
 		return 0;
 	} else {
 		return check_ok_to_remove(ce->name, ce_namelen(ce),
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 39/41] upload-pack.c: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (37 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 38/41] unpack-trees.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 40/41] vcs-svn: " Nguyễn Thái Ngọc Duy
                   ` (3 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 upload-pack.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/upload-pack.c b/upload-pack.c
index dc802a0..f19444d 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -174,8 +174,7 @@ static void create_pack_file(void)
 
 		if (ret < 0) {
 			if (errno != EINTR) {
-				error("poll failed, resuming: %s",
-				      strerror(errno));
+				error_errno("poll failed, resuming");
 				sleep(1);
 			}
 			continue;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 40/41] vcs-svn: use error_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (38 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 39/41] upload-pack.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:14 ` [PATCH 41/41] wrapper.c: use warning_errno() Nguyễn Thái Ngọc Duy
                   ` (2 subsequent siblings)
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 vcs-svn/line_buffer.c    | 4 ++--
 vcs-svn/sliding_window.c | 2 +-
 vcs-svn/svndiff.c        | 4 ++--
 vcs-svn/svndump.c        | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/vcs-svn/line_buffer.c b/vcs-svn/line_buffer.c
index 57cc1ce..e416caf 100644
--- a/vcs-svn/line_buffer.c
+++ b/vcs-svn/line_buffer.c
@@ -53,9 +53,9 @@ long buffer_tmpfile_prepare_to_read(struct line_buffer *buf)
 {
 	long pos = ftell(buf->infile);
 	if (pos < 0)
-		return error("ftell error: %s", strerror(errno));
+		return error_errno("ftell error");
 	if (fseek(buf->infile, 0, SEEK_SET))
-		return error("seek error: %s", strerror(errno));
+		return error_errno("seek error");
 	return pos;
 }
 
diff --git a/vcs-svn/sliding_window.c b/vcs-svn/sliding_window.c
index f11d490..06d273c 100644
--- a/vcs-svn/sliding_window.c
+++ b/vcs-svn/sliding_window.c
@@ -12,7 +12,7 @@ static int input_error(struct line_buffer *file)
 {
 	if (!buffer_ferror(file))
 		return error("delta preimage ends early");
-	return error("cannot read delta preimage: %s", strerror(errno));
+	return error_errno("cannot read delta preimage");
 }
 
 static int skip_or_whine(struct line_buffer *file, off_t gap)
diff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c
index 74c97c4..75c7531 100644
--- a/vcs-svn/svndiff.c
+++ b/vcs-svn/svndiff.c
@@ -64,13 +64,13 @@ static int write_strbuf(struct strbuf *sb, FILE *out)
 {
 	if (fwrite(sb->buf, 1, sb->len, out) == sb->len)	/* Success. */
 		return 0;
-	return error("cannot write delta postimage: %s", strerror(errno));
+	return error_errno("cannot write delta postimage");
 }
 
 static int error_short_read(struct line_buffer *input)
 {
 	if (buffer_ferror(input))
-		return error("error reading delta: %s", strerror(errno));
+		return error_errno("error reading delta");
 	return error("invalid delta: unexpected end of file");
 }
 
diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c
index 31d1d83..e4b3959 100644
--- a/vcs-svn/svndump.c
+++ b/vcs-svn/svndump.c
@@ -501,7 +501,7 @@ static void init(int report_fd)
 int svndump_init(const char *filename)
 {
 	if (buffer_init(&input, filename))
-		return error("cannot open %s: %s", filename ? filename : "NULL", strerror(errno));
+		return error_errno("cannot open %s", filename ? filename : "NULL");
 	init(REPORT_FILENO);
 	return 0;
 }
@@ -509,7 +509,7 @@ int svndump_init(const char *filename)
 int svndump_init_fd(int in_fd, int back_fd)
 {
 	if(buffer_fdinit(&input, xdup(in_fd)))
-		return error("cannot open fd %d: %s", in_fd, strerror(errno));
+		return error_errno("cannot open fd %d", in_fd);
 	init(xdup(back_fd));
 	return 0;
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH 41/41] wrapper.c: use warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (39 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 40/41] vcs-svn: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:14 ` Nguyễn Thái Ngọc Duy
  2016-05-01 11:21 ` [PATCH 00/41] Add and use error_errno() and warning_errno() Duy Nguyen
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
  42 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-01 11:14 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 wrapper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/wrapper.c b/wrapper.c
index 9afc1a0..3df2fe0 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -572,7 +572,7 @@ static int warn_if_unremovable(const char *op, const char *file, int rc)
 	if (!rc || errno == ENOENT)
 		return 0;
 	err = errno;
-	warning("unable to %s %s: %s", op, file, strerror(errno));
+	warning_errno("unable to %s %s", op, file);
 	errno = err;
 	return rc;
 }
@@ -608,7 +608,7 @@ int remove_or_warn(unsigned int mode, const char *file)
 
 void warn_on_inaccessible(const char *path)
 {
-	warning(_("unable to access '%s': %s"), path, strerror(errno));
+	warning_errno(_("unable to access '%s'"), path);
 }
 
 static int access_error_is_ok(int err, unsigned flag)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* Re: [PATCH 00/41] Add and use error_errno() and warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (40 preceding siblings ...)
  2016-05-01 11:14 ` [PATCH 41/41] wrapper.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 11:21 ` Duy Nguyen
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
  42 siblings, 0 replies; 145+ messages in thread
From: Duy Nguyen @ 2016-05-01 11:21 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin

On Sun, May 01, 2016 at 06:14:16PM +0700, Nguyễn Thái Ngọc Duy wrote:
> This is a spinoff from my worktree-move topic. This series adds
> die_errno() companions, error_errno() and warning_errno(), and use them
> where applicable to reduce the amount of typing (in future).

I had this patch in the series but excluded it before sending because
there is something wrong about it.

The patch shows two code blocks that follow the same pattern:
closesocket() then print an error with strerror(). The second block
suggests that closesocket() can change errno. But if that's true, the
first block should do the same.

Which is right? Fix the first block to save errno, or drop the saving
in the second block?

diff --git a/compat/mingw.c b/compat/mingw.c
index 0413d5c..b6de02c 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1555,8 +1555,7 @@ int mingw_socket(int domain, int type, int protocol)
 	/* convert into a file descriptor */
 	if ((sockfd = _open_osfhandle(s, O_RDWR|O_BINARY)) < 0) {
 		closesocket(s);
-		return error("unable to make a socket file descriptor: %s",
-			strerror(errno));
+		return error_errno("unable to make a socket file descriptor");
 	}
 	return sockfd;
 }
@@ -1606,10 +1605,8 @@ int mingw_accept(int sockfd1, struct sockaddr *sa, socklen_t *sz)
 
 	/* convert into a file descriptor */
 	if ((sockfd2 = _open_osfhandle(s2, O_RDWR|O_BINARY)) < 0) {
-		int err = errno;
 		closesocket(s2);
-		return error("unable to make a socket file descriptor: %s",
-			strerror(err));
+		return error_errno("unable to make a socket file descriptor");
 	}
 	return sockfd2;
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* Re: [PATCH 01/41] usage.c: move format processing out of die_errno()
  2016-05-01 11:14 ` [PATCH 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 18:23   ` Eric Sunshine
  2016-05-02 18:26     ` Junio C Hamano
  0 siblings, 1 reply; 145+ messages in thread
From: Eric Sunshine @ 2016-05-01 18:23 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List

On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> fmt_with_err() will be shared with the coming error_errno() and
> warning_errno().
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/usage.c b/usage.c
> @@ -109,19 +109,12 @@ void NORETURN die(const char *err, ...)
> -void NORETURN die_errno(const char *fmt, ...)
> +static const char *fmt_with_err(const char *fmt)
>  {
> -       va_list params;
> -       char fmt_with_err[1024];
> +       static char fmt_with_err[1024];

Rather than this static buffer, did you consider having the caller
pass in the buffer?

    static const char *fmt_with_err(char *buf, size_t n, const char *fmt)
    {
        ...
        snprintf(buf, n, "%s: %s", fmt, str_error);
        return buf;
    }

    void die_errno(const char *fmt, ...)
    {
        char fmtbuf[1024];
        ...
        die_routine(fmt_with_err(fmtbuf, sizeof(fmtbuf), fmt),
            params);
        ...
    }

Better? Worse? Indifferent?

>         char str_error[256], *err;
>         int i, j;
>
> -       if (die_is_recursing()) {
> -               fputs("fatal: recursion detected in die_errno handler\n",
> -                       stderr);
> -               exit(128);
> -       }
> -
>         err = strerror(errno);
>         for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {
>                 if ((str_error[j++] = err[i++]) != '%')
> @@ -137,9 +130,21 @@ void NORETURN die_errno(const char *fmt, ...)
>         }
>         str_error[j] = 0;
>         snprintf(fmt_with_err, sizeof(fmt_with_err), "%s: %s", fmt, str_error);
> +       return fmt_with_err;
> +}
> +
> +void NORETURN die_errno(const char *fmt, ...)
> +{
> +       va_list params;
> +
> +       if (die_is_recursing()) {
> +               fputs("fatal: recursion detected in die_errno handler\n",
> +                       stderr);
> +               exit(128);
> +       }
>
>         va_start(params, fmt);
> -       die_routine(fmt_with_err, params);
> +       die_routine(fmt_with_err(fmt), params);
>         va_end(params);
>  }

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH 08/41] builtin/mailsplit.c: use error_errno()
  2016-05-01 11:14 ` [PATCH 08/41] builtin/mailsplit.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 18:31   ` Eric Sunshine
  0 siblings, 0 replies; 145+ messages in thread
From: Eric Sunshine @ 2016-05-01 18:31 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List

On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
> @@ -109,7 +109,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)
>                 if ((dir = opendir(name)) == NULL) {
>                         if (errno == ENOENT)
>                                 continue;
> -                       error("cannot opendir %s (%s)", name, strerror(errno));
> +                       error_errno("cannot opendir %s", name);
>                         goto out;
>                 }
> @@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
>         int file_done = 0;
>
>         if (!f) {
> -               error("cannot open mbox %s", file);
> +               error_errno("cannot open mbox %s", file);

Unlike other cases in this patch which already printed
strerror(errno), this one didn't, and the patch upgrades it to do so,
which is valid since errno will not be clobbered between the preceding
fopen() and this error_errno(). I see other patches in the series do
likewise.

The error("cannot read mbox %s"" just below this code doesn't deserve
the same treatment because strbuf_getwholeline() doesn't promise a
meaningful errno. Okay.

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH 12/41] builtin/update-index.c: use error_errno()
  2016-05-01 11:14 ` [PATCH 12/41] builtin/update-index.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 18:40   ` Eric Sunshine
  2016-05-02  8:47     ` Duy Nguyen
  0 siblings, 1 reply; 145+ messages in thread
From: Eric Sunshine @ 2016-05-01 18:40 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List

On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> "err" is deleted because it just causes confusion when "errno" is also
> used directly in process_lstat_error().

Despite the function name which may imply that it is consulting errno,
this change makes me feel slightly uncomfortable since it increases
coupling. Whereas consulting of errno had been explicit, with this
change, it becomes implicit, and someone changing the code needs to be
extra careful about ensuring that errno does not get clobbered.

Not a big objection, but a nagging doubt...

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/builtin/update-index.c b/builtin/update-index.c
> @@ -251,11 +251,11 @@ static int remove_one_path(const char *path)
> -static int process_lstat_error(const char *path, int err)
> +static int process_lstat_error(const char *path)
>  {
> -       if (err == ENOENT || err == ENOTDIR)
> +       if (errno == ENOENT || errno == ENOTDIR)
>                 return remove_one_path(path);
> -       return error("lstat(\"%s\"): %s", path, strerror(errno));
> +       return error_errno("lstat(\"%s\")", path);
>  }
>
>  static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)
> @@ -382,7 +382,7 @@ static int process_path(const char *path)
>          * what to do about the pathname!
>          */
>         if (lstat(path, &st) < 0)
> -               return process_lstat_error(path, errno);
> +               return process_lstat_error(path);
>
>         if (S_ISDIR(st.st_mode))
>                 return process_directory(path, len, &st);

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH 17/41] compat/win32/syslog.c: use warning_errno()
  2016-05-01 11:14 ` [PATCH 17/41] compat/win32/syslog.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-01 18:40   ` Eric Sunshine
  0 siblings, 0 replies; 145+ messages in thread
From: Eric Sunshine @ 2016-05-01 18:40 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List

On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c
> @@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...)
>         va_end(ap);
>
>         if (str_len < 0) {
> -               warning("vsnprintf failed: '%s'", strerror(errno));
> +               warning_errno("vsnprintf failed:");

s/failed:/failed/

>                 return;
>         }

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH 27/41] grep.c: use error_errno()
  2016-05-01 11:14 ` [PATCH 27/41] grep.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-01 18:46   ` Eric Sunshine
  0 siblings, 0 replies; 145+ messages in thread
From: Eric Sunshine @ 2016-05-01 18:46 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List

On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/grep.c b/grep.c
> @@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)
>         if (lstat(filename, &st) < 0) {
>         err_ret:
>                 if (errno != ENOENT)
> -                       error(_("'%s': %s"), filename, strerror(errno));
> +                       error_errno(_("'%s'"), filename);

Does this still need to be wrapped in _(...)? (Did it ever?)

>                 return -1;
>         }
>         if (!S_ISREG(st.st_mode))
> @@ -1743,7 +1743,7 @@ static int grep_source_load_file(struct grep_source *gs)
>                 goto err_ret;
>         data = xmallocz(size);
>         if (st.st_size != read_in_full(i, data, size)) {
> -               error(_("'%s': short read %s"), filename, strerror(errno));
> +               error_errno(_("'%s': short read"), filename);
>                 close(i);
>                 free(data);
>                 return -1;

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH 12/41] builtin/update-index.c: use error_errno()
  2016-05-01 18:40   ` Eric Sunshine
@ 2016-05-02  8:47     ` Duy Nguyen
  0 siblings, 0 replies; 145+ messages in thread
From: Duy Nguyen @ 2016-05-02  8:47 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git List

On Mon, May 2, 2016 at 1:40 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>> "err" is deleted because it just causes confusion when "errno" is also
>> used directly in process_lstat_error().
>
> Despite the function name which may imply that it is consulting errno,
> this change makes me feel slightly uncomfortable since it increases
> coupling. Whereas consulting of errno had been explicit, with this
> change, it becomes implicit, and someone changing the code needs to be
> extra careful about ensuring that errno does not get clobbered.
>
> Not a big objection, but a nagging doubt...

We could s/errno/err/ in this function and not convert to
error_errno(). Or we could delete this function and move the code back
to its only call site in process_path()?

>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>> diff --git a/builtin/update-index.c b/builtin/update-index.c
>> @@ -251,11 +251,11 @@ static int remove_one_path(const char *path)
>> -static int process_lstat_error(const char *path, int err)
>> +static int process_lstat_error(const char *path)
>>  {
>> -       if (err == ENOENT || err == ENOTDIR)
>> +       if (errno == ENOENT || errno == ENOTDIR)
>>                 return remove_one_path(path);
>> -       return error("lstat(\"%s\"): %s", path, strerror(errno));
>> +       return error_errno("lstat(\"%s\")", path);
>>  }
>>
>>  static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)
>> @@ -382,7 +382,7 @@ static int process_path(const char *path)
>>          * what to do about the pathname!
>>          */
>>         if (lstat(path, &st) < 0)
>> -               return process_lstat_error(path, errno);
>> +               return process_lstat_error(path);
>>
>>         if (S_ISDIR(st.st_mode))
>>                 return process_directory(path, len, &st);
-- 
Duy

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH 01/41] usage.c: move format processing out of die_errno()
  2016-05-01 18:23   ` Eric Sunshine
@ 2016-05-02 18:26     ` Junio C Hamano
  2016-05-03  4:45       ` Jeff King
  0 siblings, 1 reply; 145+ messages in thread
From: Junio C Hamano @ 2016-05-02 18:26 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Nguyễn Thái Ngọc Duy, Git List

Eric Sunshine <sunshine@sunshineco.com> writes:

> On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>> fmt_with_err() will be shared with the coming error_errno() and
>> warning_errno().
>>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>> diff --git a/usage.c b/usage.c
>> @@ -109,19 +109,12 @@ void NORETURN die(const char *err, ...)
>> -void NORETURN die_errno(const char *fmt, ...)
>> +static const char *fmt_with_err(const char *fmt)
>>  {
>> -       va_list params;
>> -       char fmt_with_err[1024];
>> +       static char fmt_with_err[1024];
>
> Rather than this static buffer, did you consider having the caller
> pass in the buffer?
>
>     static const char *fmt_with_err(char *buf, size_t n, const char *fmt)
>     {
>         ...
>         snprintf(buf, n, "%s: %s", fmt, str_error);
>         return buf;
>     }
>
>     void die_errno(const char *fmt, ...)
>     {
>         char fmtbuf[1024];
>         ...
>         die_routine(fmt_with_err(fmtbuf, sizeof(fmtbuf), fmt),
>             params);
>         ...
>     }
>
> Better? Worse? Indifferent?

Caller supplied buffer would be the way to go when multiple threads
could be showing errors and warnings, right?

It would not make too much of a difference for die(), though.

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH 01/41] usage.c: move format processing out of die_errno()
  2016-05-02 18:26     ` Junio C Hamano
@ 2016-05-03  4:45       ` Jeff King
  2016-05-03  9:39         ` Duy Nguyen
  0 siblings, 1 reply; 145+ messages in thread
From: Jeff King @ 2016-05-03  4:45 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Eric Sunshine, Nguyễn Thái Ngọc Duy, Git List

On Mon, May 02, 2016 at 11:26:02AM -0700, Junio C Hamano wrote:

> Caller supplied buffer would be the way to go when multiple threads
> could be showing errors and warnings, right?
> 
> It would not make too much of a difference for die(), though.

I think it can matter for die(). This is happening above the pluggable
die_routine() layer, so it's possible for an async task to call die()
which will end in pthread_exit(), while the main program is calling
die() to end in regular exit().

I imagine it's exceedingly unlikely, and of course both threads are
dying anyway, but it could result in some pretty weird memory errors.
It's probably worth taking precautions against, especially because it's
to easy to do so.

-Peff

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH 01/41] usage.c: move format processing out of die_errno()
  2016-05-03  4:45       ` Jeff King
@ 2016-05-03  9:39         ` Duy Nguyen
  2016-05-03 10:15           ` Jeff King
  0 siblings, 1 reply; 145+ messages in thread
From: Duy Nguyen @ 2016-05-03  9:39 UTC (permalink / raw)
  To: Jeff King; +Cc: Junio C Hamano, Eric Sunshine, Git List

On Tue, May 3, 2016 at 11:45 AM, Jeff King <peff@peff.net> wrote:
> On Mon, May 02, 2016 at 11:26:02AM -0700, Junio C Hamano wrote:
>
>> Caller supplied buffer would be the way to go when multiple threads
>> could be showing errors and warnings, right?
>>
>> It would not make too much of a difference for die(), though.
>
> I think it can matter for die(). This is happening above the pluggable
> die_routine() layer, so it's possible for an async task to call die()
> which will end in pthread_exit(), while the main program is calling
> die() to end in regular exit().
>
> I imagine it's exceedingly unlikely, and of course both threads are
> dying anyway, but it could result in some pretty weird memory errors.
> It's probably worth taking precautions against, especially because it's
> to easy to do so.

So, sum it up, the new fmt_with_err() will take a buffer and size.
die_errno() sticks to its static buffer as before. error_errno() and
warning_errno() can allocate 1k on stack to be more
multithread-friendly. Let me know if some other change is needed.
-- 
Duy

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH 01/41] usage.c: move format processing out of die_errno()
  2016-05-03  9:39         ` Duy Nguyen
@ 2016-05-03 10:15           ` Jeff King
  0 siblings, 0 replies; 145+ messages in thread
From: Jeff King @ 2016-05-03 10:15 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Junio C Hamano, Eric Sunshine, Git List

On Tue, May 03, 2016 at 04:39:45PM +0700, Duy Nguyen wrote:

> On Tue, May 3, 2016 at 11:45 AM, Jeff King <peff@peff.net> wrote:
> > On Mon, May 02, 2016 at 11:26:02AM -0700, Junio C Hamano wrote:
> >
> >> Caller supplied buffer would be the way to go when multiple threads
> >> could be showing errors and warnings, right?
> >>
> >> It would not make too much of a difference for die(), though.
> >
> > I think it can matter for die(). This is happening above the pluggable
> > die_routine() layer, so it's possible for an async task to call die()
> > which will end in pthread_exit(), while the main program is calling
> > die() to end in regular exit().
> >
> > I imagine it's exceedingly unlikely, and of course both threads are
> > dying anyway, but it could result in some pretty weird memory errors.
> > It's probably worth taking precautions against, especially because it's
> > to easy to do so.
> 
> So, sum it up, the new fmt_with_err() will take a buffer and size.
> die_errno() sticks to its static buffer as before. error_errno() and
> warning_errno() can allocate 1k on stack to be more
> multithread-friendly. Let me know if some other change is needed.

Yes, though note that die_errno() currently has a stack buffer, not a
static one. It should remain that way (and error_errno and warning_errno
should follow suit) to be friendly to multi-threading.

-Peff

^ permalink raw reply	[flat|nested] 145+ messages in thread

* [PATCH v2 00/41] Add and use error_errno() and warning_errno()
  2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                   ` (41 preceding siblings ...)
  2016-05-01 11:21 ` [PATCH 00/41] Add and use error_errno() and warning_errno() Duy Nguyen
@ 2016-05-03 12:03 ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
                     ` (43 more replies)
  42 siblings, 44 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Changes are in

  [01/41] usage.c: move format processing out of die_errno()
  [02/41] usage.c: add warning_errno() and error_errno()
  [12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error
  [17/41] compat/win32/syslog.c: use warning_errno()
  [27/41] grep.c: use error_errno()

12/41 is basically a revert with s/strerror(errno)/strerror(err)/.
Interdiff from v1

-- 8< --
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 0c539ed..b8b8522 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -251,11 +251,11 @@ static int remove_one_path(const char *path)
  *    succeeds.
  *  - permission error. That's never ok.
  */
-static int process_lstat_error(const char *path)
+static int process_lstat_error(const char *path, int err)
 {
-	if (errno == ENOENT || errno == ENOTDIR)
+	if (err == ENOENT || err == ENOTDIR)
 		return remove_one_path(path);
-	return error_errno("lstat(\"%s\")", path);
+	return error("lstat(\"%s\"): %s", path, strerror(err));
 }
 
 static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)
@@ -382,7 +382,7 @@ static int process_path(const char *path)
 	 * what to do about the pathname!
 	 */
 	if (lstat(path, &st) < 0)
-		return process_lstat_error(path);
+		return process_lstat_error(path, errno);
 
 	if (S_ISDIR(st.st_mode))
 		return process_directory(path, len, &st);
diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c
index 1c2ae18..6c7c9b6 100644
--- a/compat/win32/syslog.c
+++ b/compat/win32/syslog.c
@@ -28,7 +28,7 @@ void syslog(int priority, const char *fmt, ...)
 	va_end(ap);
 
 	if (str_len < 0) {
-		warning_errno("vsnprintf failed:");
+		warning_errno("vsnprintf failed");
 		return;
 	}
 
diff --git a/grep.c b/grep.c
index 87c1890..4f3779a 100644
--- a/grep.c
+++ b/grep.c
@@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)
 	if (lstat(filename, &st) < 0) {
 	err_ret:
 		if (errno != ENOENT)
-			error_errno(_("'%s'"), filename);
+			error_errno("'%s'", filename);
 		return -1;
 	}
 	if (!S_ISREG(st.st_mode))
diff --git a/usage.c b/usage.c
index af1b7d1..1dad03f 100644
--- a/usage.c
+++ b/usage.c
@@ -109,9 +109,8 @@ void NORETURN die(const char *err, ...)
 	va_end(params);
 }
 
-static const char *fmt_with_err(const char *fmt)
+static const char *fmt_with_err(char *buf, int n, const char *fmt)
 {
-	static char fmt_with_err[1024];
 	char str_error[256], *err;
 	int i, j;
 
@@ -129,12 +128,13 @@ static const char *fmt_with_err(const char *fmt)
 		}
 	}
 	str_error[j] = 0;
-	snprintf(fmt_with_err, sizeof(fmt_with_err), "%s: %s", fmt, str_error);
-	return fmt_with_err;
+	snprintf(buf, n, "%s: %s", fmt, str_error);
+	return buf;
 }
 
 void NORETURN die_errno(const char *fmt, ...)
 {
+	char buf[1024];
 	va_list params;
 
 	if (die_is_recursing()) {
@@ -144,16 +144,17 @@ void NORETURN die_errno(const char *fmt, ...)
 	}
 
 	va_start(params, fmt);
-	die_routine(fmt_with_err(fmt), params);
+	die_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
 	va_end(params);
 }
 
 int error_errno(const char *fmt, ...)
 {
+	char buf[1024];
 	va_list params;
 
 	va_start(params, fmt);
-	error_routine(fmt_with_err(fmt), params);
+	error_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
 	va_end(params);
 	return -1;
 }
@@ -171,10 +172,11 @@ int error(const char *err, ...)
 
 void warning_errno(const char *warn, ...)
 {
+	char buf[1024];
 	va_list params;
 
 	va_start(params, warn);
-	warn_routine(fmt_with_err(warn), params);
+	warn_routine(fmt_with_err(buf, sizeof(buf), warn), params);
 	va_end(params);
 }
 
-- 8< --
--
Duy

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 01/41] usage.c: move format processing out of die_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 02/41] usage.c: add warning_errno() and error_errno() Nguyễn Thái Ngọc Duy
                     ` (42 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

fmt_with_err() will be shared with the coming error_errno() and
warning_errno().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 usage.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/usage.c b/usage.c
index 82ff131..8675d72 100644
--- a/usage.c
+++ b/usage.c
@@ -109,19 +109,11 @@ void NORETURN die(const char *err, ...)
 	va_end(params);
 }
 
-void NORETURN die_errno(const char *fmt, ...)
+static const char *fmt_with_err(char *buf, int n, const char *fmt)
 {
-	va_list params;
-	char fmt_with_err[1024];
 	char str_error[256], *err;
 	int i, j;
 
-	if (die_is_recursing()) {
-		fputs("fatal: recursion detected in die_errno handler\n",
-			stderr);
-		exit(128);
-	}
-
 	err = strerror(errno);
 	for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {
 		if ((str_error[j++] = err[i++]) != '%')
@@ -136,10 +128,23 @@ void NORETURN die_errno(const char *fmt, ...)
 		}
 	}
 	str_error[j] = 0;
-	snprintf(fmt_with_err, sizeof(fmt_with_err), "%s: %s", fmt, str_error);
+	snprintf(buf, n, "%s: %s", fmt, str_error);
+	return buf;
+}
+
+void NORETURN die_errno(const char *fmt, ...)
+{
+	char buf[1024];
+	va_list params;
+
+	if (die_is_recursing()) {
+		fputs("fatal: recursion detected in die_errno handler\n",
+			stderr);
+		exit(128);
+	}
 
 	va_start(params, fmt);
-	die_routine(fmt_with_err, params);
+	die_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
 	va_end(params);
 }
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 02/41] usage.c: add warning_errno() and error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 03/41] bisect.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                     ` (41 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Similar to die_errno(), these functions will append strerror()
automatically.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 git-compat-util.h |  2 ++
 usage.c           | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/git-compat-util.h b/git-compat-util.h
index 1f8b5f3..49d4029 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -409,7 +409,9 @@ extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf,
 extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
+extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
+extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 
 #ifndef NO_OPENSSL
 #ifdef APPLE_COMMON_CRYPTO
diff --git a/usage.c b/usage.c
index 8675d72..1dad03f 100644
--- a/usage.c
+++ b/usage.c
@@ -148,6 +148,17 @@ void NORETURN die_errno(const char *fmt, ...)
 	va_end(params);
 }
 
+int error_errno(const char *fmt, ...)
+{
+	char buf[1024];
+	va_list params;
+
+	va_start(params, fmt);
+	error_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
+	va_end(params);
+	return -1;
+}
+
 #undef error
 int error(const char *err, ...)
 {
@@ -159,6 +170,16 @@ int error(const char *err, ...)
 	return -1;
 }
 
+void warning_errno(const char *warn, ...)
+{
+	char buf[1024];
+	va_list params;
+
+	va_start(params, warn);
+	warn_routine(fmt_with_err(buf, sizeof(buf), warn), params);
+	va_end(params);
+}
+
 void warning(const char *warn, ...)
 {
 	va_list params;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 03/41] bisect.c: use die_errno() and warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 02/41] usage.c: add warning_errno() and error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 04/41] builtin/am.c: use error_errno() Nguyễn Thái Ngọc Duy
                     ` (40 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 bisect.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/bisect.c b/bisect.c
index 7996c29..6d93edb 100644
--- a/bisect.c
+++ b/bisect.c
@@ -860,8 +860,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
 	/* Create file BISECT_ANCESTORS_OK. */
 	fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);
 	if (fd < 0)
-		warning("could not create file '%s': %s",
-			filename, strerror(errno));
+		warning_errno("could not create file '%s'",
+			      filename);
 	else
 		close(fd);
  done:
@@ -910,8 +910,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
 			*read_good = "good";
 			return;
 		} else {
-			die("could not read file '%s': %s", filename,
-				strerror(errno));
+			die_errno("could not read file '%s'", filename);
 		}
 	} else {
 		strbuf_getline_lf(&str, fp);
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 04/41] builtin/am.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (2 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 03/41] bisect.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 05/41] builtin/branch.c: " Nguyễn Thái Ngọc Duy
                     ` (39 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/am.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index d003939..3dfe70b 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -769,15 +769,15 @@ static int split_mail_conv(mail_conv_fn fn, struct am_state *state,
 			in = fopen(*paths, "r");
 
 		if (!in)
-			return error(_("could not open '%s' for reading: %s"),
-					*paths, strerror(errno));
+			return error_errno(_("could not open '%s' for reading"),
+					   *paths);
 
 		mail = mkpath("%s/%0*d", state->dir, state->prec, i + 1);
 
 		out = fopen(mail, "w");
 		if (!out)
-			return error(_("could not open '%s' for writing: %s"),
-					mail, strerror(errno));
+			return error_errno(_("could not open '%s' for writing"),
+					   mail);
 
 		ret = fn(out, in, keep_cr);
 
@@ -857,8 +857,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
 
 	fp = fopen(*paths, "r");
 	if (!fp)
-		return error(_("could not open '%s' for reading: %s"), *paths,
-				strerror(errno));
+		return error_errno(_("could not open '%s' for reading"), *paths);
 
 	while (!strbuf_getline_lf(&sb, fp)) {
 		if (*sb.buf == '#')
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 05/41] builtin/branch.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (3 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 04/41] builtin/am.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 06/41] builtin/fetch.c: " Nguyễn Thái Ngọc Duy
                     ` (38 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/branch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index 0adba62..6f1572d 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -593,8 +593,7 @@ static int edit_branch_description(const char *branch_name)
 		    branch_name, comment_line_char);
 	if (write_file_gently(git_path(edit_description), "%s", buf.buf)) {
 		strbuf_release(&buf);
-		return error(_("could not write branch description template: %s"),
-			     strerror(errno));
+		return error_errno(_("could not write branch description template"));
 	}
 	strbuf_reset(&buf);
 	if (launch_editor(git_path(edit_description), &buf, NULL)) {
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 06/41] builtin/fetch.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (4 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 05/41] builtin/branch.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 19:22     ` Junio C Hamano
  2016-05-03 12:03   ` [PATCH v2 07/41] builtin/help.c: use warning_errno() Nguyễn Thái Ngọc Duy
                     ` (37 subsequent siblings)
  43 siblings, 1 reply; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fetch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index f8455bd..1582ca7 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -607,7 +607,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 
 	fp = fopen(filename, "a");
 	if (!fp)
-		return error(_("cannot open %s: %s\n"), filename, strerror(errno));
+		return error_errno(_("cannot open %s"), filename);
 
 	if (raw_url)
 		url = transport_anonymize_url(raw_url);
@@ -848,7 +848,7 @@ static int truncate_fetch_head(void)
 	FILE *fp = fopen_for_writing(filename);
 
 	if (!fp)
-		return error(_("cannot open %s: %s\n"), filename, strerror(errno));
+		return error_errno(_("cannot open %s"), filename);
 	fclose(fp);
 	return 0;
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 07/41] builtin/help.c: use warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (5 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 06/41] builtin/fetch.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 08/41] builtin/mailsplit.c: use error_errno() Nguyễn Thái Ngọc Duy
                     ` (36 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/help.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/help.c b/builtin/help.c
index 3c55ce4..8848013 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -127,7 +127,7 @@ static void exec_woman_emacs(const char *path, const char *page)
 			path = "emacsclient";
 		strbuf_addf(&man_page, "(woman \"%s\")", page);
 		execlp(path, "emacsclient", "-e", man_page.buf, (char *)NULL);
-		warning(_("failed to exec '%s': %s"), path, strerror(errno));
+		warning_errno(_("failed to exec '%s'"), path);
 	}
 }
 
@@ -148,7 +148,7 @@ static void exec_man_konqueror(const char *path, const char *page)
 			path = "kfmclient";
 		strbuf_addf(&man_page, "man:%s(1)", page);
 		execlp(path, filename, "newTab", man_page.buf, (char *)NULL);
-		warning(_("failed to exec '%s': %s"), path, strerror(errno));
+		warning_errno(_("failed to exec '%s'"), path);
 	}
 }
 
@@ -157,7 +157,7 @@ static void exec_man_man(const char *path, const char *page)
 	if (!path)
 		path = "man";
 	execlp(path, "man", page, (char *)NULL);
-	warning(_("failed to exec '%s': %s"), path, strerror(errno));
+	warning_errno(_("failed to exec '%s'"), path);
 }
 
 static void exec_man_cmd(const char *cmd, const char *page)
@@ -165,7 +165,7 @@ static void exec_man_cmd(const char *cmd, const char *page)
 	struct strbuf shell_cmd = STRBUF_INIT;
 	strbuf_addf(&shell_cmd, "%s %s", cmd, page);
 	execl(SHELL_PATH, SHELL_PATH, "-c", shell_cmd.buf, (char *)NULL);
-	warning(_("failed to exec '%s': %s"), cmd, strerror(errno));
+	warning(_("failed to exec '%s'"), cmd);
 }
 
 static void add_man_viewer(const char *name)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 08/41] builtin/mailsplit.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (6 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 07/41] builtin/help.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 19:48     ` Junio C Hamano
  2016-05-03 12:03   ` [PATCH v2 09/41] builtin/merge-file.c: " Nguyễn Thái Ngọc Duy
                     ` (35 subsequent siblings)
  43 siblings, 1 reply; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/mailsplit.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
index 104277a..4859ede 100644
--- a/builtin/mailsplit.c
+++ b/builtin/mailsplit.c
@@ -109,7 +109,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)
 		if ((dir = opendir(name)) == NULL) {
 			if (errno == ENOENT)
 				continue;
-			error("cannot opendir %s (%s)", name, strerror(errno));
+			error_errno("cannot opendir %s", name);
 			goto out;
 		}
 
@@ -174,12 +174,12 @@ static int split_maildir(const char *maildir, const char *dir,
 
 		f = fopen(file, "r");
 		if (!f) {
-			error("cannot open mail %s (%s)", file, strerror(errno));
+			error_errno("cannot open mail %s", file);
 			goto out;
 		}
 
 		if (strbuf_getwholeline(&buf, f, '\n')) {
-			error("cannot read mail %s (%s)", file, strerror(errno));
+			error_errno("cannot read mail %s", file);
 			goto out;
 		}
 
@@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
 	int file_done = 0;
 
 	if (!f) {
-		error("cannot open mbox %s", file);
+		error_errno("cannot open mbox %s", file);
 		goto out;
 	}
 
@@ -318,7 +318,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)
 		}
 
 		if (stat(arg, &argstat) == -1) {
-			error("cannot stat %s (%s)", arg, strerror(errno));
+			error_errno("cannot stat %s", arg);
 			return 1;
 		}
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 09/41] builtin/merge-file.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (7 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 08/41] builtin/mailsplit.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 10/41] builtin/pack-objects.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                     ` (34 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/merge-file.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 5544705..13e22a2 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -62,8 +62,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 		usage_with_options(merge_file_usage, options);
 	if (quiet) {
 		if (!freopen("/dev/null", "w", stderr))
-			return error("failed to redirect stderr to /dev/null: "
-				     "%s", strerror(errno));
+			return error_errno("failed to redirect stderr to /dev/null");
 	}
 
 	if (prefix)
@@ -95,12 +94,13 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 		FILE *f = to_stdout ? stdout : fopen(fpath, "wb");
 
 		if (!f)
-			ret = error("Could not open %s for writing", filename);
+			ret = error_errno("Could not open %s for writing",
+					  filename);
 		else if (result.size &&
 			 fwrite(result.ptr, result.size, 1, f) != 1)
-			ret = error("Could not write to %s", filename);
+			ret = error_errno("Could not write to %s", filename);
 		else if (fclose(f))
-			ret = error("Could not close %s", filename);
+			ret = error_errno("Could not close %s", filename);
 		free(result.ptr);
 	}
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 10/41] builtin/pack-objects.c: use die_errno() and warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (8 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 09/41] builtin/merge-file.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 19:54     ` Junio C Hamano
  2016-05-03 12:03   ` [PATCH v2 11/41] builtin/rm.c: use warning_errno() Nguyễn Thái Ngọc Duy
                     ` (33 subsequent siblings)
  43 siblings, 1 reply; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/pack-objects.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index a27de5b..e18e190 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -828,8 +828,7 @@ static void write_pack_file(void)
 			 * to preserve this property.
 			 */
 			if (stat(pack_tmp_name, &st) < 0) {
-				warning("failed to stat %s: %s",
-					pack_tmp_name, strerror(errno));
+				warning_errno("failed to stat %s", pack_tmp_name);
 			} else if (!last_mtime) {
 				last_mtime = st.st_mtime;
 			} else {
@@ -837,8 +836,7 @@ static void write_pack_file(void)
 				utb.actime = st.st_atime;
 				utb.modtime = --last_mtime;
 				if (utime(pack_tmp_name, &utb) < 0)
-					warning("failed utime() on %s: %s",
-						pack_tmp_name, strerror(errno));
+					warning_errno("failed utime() on %s", pack_tmp_name);
 			}
 
 			strbuf_addf(&tmpname, "%s-", base_name);
@@ -2020,7 +2018,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
 		ret = pthread_create(&p[i].thread, NULL,
 				     threaded_find_deltas, &p[i]);
 		if (ret)
-			die("unable to create thread: %s", strerror(ret));
+			die_errno("unable to create thread");
 		active_threads++;
 	}
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 11/41] builtin/rm.c: use warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (9 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 10/41] builtin/pack-objects.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 19:58     ` Junio C Hamano
  2016-05-03 12:03   ` [PATCH v2 12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error Nguyễn Thái Ngọc Duy
                     ` (32 subsequent siblings)
  43 siblings, 1 reply; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/rm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/rm.c b/builtin/rm.c
index 8829b09..13b9639 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only)
 
 		if (lstat(ce->name, &st) < 0) {
 			if (errno != ENOENT && errno != ENOTDIR)
-				warning("'%s': %s", ce->name, strerror(errno));
+				warning_errno("'%s'", ce->name);
 			/* It already vanished from the working tree */
 			continue;
 		}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (10 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 11/41] builtin/rm.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 16:52     ` Eric Sunshine
  2016-05-03 12:03   ` [PATCH v2 13/41] builtin/upload-archive.c: use error_errno() Nguyễn Thái Ngọc Duy
                     ` (31 subsequent siblings)
  43 siblings, 1 reply; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

"errno" is already passed in as "err". Here we should use err instead of
errno. errno is probably a copy/paste mistake in e011054 (Teach
git-update-index about gitlinks - 2007-04-12)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/update-index.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/update-index.c b/builtin/update-index.c
index 1c94ca5..b8b8522 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -255,7 +255,7 @@ static int process_lstat_error(const char *path, int err)
 {
 	if (err == ENOENT || err == ENOTDIR)
 		return remove_one_path(path);
-	return error("lstat(\"%s\"): %s", path, strerror(errno));
+	return error("lstat(\"%s\"): %s", path, strerror(err));
 }
 
 static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 13/41] builtin/upload-archive.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (11 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 14/41] builtin/worktree.c: " Nguyễn Thái Ngọc Duy
                     ` (30 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/upload-archive.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index dbfe14f..2caedf1 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -104,8 +104,7 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
 		pfd[1].events = POLLIN;
 		if (poll(pfd, 2, -1) < 0) {
 			if (errno != EINTR) {
-				error("poll failed resuming: %s",
-				      strerror(errno));
+				error_errno("poll failed resuming");
 				sleep(1);
 			}
 			continue;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 14/41] builtin/worktree.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (12 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 13/41] builtin/upload-archive.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 20:02     ` Junio C Hamano
  2016-05-03 12:03   ` [PATCH v2 15/41] check-racy.c: " Nguyễn Thái Ngọc Duy
                     ` (29 subsequent siblings)
  43 siblings, 1 reply; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/worktree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index d8e3795..331ecf6 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -110,7 +110,7 @@ static void prune_worktrees(void)
 		if (ret < 0 && errno == ENOTDIR)
 			ret = unlink(path.buf);
 		if (ret)
-			error(_("failed to remove: %s"), strerror(errno));
+			error_errno(_("failed to remove '%s'"), path.buf);
 	}
 	closedir(dir);
 	if (!show_only)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 15/41] check-racy.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (13 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 14/41] builtin/worktree.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 16/41] combine-diff.c: " Nguyễn Thái Ngọc Duy
                     ` (28 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 check-racy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/check-racy.c b/check-racy.c
index 00d92a1..24b6542 100644
--- a/check-racy.c
+++ b/check-racy.c
@@ -12,7 +12,7 @@ int main(int ac, char **av)
 		struct stat st;
 
 		if (lstat(ce->name, &st)) {
-			error("lstat(%s): %s", ce->name, strerror(errno));
+			error_errno("lstat(%s)", ce->name);
 			continue;
 		}
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 16/41] combine-diff.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (14 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 15/41] check-racy.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 17/41] compat/win32/syslog.c: use warning_errno() Nguyễn Thái Ngọc Duy
                     ` (27 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 combine-diff.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/combine-diff.c b/combine-diff.c
index 0e1d4b0..8f2313d 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1005,8 +1005,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 			struct strbuf buf = STRBUF_INIT;
 
 			if (strbuf_readlink(&buf, elem->path, st.st_size) < 0) {
-				error("readlink(%s): %s", elem->path,
-				      strerror(errno));
+				error_errno("readlink(%s)", elem->path);
 				return;
 			}
 			result_size = buf.len;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 17/41] compat/win32/syslog.c: use warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (15 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 16/41] combine-diff.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 18/41] config.c: use error_errno() Nguyễn Thái Ngọc Duy
                     ` (26 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 compat/win32/syslog.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c
index b905aea..6c7c9b6 100644
--- a/compat/win32/syslog.c
+++ b/compat/win32/syslog.c
@@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...)
 	va_end(ap);
 
 	if (str_len < 0) {
-		warning("vsnprintf failed: '%s'", strerror(errno));
+		warning_errno("vsnprintf failed");
 		return;
 	}
 
 	str = malloc(st_add(str_len, 1));
 	if (!str) {
-		warning("malloc failed: '%s'", strerror(errno));
+		warning_errno("malloc failed");
 		return;
 	}
 
@@ -45,7 +45,7 @@ void syslog(int priority, const char *fmt, ...)
 	while ((pos = strstr(str, "%1")) != NULL) {
 		str = realloc(str, st_add(++str_len, 1));
 		if (!str) {
-			warning("realloc failed: '%s'", strerror(errno));
+			warning_errno("realloc failed");
 			return;
 		}
 		memmove(pos + 2, pos + 1, strlen(pos));
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 18/41] config.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (16 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 17/41] compat/win32/syslog.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 19/41] connected.c: " Nguyễn Thái Ngọc Duy
                     ` (25 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 config.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/config.c b/config.c
index 10b5c95..80411e4 100644
--- a/config.c
+++ b/config.c
@@ -2012,7 +2012,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 	lock = xcalloc(1, sizeof(struct lock_file));
 	fd = hold_lock_file_for_update(lock, config_filename, 0);
 	if (fd < 0) {
-		error("could not lock config file %s: %s", config_filename, strerror(errno));
+		error_errno("could not lock config file %s", config_filename);
 		free(store.key);
 		ret = CONFIG_NO_LOCK;
 		goto out_free;
@@ -2026,8 +2026,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 		free(store.key);
 
 		if ( ENOENT != errno ) {
-			error("opening %s: %s", config_filename,
-			      strerror(errno));
+			error_errno("opening %s", config_filename);
 			ret = CONFIG_INVALID_FILE; /* same as "invalid config file" */
 			goto out_free;
 		}
@@ -2111,8 +2110,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 		if (contents == MAP_FAILED) {
 			if (errno == ENODEV && S_ISDIR(st.st_mode))
 				errno = EISDIR;
-			error("unable to mmap '%s': %s",
-			      config_filename, strerror(errno));
+			error_errno("unable to mmap '%s'", config_filename);
 			ret = CONFIG_INVALID_FILE;
 			contents = NULL;
 			goto out_free;
@@ -2121,8 +2119,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 		in_fd = -1;
 
 		if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
-			error("chmod on %s failed: %s",
-			      get_lock_file_path(lock), strerror(errno));
+			error_errno("chmod on %s failed", get_lock_file_path(lock));
 			ret = CONFIG_NO_WRITE;
 			goto out_free;
 		}
@@ -2178,8 +2175,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 	}
 
 	if (commit_lock_file(lock) < 0) {
-		error("could not write config file %s: %s", config_filename,
-		      strerror(errno));
+		error_errno("could not write config file %s", config_filename);
 		ret = CONFIG_NO_WRITE;
 		lock = NULL;
 		goto out_free;
@@ -2330,8 +2326,8 @@ int git_config_rename_section_in_file(const char *config_filename,
 	fstat(fileno(config_file), &st);
 
 	if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
-		ret = error("chmod on %s failed: %s",
-			    get_lock_file_path(lock), strerror(errno));
+		ret = error_errno("chmod on %s failed",
+				  get_lock_file_path(lock));
 		goto out;
 	}
 
@@ -2385,8 +2381,8 @@ int git_config_rename_section_in_file(const char *config_filename,
 	fclose(config_file);
 unlock_and_out:
 	if (commit_lock_file(lock) < 0)
-		ret = error("could not write config file %s: %s",
-			    config_filename, strerror(errno));
+		ret = error_errno("could not write config file %s",
+				  config_filename);
 out:
 	free(filename_buf);
 	return ret;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 19/41] connected.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (17 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 18/41] config.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 20/41] copy.c: " Nguyễn Thái Ngọc Duy
                     ` (24 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 connected.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/connected.c b/connected.c
index 299c560..bf1b12e 100644
--- a/connected.c
+++ b/connected.c
@@ -86,17 +86,14 @@ static int check_everything_connected_real(sha1_iterate_fn fn,
 		memcpy(commit, sha1_to_hex(sha1), 40);
 		if (write_in_full(rev_list.in, commit, 41) < 0) {
 			if (errno != EPIPE && errno != EINVAL)
-				error(_("failed write to rev-list: %s"),
-				      strerror(errno));
+				error_errno(_("failed write to rev-list"));
 			err = -1;
 			break;
 		}
 	} while (!fn(cb_data, sha1));
 
-	if (close(rev_list.in)) {
-		error(_("failed to close rev-list's stdin: %s"), strerror(errno));
-		err = -1;
-	}
+	if (close(rev_list.in))
+		err = error_errno(_("failed to close rev-list's stdin"));
 
 	sigchain_pop(SIGPIPE);
 	return finish_command(&rev_list) || err;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 20/41] copy.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (18 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 19/41] connected.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 21/41] credential-cache--daemon.c: use warning_errno() Nguyễn Thái Ngọc Duy
                     ` (23 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 copy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/copy.c b/copy.c
index 574fa1f..4de6a11 100644
--- a/copy.c
+++ b/copy.c
@@ -42,15 +42,15 @@ int copy_file(const char *dst, const char *src, int mode)
 	status = copy_fd(fdi, fdo);
 	switch (status) {
 	case COPY_READ_ERROR:
-		error("copy-fd: read returned %s", strerror(errno));
+		error_errno("copy-fd: read returned");
 		break;
 	case COPY_WRITE_ERROR:
-		error("copy-fd: write returned %s", strerror(errno));
+		error_errno("copy-fd: write returned");
 		break;
 	}
 	close(fdi);
 	if (close(fdo) != 0)
-		return error("%s: close error: %s", dst, strerror(errno));
+		return error_errno("%s: close error", dst);
 
 	if (!status && adjust_shared_perm(dst))
 		return -1;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 21/41] credential-cache--daemon.c: use warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (19 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 20/41] copy.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 22/41] diff-no-index.c: use error_errno() Nguyễn Thái Ngọc Duy
                     ` (22 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 credential-cache--daemon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
index 291c0fd..1f14d56 100644
--- a/credential-cache--daemon.c
+++ b/credential-cache--daemon.c
@@ -179,12 +179,12 @@ static int serve_cache_loop(int fd)
 
 		client = accept(fd, NULL, NULL);
 		if (client < 0) {
-			warning("accept failed: %s", strerror(errno));
+			warning_errno("accept failed");
 			return 1;
 		}
 		client2 = dup(client);
 		if (client2 < 0) {
-			warning("dup failed: %s", strerror(errno));
+			warning_errno("dup failed");
 			close(client);
 			return 1;
 		}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 22/41] diff-no-index.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (20 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 21/41] credential-cache--daemon.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 23/41] editor.c: " Nguyễn Thái Ngọc Duy
                     ` (21 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 diff-no-index.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/diff-no-index.c b/diff-no-index.c
index 03daadb..1f8999b 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -65,8 +65,7 @@ static int populate_from_stdin(struct diff_filespec *s)
 	size_t size = 0;
 
 	if (strbuf_read(&buf, 0, 0) < 0)
-		return error("error while reading from stdin %s",
-				     strerror(errno));
+		return error_errno("error while reading from stdin");
 
 	s->should_munmap = 0;
 	s->data = strbuf_detach(&buf, &size);
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 23/41] editor.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (21 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 22/41] diff-no-index.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 24/41] entry.c: " Nguyễn Thái Ngọc Duy
                     ` (20 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 editor.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/editor.c b/editor.c
index 01c644c..7519ede 100644
--- a/editor.c
+++ b/editor.c
@@ -63,7 +63,6 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
 	if (!buffer)
 		return 0;
 	if (strbuf_read_file(buffer, path, 0) < 0)
-		return error("could not read file '%s': %s",
-				path, strerror(errno));
+		return error_errno("could not read file '%s'", path);
 	return 0;
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 24/41] entry.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (22 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 23/41] editor.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 25/41] fast-import.c: " Nguyễn Thái Ngọc Duy
                     ` (19 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 entry.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/entry.c b/entry.c
index a410957..519e042 100644
--- a/entry.c
+++ b/entry.c
@@ -168,8 +168,8 @@ static int write_entry(struct cache_entry *ce,
 			ret = symlink(new, path);
 			free(new);
 			if (ret)
-				return error("unable to create symlink %s (%s)",
-					     path, strerror(errno));
+				return error_errno("unable to create symlink %s",
+						   path);
 			break;
 		}
 
@@ -186,8 +186,7 @@ static int write_entry(struct cache_entry *ce,
 		fd = open_output_fd(path, ce, to_tempfile);
 		if (fd < 0) {
 			free(new);
-			return error("unable to create file %s (%s)",
-				path, strerror(errno));
+			return error_errno("unable to create file %s", path);
 		}
 
 		wrote = write_in_full(fd, new, size);
@@ -284,8 +283,7 @@ int checkout_entry(struct cache_entry *ce,
 				return error("%s is a directory", path.buf);
 			remove_subtree(&path);
 		} else if (unlink(path.buf))
-			return error("unable to unlink old '%s' (%s)",
-				     path.buf, strerror(errno));
+			return error_errno("unable to unlink old '%s'", path.buf);
 	} else if (state->not_new)
 		return 0;
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 25/41] fast-import.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (23 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 24/41] entry.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:03   ` [PATCH v2 26/41] gpg-interface.c: " Nguyễn Thái Ngọc Duy
                     ` (18 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 fast-import.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index 9fc7093..21881d1 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -414,7 +414,7 @@ static void write_crash_report(const char *err)
 	struct recent_command *rc;
 
 	if (!rpt) {
-		error("can't write crash report %s: %s", loc, strerror(errno));
+		error_errno("can't write crash report %s", loc);
 		free(loc);
 		return;
 	}
@@ -1806,8 +1806,8 @@ static void dump_marks(void)
 		return;
 
 	if (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) {
-		failure |= error("Unable to write marks file %s: %s",
-			export_marks_file, strerror(errno));
+		failure |= error_errno("Unable to write marks file %s",
+				       export_marks_file);
 		return;
 	}
 
@@ -1822,8 +1822,8 @@ static void dump_marks(void)
 
 	dump_marks_helper(f, 0, marks);
 	if (commit_lock_file(&mark_lock)) {
-		failure |= error("Unable to write file %s: %s",
-			export_marks_file, strerror(errno));
+		failure |= error_errno("Unable to write file %s",
+				       export_marks_file);
 		return;
 	}
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 26/41] gpg-interface.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (24 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 25/41] fast-import.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:03   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 27/41] grep.c: " Nguyễn Thái Ngọc Duy
                     ` (17 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:03 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 gpg-interface.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/gpg-interface.c b/gpg-interface.c
index 2259938..c4b1e8c 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -219,11 +219,9 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
 	args_gpg[0] = gpg_program;
 	fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXXXXXX");
 	if (fd < 0)
-		return error(_("could not create temporary file '%s': %s"),
-			     path, strerror(errno));
+		return error_errno(_("could not create temporary file '%s'"), path);
 	if (write_in_full(fd, signature, signature_size) < 0)
-		return error(_("failed writing detached signature to '%s': %s"),
-			     path, strerror(errno));
+		return error_errno(_("failed writing detached signature to '%s'"), path);
 	close(fd);
 
 	gpg.argv = args_gpg;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 27/41] grep.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (25 preceding siblings ...)
  2016-05-03 12:03   ` [PATCH v2 26/41] gpg-interface.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 28/41] http.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                     ` (16 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 grep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grep.c b/grep.c
index 528b652..4f3779a 100644
--- a/grep.c
+++ b/grep.c
@@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)
 	if (lstat(filename, &st) < 0) {
 	err_ret:
 		if (errno != ENOENT)
-			error(_("'%s': %s"), filename, strerror(errno));
+			error_errno("'%s'", filename);
 		return -1;
 	}
 	if (!S_ISREG(st.st_mode))
@@ -1743,7 +1743,7 @@ static int grep_source_load_file(struct grep_source *gs)
 		goto err_ret;
 	data = xmallocz(size);
 	if (st.st_size != read_in_full(i, data, size)) {
-		error(_("'%s': short read %s"), filename, strerror(errno));
+		error_errno(_("'%s': short read"), filename);
 		close(i);
 		free(data);
 		return -1;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 28/41] http.c: use error_errno() and warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (26 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 27/41] grep.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 29/41] ident.c: use warning_errno() Nguyễn Thái Ngọc Duy
                     ` (15 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 http.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/http.c b/http.c
index 4304b80..7565c93 100644
--- a/http.c
+++ b/http.c
@@ -446,8 +446,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)
 
 	rc = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&ka, len);
 	if (rc < 0)
-		warning("unable to set SO_KEEPALIVE on socket %s",
-			strerror(errno));
+		warning_errno("unable to set SO_KEEPALIVE on socket");
 
 	return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */
 }
@@ -1894,8 +1893,7 @@ struct http_object_request *new_http_object_request(const char *base_url,
 	}
 
 	if (freq->localfile < 0) {
-		error("Couldn't create temporary file %s: %s",
-		      freq->tmpfile, strerror(errno));
+		error_errno("Couldn't create temporary file %s", freq->tmpfile);
 		goto abort;
 	}
 
@@ -1940,8 +1938,8 @@ struct http_object_request *new_http_object_request(const char *base_url,
 			prev_posn = 0;
 			lseek(freq->localfile, 0, SEEK_SET);
 			if (ftruncate(freq->localfile, 0) < 0) {
-				error("Couldn't truncate temporary file %s: %s",
-					  freq->tmpfile, strerror(errno));
+				error_errno("Couldn't truncate temporary file %s",
+					    freq->tmpfile);
 				goto abort;
 			}
 		}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 29/41] ident.c: use warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (27 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 28/41] http.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 30/41] mailmap.c: use error_errno() Nguyễn Thái Ngọc Duy
                     ` (14 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 ident.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/ident.c b/ident.c
index 4fd82d1..139c528 100644
--- a/ident.c
+++ b/ident.c
@@ -75,14 +75,12 @@ static int add_mailname_host(struct strbuf *buf)
 	mailname = fopen("/etc/mailname", "r");
 	if (!mailname) {
 		if (errno != ENOENT)
-			warning("cannot open /etc/mailname: %s",
-				strerror(errno));
+			warning_errno("cannot open /etc/mailname");
 		return -1;
 	}
 	if (strbuf_getline(&mailnamebuf, mailname) == EOF) {
 		if (ferror(mailname))
-			warning("cannot read /etc/mailname: %s",
-				strerror(errno));
+			warning_errno("cannot read /etc/mailname");
 		strbuf_release(&mailnamebuf);
 		fclose(mailname);
 		return -1;
@@ -125,7 +123,7 @@ static void add_domainname(struct strbuf *out, int *is_bogus)
 	char buf[1024];
 
 	if (gethostname(buf, sizeof(buf))) {
-		warning("cannot get host name: %s", strerror(errno));
+		warning_errno("cannot get host name");
 		strbuf_addstr(out, "(none)");
 		*is_bogus = 1;
 		return;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 30/41] mailmap.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (28 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 29/41] ident.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 31/41] reachable.c: " Nguyễn Thái Ngọc Duy
                     ` (13 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 mailmap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mailmap.c b/mailmap.c
index 9726237..b5c521f 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -189,8 +189,7 @@ static int read_mailmap_file(struct string_list *map, const char *filename,
 	if (!f) {
 		if (errno == ENOENT)
 			return 0;
-		return error("unable to open mailmap at %s: %s",
-			     filename, strerror(errno));
+		return error_errno("unable to open mailmap at %s", filename);
 	}
 
 	while (fgets(buffer, sizeof(buffer), f) != NULL)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 31/41] reachable.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (29 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 30/41] mailmap.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 32/41] rerere.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                     ` (12 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 reachable.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/reachable.c b/reachable.c
index ed35201..d0199ca 100644
--- a/reachable.c
+++ b/reachable.c
@@ -119,8 +119,7 @@ static int add_recent_loose(const unsigned char *sha1,
 		 */
 		if (errno == ENOENT)
 			return 0;
-		return error("unable to stat %s: %s",
-			     sha1_to_hex(sha1), strerror(errno));
+		return error_errno("unable to stat %s", sha1_to_hex(sha1));
 	}
 
 	add_recent_object(sha1, st.st_mtime, data);
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 32/41] rerere.c: use error_errno() and warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (30 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 31/41] reachable.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 33/41] run-command.c: use error_errno() Nguyễn Thái Ngọc Duy
                     ` (11 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 rerere.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/rerere.c b/rerere.c
index c8b9f40..1810c04 100644
--- a/rerere.c
+++ b/rerere.c
@@ -501,8 +501,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
 		error("There were errors while writing %s (%s)",
 		      path, strerror(io.io.wrerror));
 	if (io.io.output && fclose(io.io.output))
-		io.io.wrerror = error("Failed to flush %s: %s",
-				      path, strerror(errno));
+		io.io.wrerror = error_errno("Failed to flush %s", path);
 
 	if (hunk_no < 0) {
 		if (output)
@@ -684,20 +683,17 @@ static int merge(const struct rerere_id *id, const char *path)
 	 * Mark that "postimage" was used to help gc.
 	 */
 	if (utime(rerere_path(id, "postimage"), NULL) < 0)
-		warning("failed utime() on %s: %s",
-			rerere_path(id, "postimage"),
-			strerror(errno));
+		warning_errno("failed utime() on %s",
+			      rerere_path(id, "postimage"));
 
 	/* Update "path" with the resolution */
 	f = fopen(path, "w");
 	if (!f)
-		return error("Could not open %s: %s", path,
-			     strerror(errno));
+		return error_errno("Could not open %s", path);
 	if (fwrite(result.ptr, result.size, 1, f) != 1)
-		error("Could not write %s: %s", path, strerror(errno));
+		error_errno("Could not write %s", path);
 	if (fclose(f))
-		return error("Writing %s failed: %s", path,
-			     strerror(errno));
+		return error_errno("Writing %s failed", path);
 
 out:
 	free(cur.ptr);
@@ -1071,7 +1067,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
 	if (unlink(filename))
 		return (errno == ENOENT
 			? error("no remembered resolution for %s", path)
-			: error("cannot unlink %s: %s", filename, strerror(errno)));
+			: error_errno("cannot unlink %s", filename));
 
 	/*
 	 * Update the preimage so that the user can resolve the
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 33/41] run-command.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (31 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 32/41] rerere.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 34/41] sequencer.c: " Nguyễn Thái Ngọc Duy
                     ` (10 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 run-command.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/run-command.c b/run-command.c
index e4593cd..842c8d1 100644
--- a/run-command.c
+++ b/run-command.c
@@ -233,7 +233,7 @@ static int wait_or_whine(pid_t pid, const char *argv0, int in_signal)
 
 	if (waiting < 0) {
 		failed_errno = errno;
-		error("waitpid for %s failed: %s", argv0, strerror(errno));
+		error_errno("waitpid for %s failed", argv0);
 	} else if (waiting != pid) {
 		error("waitpid is confused (%s)", argv0);
 	} else if (WIFSIGNALED(status)) {
@@ -420,8 +420,7 @@ fail_pipe:
 		}
 	}
 	if (cmd->pid < 0)
-		error("cannot fork() for %s: %s", cmd->argv[0],
-			strerror(errno));
+		error_errno("cannot fork() for %s", cmd->argv[0]);
 	else if (cmd->clean_on_exit)
 		mark_child_for_cleanup(cmd->pid);
 
@@ -482,7 +481,7 @@ fail_pipe:
 			cmd->dir, fhin, fhout, fherr);
 	failed_errno = errno;
 	if (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))
-		error("cannot spawn %s: %s", cmd->argv[0], strerror(errno));
+		error_errno("cannot spawn %s", cmd->argv[0]);
 	if (cmd->clean_on_exit && cmd->pid >= 0)
 		mark_child_for_cleanup(cmd->pid);
 
@@ -703,7 +702,7 @@ int start_async(struct async *async)
 		if (pipe(fdin) < 0) {
 			if (async->out > 0)
 				close(async->out);
-			return error("cannot create pipe: %s", strerror(errno));
+			return error_errno("cannot create pipe");
 		}
 		async->in = fdin[1];
 	}
@@ -715,7 +714,7 @@ int start_async(struct async *async)
 				close_pair(fdin);
 			else if (async->in)
 				close(async->in);
-			return error("cannot create pipe: %s", strerror(errno));
+			return error_errno("cannot create pipe");
 		}
 		async->out = fdout[0];
 	}
@@ -740,7 +739,7 @@ int start_async(struct async *async)
 
 	async->pid = fork();
 	if (async->pid < 0) {
-		error("fork (async) failed: %s", strerror(errno));
+		error_errno("fork (async) failed");
 		goto error;
 	}
 	if (!async->pid) {
@@ -787,7 +786,7 @@ int start_async(struct async *async)
 	{
 		int err = pthread_create(&async->tid, NULL, run_thread, async);
 		if (err) {
-			error("cannot create thread: %s", strerror(err));
+			error_errno("cannot create thread");
 			goto error;
 		}
 	}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 34/41] sequencer.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (32 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 33/41] run-command.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 35/41] server-info.c: " Nguyễn Thái Ngọc Duy
                     ` (9 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 sequencer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index e66f2fe..4687ad4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -875,8 +875,7 @@ static int sequencer_rollback(struct replay_opts *opts)
 		return rollback_single_pick();
 	}
 	if (!f)
-		return error(_("cannot open %s: %s"), git_path_head_file(),
-						strerror(errno));
+		return error_errno(_("cannot open %s"), git_path_head_file());
 	if (strbuf_getline_lf(&buf, f)) {
 		error(_("cannot read %s: %s"), git_path_head_file(),
 		      ferror(f) ?  strerror(errno) : _("unexpected end of file"));
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 35/41] server-info.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (33 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 34/41] sequencer.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 36/41] sha1_file.c: use {error,die,warning}_errno() Nguyễn Thái Ngọc Duy
                     ` (8 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 server-info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server-info.c b/server-info.c
index 5a86e29..75dd677 100644
--- a/server-info.c
+++ b/server-info.c
@@ -36,7 +36,7 @@ static int update_info_file(char *path, int (*generate)(FILE *))
 
 out:
 	if (ret) {
-		error("unable to update %s: %s", path, strerror(errno));
+		error_errno("unable to update %s", path);
 		if (fp)
 			fclose(fp);
 		else if (fd >= 0)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 36/41] sha1_file.c: use {error,die,warning}_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (34 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 35/41] server-info.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 37/41] transport-helper.c: use error_errno() Nguyễn Thái Ngọc Duy
                     ` (7 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 sha1_file.c | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index d0f2aa0..a7f45b3 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1107,9 +1107,8 @@ unsigned char *use_pack(struct packed_git *p,
 				PROT_READ, MAP_PRIVATE,
 				p->pack_fd, win->offset);
 			if (win->base == MAP_FAILED)
-				die("packfile %s cannot be mapped: %s",
-					p->pack_name,
-					strerror(errno));
+				die_errno("packfile %s cannot be mapped",
+					  p->pack_name);
 			if (!win->offset && win->len == p->pack_size
 				&& !p->do_not_close)
 				close_pack_fd(p);
@@ -1279,8 +1278,8 @@ static void prepare_packed_git_one(char *objdir, int local)
 	dir = opendir(path.buf);
 	if (!dir) {
 		if (errno != ENOENT)
-			error("unable to open object pack directory: %s: %s",
-			      path.buf, strerror(errno));
+			error_errno("unable to open object pack directory: %s",
+				    path.buf);
 		strbuf_release(&path);
 		return;
 	}
@@ -2984,7 +2983,7 @@ int finalize_object_file(const char *tmpfile, const char *filename)
 	unlink_or_warn(tmpfile);
 	if (ret) {
 		if (ret != EEXIST) {
-			return error("unable to write sha1 filename %s: %s", filename, strerror(ret));
+			return error_errno("unable to write sha1 filename %s", filename);
 		}
 		/* FIXME!!! Collision check here ? */
 	}
@@ -2998,7 +2997,7 @@ out:
 static int write_buffer(int fd, const void *buf, size_t len)
 {
 	if (write_in_full(fd, buf, len) < 0)
-		return error("file write error (%s)", strerror(errno));
+		return error_errno("file write error");
 	return 0;
 }
 
@@ -3081,7 +3080,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
 		if (errno == EACCES)
 			return error("insufficient permission for adding an object to repository database %s", get_object_directory());
 		else
-			return error("unable to create temporary file: %s", strerror(errno));
+			return error_errno("unable to create temporary file");
 	}
 
 	/* Set it up */
@@ -3126,8 +3125,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
 		utb.actime = mtime;
 		utb.modtime = mtime;
 		if (utime(tmp_file.buf, &utb) < 0)
-			warning("failed utime() on %s: %s",
-				tmp_file.buf, strerror(errno));
+			warning_errno("failed utime() on %s", tmp_file.buf);
 	}
 
 	return finalize_object_file(tmp_file.buf, filename);
@@ -3360,7 +3358,7 @@ static int index_core(unsigned char *sha1, int fd, size_t size,
 		if (size == read_in_full(fd, buf, size))
 			ret = index_mem(sha1, buf, size, type, path, flags);
 		else
-			ret = error("short read %s", strerror(errno));
+			ret = error_errno("short read");
 		free(buf);
 	} else {
 		void *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
@@ -3425,18 +3423,14 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned
 	case S_IFREG:
 		fd = open(path, O_RDONLY);
 		if (fd < 0)
-			return error("open(\"%s\"): %s", path,
-				     strerror(errno));
+			return error_errno("open(\"%s\")", path);
 		if (index_fd(sha1, fd, st, OBJ_BLOB, path, flags) < 0)
 			return error("%s: failed to insert into database",
 				     path);
 		break;
 	case S_IFLNK:
-		if (strbuf_readlink(&sb, path, st->st_size)) {
-			char *errstr = strerror(errno);
-			return error("readlink(\"%s\"): %s", path,
-			             errstr);
-		}
+		if (strbuf_readlink(&sb, path, st->st_size))
+			return error_errno("readlink(\"%s\")", path);
 		if (!(flags & HASH_WRITE_OBJECT))
 			hash_sha1_file(sb.buf, sb.len, blob_type, sha1);
 		else if (write_sha1_file(sb.buf, sb.len, blob_type, sha1))
@@ -3492,7 +3486,7 @@ static int for_each_file_in_obj_subdir(int subdir_nr,
 	if (!dir) {
 		if (errno == ENOENT)
 			return 0;
-		return error("unable to open %s: %s", path->buf, strerror(errno));
+		return error_errno("unable to open %s", path->buf);
 	}
 
 	while ((de = readdir(dir))) {
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 37/41] transport-helper.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (35 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 36/41] sha1_file.c: use {error,die,warning}_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 38/41] unpack-trees.c: " Nguyễn Thái Ngọc Duy
                     ` (6 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 transport-helper.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index b934183..f09fadc 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1166,7 +1166,7 @@ static int udt_do_read(struct unidirectional_transfer *t)
 	bytes = read(t->src, t->buf + t->bufuse, BUFFERSIZE - t->bufuse);
 	if (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN &&
 		errno != EINTR) {
-		error("read(%s) failed: %s", t->src_name, strerror(errno));
+		error_errno("read(%s) failed", t->src_name);
 		return -1;
 	} else if (bytes == 0) {
 		transfer_debug("%s EOF (with %i bytes in buffer)",
@@ -1193,7 +1193,7 @@ static int udt_do_write(struct unidirectional_transfer *t)
 	transfer_debug("%s is writable", t->dest_name);
 	bytes = xwrite(t->dest, t->buf, t->bufuse);
 	if (bytes < 0 && errno != EWOULDBLOCK) {
-		error("write(%s) failed: %s", t->dest_name, strerror(errno));
+		error_errno("write(%s) failed", t->dest_name);
 		return -1;
 	} else if (bytes > 0) {
 		t->bufuse -= bytes;
@@ -1306,7 +1306,7 @@ static int tloop_join(pid_t pid, const char *name)
 {
 	int tret;
 	if (waitpid(pid, &tret, 0) < 0) {
-		error("%s process failed to wait: %s", name, strerror(errno));
+		error_errno("%s process failed to wait", name);
 		return 1;
 	}
 	if (!WIFEXITED(tret) || WEXITSTATUS(tret)) {
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 38/41] unpack-trees.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (36 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 37/41] transport-helper.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 39/41] upload-pack.c: " Nguyễn Thái Ngọc Duy
                     ` (5 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 unpack-trees.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index 9f55cc2..bb0d142 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1499,8 +1499,7 @@ static int verify_absent_1(const struct cache_entry *ce,
 
 		path = xmemdupz(ce->name, len);
 		if (lstat(path, &st))
-			ret = error("cannot stat '%s': %s", path,
-					strerror(errno));
+			ret = error_errno("cannot stat '%s'", path);
 		else
 			ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,
 						 &st, error_type, o);
@@ -1508,8 +1507,7 @@ static int verify_absent_1(const struct cache_entry *ce,
 		return ret;
 	} else if (lstat(ce->name, &st)) {
 		if (errno != ENOENT)
-			return error("cannot stat '%s': %s", ce->name,
-				     strerror(errno));
+			return error_errno("cannot stat '%s'", ce->name);
 		return 0;
 	} else {
 		return check_ok_to_remove(ce->name, ce_namelen(ce),
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 39/41] upload-pack.c: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (37 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 38/41] unpack-trees.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 40/41] vcs-svn: " Nguyễn Thái Ngọc Duy
                     ` (4 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 upload-pack.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/upload-pack.c b/upload-pack.c
index dc802a0..f19444d 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -174,8 +174,7 @@ static void create_pack_file(void)
 
 		if (ret < 0) {
 			if (errno != EINTR) {
-				error("poll failed, resuming: %s",
-				      strerror(errno));
+				error_errno("poll failed, resuming");
 				sleep(1);
 			}
 			continue;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 40/41] vcs-svn: use error_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (38 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 39/41] upload-pack.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 12:04   ` [PATCH v2 41/41] wrapper.c: use warning_errno() Nguyễn Thái Ngọc Duy
                     ` (3 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 vcs-svn/line_buffer.c    | 4 ++--
 vcs-svn/sliding_window.c | 2 +-
 vcs-svn/svndiff.c        | 4 ++--
 vcs-svn/svndump.c        | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/vcs-svn/line_buffer.c b/vcs-svn/line_buffer.c
index 57cc1ce..e416caf 100644
--- a/vcs-svn/line_buffer.c
+++ b/vcs-svn/line_buffer.c
@@ -53,9 +53,9 @@ long buffer_tmpfile_prepare_to_read(struct line_buffer *buf)
 {
 	long pos = ftell(buf->infile);
 	if (pos < 0)
-		return error("ftell error: %s", strerror(errno));
+		return error_errno("ftell error");
 	if (fseek(buf->infile, 0, SEEK_SET))
-		return error("seek error: %s", strerror(errno));
+		return error_errno("seek error");
 	return pos;
 }
 
diff --git a/vcs-svn/sliding_window.c b/vcs-svn/sliding_window.c
index f11d490..06d273c 100644
--- a/vcs-svn/sliding_window.c
+++ b/vcs-svn/sliding_window.c
@@ -12,7 +12,7 @@ static int input_error(struct line_buffer *file)
 {
 	if (!buffer_ferror(file))
 		return error("delta preimage ends early");
-	return error("cannot read delta preimage: %s", strerror(errno));
+	return error_errno("cannot read delta preimage");
 }
 
 static int skip_or_whine(struct line_buffer *file, off_t gap)
diff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c
index 74c97c4..75c7531 100644
--- a/vcs-svn/svndiff.c
+++ b/vcs-svn/svndiff.c
@@ -64,13 +64,13 @@ static int write_strbuf(struct strbuf *sb, FILE *out)
 {
 	if (fwrite(sb->buf, 1, sb->len, out) == sb->len)	/* Success. */
 		return 0;
-	return error("cannot write delta postimage: %s", strerror(errno));
+	return error_errno("cannot write delta postimage");
 }
 
 static int error_short_read(struct line_buffer *input)
 {
 	if (buffer_ferror(input))
-		return error("error reading delta: %s", strerror(errno));
+		return error_errno("error reading delta");
 	return error("invalid delta: unexpected end of file");
 }
 
diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c
index 31d1d83..e4b3959 100644
--- a/vcs-svn/svndump.c
+++ b/vcs-svn/svndump.c
@@ -501,7 +501,7 @@ static void init(int report_fd)
 int svndump_init(const char *filename)
 {
 	if (buffer_init(&input, filename))
-		return error("cannot open %s: %s", filename ? filename : "NULL", strerror(errno));
+		return error_errno("cannot open %s", filename ? filename : "NULL");
 	init(REPORT_FILENO);
 	return 0;
 }
@@ -509,7 +509,7 @@ int svndump_init(const char *filename)
 int svndump_init_fd(int in_fd, int back_fd)
 {
 	if(buffer_fdinit(&input, xdup(in_fd)))
-		return error("cannot open fd %d: %s", in_fd, strerror(errno));
+		return error_errno("cannot open fd %d", in_fd);
 	init(xdup(back_fd));
 	return 0;
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v2 41/41] wrapper.c: use warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (39 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 40/41] vcs-svn: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 12:04   ` Nguyễn Thái Ngọc Duy
  2016-05-03 16:55   ` [PATCH v2 00/41] Add and use error_errno() and warning_errno() Eric Sunshine
                     ` (2 subsequent siblings)
  43 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-03 12:04 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 wrapper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/wrapper.c b/wrapper.c
index 9afc1a0..3df2fe0 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -572,7 +572,7 @@ static int warn_if_unremovable(const char *op, const char *file, int rc)
 	if (!rc || errno == ENOENT)
 		return 0;
 	err = errno;
-	warning("unable to %s %s: %s", op, file, strerror(errno));
+	warning_errno("unable to %s %s", op, file);
 	errno = err;
 	return rc;
 }
@@ -608,7 +608,7 @@ int remove_or_warn(unsigned int mode, const char *file)
 
 void warn_on_inaccessible(const char *path)
 {
-	warning(_("unable to access '%s': %s"), path, strerror(errno));
+	warning_errno(_("unable to access '%s'"), path);
 }
 
 static int access_error_is_ok(int err, unsigned flag)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* Re: [PATCH v2 12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error
  2016-05-03 12:03   ` [PATCH v2 12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error Nguyễn Thái Ngọc Duy
@ 2016-05-03 16:52     ` Eric Sunshine
  0 siblings, 0 replies; 145+ messages in thread
From: Eric Sunshine @ 2016-05-03 16:52 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List, Junio C Hamano, Jeff King

On Tue, May 3, 2016 at 8:03 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> "errno" is already passed in as "err". Here we should use err instead of
> errno. errno is probably a copy/paste mistake in e011054 (Teach
> git-update-index about gitlinks - 2007-04-12)

Thanks, this version is quite sensible and doesn't trigger any
feelings of discomfort[1].

[1]: http://thread.gmane.org/gmane.comp.version-control.git/293150/focus=293205

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  builtin/update-index.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/update-index.c b/builtin/update-index.c
> index 1c94ca5..b8b8522 100644
> --- a/builtin/update-index.c
> +++ b/builtin/update-index.c
> @@ -255,7 +255,7 @@ static int process_lstat_error(const char *path, int err)
>  {
>         if (err == ENOENT || err == ENOTDIR)
>                 return remove_one_path(path);
> -       return error("lstat(\"%s\"): %s", path, strerror(errno));
> +       return error("lstat(\"%s\"): %s", path, strerror(err));
>  }
>
>  static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)
> --
> 2.8.0.rc0.210.gd302cd2

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH v2 00/41] Add and use error_errno() and warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (40 preceding siblings ...)
  2016-05-03 12:04   ` [PATCH v2 41/41] wrapper.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 16:55   ` Eric Sunshine
  2016-05-03 20:11   ` Junio C Hamano
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
  43 siblings, 0 replies; 145+ messages in thread
From: Eric Sunshine @ 2016-05-03 16:55 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List, Junio C Hamano, Jeff King

On Tue, May 3, 2016 at 8:03 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> Changes are in
>
>   [01/41] usage.c: move format processing out of die_errno()
>   [02/41] usage.c: add warning_errno() and error_errno()
>   [12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error
>   [17/41] compat/win32/syslog.c: use warning_errno()
>   [27/41] grep.c: use error_errno()
>
> 12/41 is basically a revert with s/strerror(errno)/strerror(err)/.
> Interdiff from v1

The interdiff looks quite sensible. Thanks.


> -- 8< --
> diff --git a/builtin/update-index.c b/builtin/update-index.c
> index 0c539ed..b8b8522 100644
> --- a/builtin/update-index.c
> +++ b/builtin/update-index.c
> @@ -251,11 +251,11 @@ static int remove_one_path(const char *path)
>   *    succeeds.
>   *  - permission error. That's never ok.
>   */
> -static int process_lstat_error(const char *path)
> +static int process_lstat_error(const char *path, int err)
>  {
> -       if (errno == ENOENT || errno == ENOTDIR)
> +       if (err == ENOENT || err == ENOTDIR)
>                 return remove_one_path(path);
> -       return error_errno("lstat(\"%s\")", path);
> +       return error("lstat(\"%s\"): %s", path, strerror(err));
>  }
>
>  static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)
> @@ -382,7 +382,7 @@ static int process_path(const char *path)
>          * what to do about the pathname!
>          */
>         if (lstat(path, &st) < 0)
> -               return process_lstat_error(path);
> +               return process_lstat_error(path, errno);
>
>         if (S_ISDIR(st.st_mode))
>                 return process_directory(path, len, &st);
> diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c
> index 1c2ae18..6c7c9b6 100644
> --- a/compat/win32/syslog.c
> +++ b/compat/win32/syslog.c
> @@ -28,7 +28,7 @@ void syslog(int priority, const char *fmt, ...)
>         va_end(ap);
>
>         if (str_len < 0) {
> -               warning_errno("vsnprintf failed:");
> +               warning_errno("vsnprintf failed");
>                 return;
>         }
>
> diff --git a/grep.c b/grep.c
> index 87c1890..4f3779a 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)
>         if (lstat(filename, &st) < 0) {
>         err_ret:
>                 if (errno != ENOENT)
> -                       error_errno(_("'%s'"), filename);
> +                       error_errno("'%s'", filename);
>                 return -1;
>         }
>         if (!S_ISREG(st.st_mode))
> diff --git a/usage.c b/usage.c
> index af1b7d1..1dad03f 100644
> --- a/usage.c
> +++ b/usage.c
> @@ -109,9 +109,8 @@ void NORETURN die(const char *err, ...)
>         va_end(params);
>  }
>
> -static const char *fmt_with_err(const char *fmt)
> +static const char *fmt_with_err(char *buf, int n, const char *fmt)
>  {
> -       static char fmt_with_err[1024];
>         char str_error[256], *err;
>         int i, j;
>
> @@ -129,12 +128,13 @@ static const char *fmt_with_err(const char *fmt)
>                 }
>         }
>         str_error[j] = 0;
> -       snprintf(fmt_with_err, sizeof(fmt_with_err), "%s: %s", fmt, str_error);
> -       return fmt_with_err;
> +       snprintf(buf, n, "%s: %s", fmt, str_error);
> +       return buf;
>  }
>
>  void NORETURN die_errno(const char *fmt, ...)
>  {
> +       char buf[1024];
>         va_list params;
>
>         if (die_is_recursing()) {
> @@ -144,16 +144,17 @@ void NORETURN die_errno(const char *fmt, ...)
>         }
>
>         va_start(params, fmt);
> -       die_routine(fmt_with_err(fmt), params);
> +       die_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
>         va_end(params);
>  }
>
>  int error_errno(const char *fmt, ...)
>  {
> +       char buf[1024];
>         va_list params;
>
>         va_start(params, fmt);
> -       error_routine(fmt_with_err(fmt), params);
> +       error_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
>         va_end(params);
>         return -1;
>  }
> @@ -171,10 +172,11 @@ int error(const char *err, ...)
>
>  void warning_errno(const char *warn, ...)
>  {
> +       char buf[1024];
>         va_list params;
>
>         va_start(params, warn);
> -       warn_routine(fmt_with_err(warn), params);
> +       warn_routine(fmt_with_err(buf, sizeof(buf), warn), params);
>         va_end(params);
>  }
>
> -- 8< --

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH v2 06/41] builtin/fetch.c: use error_errno()
  2016-05-03 12:03   ` [PATCH v2 06/41] builtin/fetch.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 19:22     ` Junio C Hamano
  0 siblings, 0 replies; 145+ messages in thread
From: Junio C Hamano @ 2016-05-03 19:22 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, Eric Sunshine, Jeff King

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index f8455bd..1582ca7 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -607,7 +607,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
>  
>  	fp = fopen(filename, "a");
>  	if (!fp)
> -		return error(_("cannot open %s: %s\n"), filename, strerror(errno));
> +		return error_errno(_("cannot open %s"), filename);
>  
>  	if (raw_url)
>  		url = transport_anonymize_url(raw_url);
> @@ -848,7 +848,7 @@ static int truncate_fetch_head(void)
>  	FILE *fp = fopen_for_writing(filename);
>  
>  	if (!fp)
> -		return error(_("cannot open %s: %s\n"), filename, strerror(errno));
> +		return error_errno(_("cannot open %s"), filename);
>  	fclose(fp);
>  	return 0;
>  }

Both of these original had unwanted \n at the end, and the updated
one loses them, which is good.

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH v2 08/41] builtin/mailsplit.c: use error_errno()
  2016-05-03 12:03   ` [PATCH v2 08/41] builtin/mailsplit.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 19:48     ` Junio C Hamano
  0 siblings, 0 replies; 145+ messages in thread
From: Junio C Hamano @ 2016-05-03 19:48 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, Eric Sunshine, Jeff King

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
> -			error("cannot opendir %s (%s)", name, strerror(errno));
> +			error_errno("cannot opendir %s", name);
> -			error("cannot open mail %s (%s)", file, strerror(errno));
> +			error_errno("cannot open mail %s", file);
> -			error("cannot read mail %s (%s)", file, strerror(errno));
> +			error_errno("cannot read mail %s", file);
> -			error("cannot stat %s (%s)", arg, strerror(errno));
> +			error_errno("cannot stat %s", arg);

These all used to use its own formatting, but will use "<message>: <errno>"
format like everybody else, which is good.

> @@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
>  	int file_done = 0;
>  
>  	if (!f) {
> -		error("cannot open mbox %s", file);
> +		error_errno("cannot open mbox %s", file);
>  		goto out;
>  	}

It may be a bit unclear from the context, but it uses errno that was
set when fopen() returned a NULL.

The changes in this patch are not faithful conversion like other
patches, but they are all good, I would say.

Thanks.

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH v2 10/41] builtin/pack-objects.c: use die_errno() and warning_errno()
  2016-05-03 12:03   ` [PATCH v2 10/41] builtin/pack-objects.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 19:54     ` Junio C Hamano
  0 siblings, 0 replies; 145+ messages in thread
From: Junio C Hamano @ 2016-05-03 19:54 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, Eric Sunshine, Jeff King

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---

> @@ -2020,7 +2018,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
>  		ret = pthread_create(&p[i].thread, NULL,
>  				     threaded_find_deltas, &p[i]);
>  		if (ret)
> -			die("unable to create thread: %s", strerror(ret));
> +			die_errno("unable to create thread");

This deserves a mention in the log message.  pthread_create()
returns 0 on success and it returns "an error number" on error.  We
used to format that returned value with strerror().

I do not see anywhere in the updated code that copies ret back to
errno, which would mean die_errno() would use whatever happens to be
in errno, and the relationship between the returned value 'ret' and
the value that is in 'errno' at this point in the code is unclear to
me.

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH v2 11/41] builtin/rm.c: use warning_errno()
  2016-05-03 12:03   ` [PATCH v2 11/41] builtin/rm.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-03 19:58     ` Junio C Hamano
  0 siblings, 0 replies; 145+ messages in thread
From: Junio C Hamano @ 2016-05-03 19:58 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, Eric Sunshine, Jeff King

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  builtin/rm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/rm.c b/builtin/rm.c
> index 8829b09..13b9639 100644
> --- a/builtin/rm.c
> +++ b/builtin/rm.c
> @@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only)
>  
>  		if (lstat(ce->name, &st) < 0) {
>  			if (errno != ENOENT && errno != ENOTDIR)
> -				warning("'%s': %s", ce->name, strerror(errno));
> +				warning_errno("'%s'", ce->name);
>  			/* It already vanished from the working tree */
>  			continue;

Not a new problem with this patch, but this would say

    warning: 'Makefile': Permission denied.

or whatever error we may happen to have hit.

I think we show strerror(errno) as an additional explanation and
there must be something _else_ that is the primary thing we would
want to say, e.g.

    warning: cannot remove 'Makefile': Permission denied.

Without that primary message from us, it looks somewhat wrong.

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH v2 14/41] builtin/worktree.c: use error_errno()
  2016-05-03 12:03   ` [PATCH v2 14/41] builtin/worktree.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-03 20:02     ` Junio C Hamano
  0 siblings, 0 replies; 145+ messages in thread
From: Junio C Hamano @ 2016-05-03 20:02 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, Eric Sunshine, Jeff King

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  builtin/worktree.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/worktree.c b/builtin/worktree.c
> index d8e3795..331ecf6 100644
> --- a/builtin/worktree.c
> +++ b/builtin/worktree.c
> @@ -110,7 +110,7 @@ static void prune_worktrees(void)
>  		if (ret < 0 && errno == ENOTDIR)
>  			ret = unlink(path.buf);
>  		if (ret)
> -			error(_("failed to remove: %s"), strerror(errno));
> +			error_errno(_("failed to remove '%s'"), path.buf);

This also deserves a mention in the log message.  We didn't say what
we failed to remove, now we do, which is an improvement.

^ permalink raw reply	[flat|nested] 145+ messages in thread

* Re: [PATCH v2 00/41] Add and use error_errno() and warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (41 preceding siblings ...)
  2016-05-03 16:55   ` [PATCH v2 00/41] Add and use error_errno() and warning_errno() Eric Sunshine
@ 2016-05-03 20:11   ` Junio C Hamano
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
  43 siblings, 0 replies; 145+ messages in thread
From: Junio C Hamano @ 2016-05-03 20:11 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, Eric Sunshine, Jeff King

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> Changes are in
>
>   [01/41] usage.c: move format processing out of die_errno()
>   [02/41] usage.c: add warning_errno() and error_errno()
>   [12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error
>   [17/41] compat/win32/syslog.c: use warning_errno()
>   [27/41] grep.c: use error_errno()
>
> 12/41 is basically a revert with s/strerror(errno)/strerror(err)/.
> Interdiff from v1

Thanks.  The earlier parts that lay the foundation looked good, and
most of the conversion of the callers were, too (I think there was
only one whose validity I wasn't sure about, though).

Some of the changes that are more than a straight and faithful
conversion, i.e. fixes to places that used to show an extra newline,
used to lack errno in the output, etc., deserve to be mentioned in
the log message of respective patches.

Thanks.

^ permalink raw reply	[flat|nested] 145+ messages in thread

* [PATCH v3 00/41] Add and use error_errno() and warning_errno()
  2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
                     ` (42 preceding siblings ...)
  2016-05-03 20:11   ` Junio C Hamano
@ 2016-05-08  9:47   ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
                       ` (40 more replies)
  43 siblings, 41 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Code changes compared to v2 is below (one incorrect conversion
reverted, two error message improvements). Other changes are text in
these commits, not shown as diff in this mail:

  [06/41] builtin/fetch.c: use error_errno()
  [08/41] builtin/mailsplit.c: use error_errno()
  [09/41] builtin/merge-file.c: use error_errno()
  [11/41] builtin/rm.c: use warning_errno()
  [14/41] builtin/worktree.c: use error_errno()
  [27/41] grep.c: use error_errno()

I didn't mention string format changes (e.g. from "abc (error)" to
"abc: error") in the commit messages though.

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index e18e190..1145747 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2018,7 +2018,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
 		ret = pthread_create(&p[i].thread, NULL,
 				     threaded_find_deltas, &p[i]);
 		if (ret)
-			die_errno("unable to create thread");
+			die("unable to create thread: %s", strerror(ret));
 		active_threads++;
 	}
 
diff --git a/builtin/rm.c b/builtin/rm.c
index 13b9639..fd47d20 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only)
 
 		if (lstat(ce->name, &st) < 0) {
 			if (errno != ENOENT && errno != ENOTDIR)
-				warning_errno("'%s'", ce->name);
+				warning_errno(_("failed to stat '%s'"), ce->name);
 			/* It already vanished from the working tree */
 			continue;
 		}
diff --git a/grep.c b/grep.c
index 4f3779a..ec6f7ff 100644
--- a/grep.c
+++ b/grep.c
@@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)
 	if (lstat(filename, &st) < 0) {
 	err_ret:
 		if (errno != ENOENT)
-			error_errno("'%s'", filename);
+			error_errno(_("failed to stat '%s'"), filename);
 		return -1;
 	}
 	if (!S_ISREG(st.st_mode))

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 01/41] usage.c: move format processing out of die_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 02/41] usage.c: add warning_errno() and error_errno() Nguyễn Thái Ngọc Duy
                       ` (39 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

fmt_with_err() will be shared with the coming error_errno() and
warning_errno().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 usage.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/usage.c b/usage.c
index 82ff131..8675d72 100644
--- a/usage.c
+++ b/usage.c
@@ -109,19 +109,11 @@ void NORETURN die(const char *err, ...)
 	va_end(params);
 }
 
-void NORETURN die_errno(const char *fmt, ...)
+static const char *fmt_with_err(char *buf, int n, const char *fmt)
 {
-	va_list params;
-	char fmt_with_err[1024];
 	char str_error[256], *err;
 	int i, j;
 
-	if (die_is_recursing()) {
-		fputs("fatal: recursion detected in die_errno handler\n",
-			stderr);
-		exit(128);
-	}
-
 	err = strerror(errno);
 	for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {
 		if ((str_error[j++] = err[i++]) != '%')
@@ -136,10 +128,23 @@ void NORETURN die_errno(const char *fmt, ...)
 		}
 	}
 	str_error[j] = 0;
-	snprintf(fmt_with_err, sizeof(fmt_with_err), "%s: %s", fmt, str_error);
+	snprintf(buf, n, "%s: %s", fmt, str_error);
+	return buf;
+}
+
+void NORETURN die_errno(const char *fmt, ...)
+{
+	char buf[1024];
+	va_list params;
+
+	if (die_is_recursing()) {
+		fputs("fatal: recursion detected in die_errno handler\n",
+			stderr);
+		exit(128);
+	}
 
 	va_start(params, fmt);
-	die_routine(fmt_with_err, params);
+	die_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
 	va_end(params);
 }
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 02/41] usage.c: add warning_errno() and error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 03/41] bisect.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                       ` (38 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Similar to die_errno(), these functions will append strerror()
automatically.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 git-compat-util.h |  2 ++
 usage.c           | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/git-compat-util.h b/git-compat-util.h
index 1f8b5f3..49d4029 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -409,7 +409,9 @@ extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf,
 extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
+extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
+extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
 
 #ifndef NO_OPENSSL
 #ifdef APPLE_COMMON_CRYPTO
diff --git a/usage.c b/usage.c
index 8675d72..1dad03f 100644
--- a/usage.c
+++ b/usage.c
@@ -148,6 +148,17 @@ void NORETURN die_errno(const char *fmt, ...)
 	va_end(params);
 }
 
+int error_errno(const char *fmt, ...)
+{
+	char buf[1024];
+	va_list params;
+
+	va_start(params, fmt);
+	error_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
+	va_end(params);
+	return -1;
+}
+
 #undef error
 int error(const char *err, ...)
 {
@@ -159,6 +170,16 @@ int error(const char *err, ...)
 	return -1;
 }
 
+void warning_errno(const char *warn, ...)
+{
+	char buf[1024];
+	va_list params;
+
+	va_start(params, warn);
+	warn_routine(fmt_with_err(buf, sizeof(buf), warn), params);
+	va_end(params);
+}
+
 void warning(const char *warn, ...)
 {
 	va_list params;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 03/41] bisect.c: use die_errno() and warning_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 02/41] usage.c: add warning_errno() and error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 04/41] builtin/am.c: use error_errno() Nguyễn Thái Ngọc Duy
                       ` (37 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 bisect.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/bisect.c b/bisect.c
index 7996c29..6d93edb 100644
--- a/bisect.c
+++ b/bisect.c
@@ -860,8 +860,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
 	/* Create file BISECT_ANCESTORS_OK. */
 	fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);
 	if (fd < 0)
-		warning("could not create file '%s': %s",
-			filename, strerror(errno));
+		warning_errno("could not create file '%s'",
+			      filename);
 	else
 		close(fd);
  done:
@@ -910,8 +910,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
 			*read_good = "good";
 			return;
 		} else {
-			die("could not read file '%s': %s", filename,
-				strerror(errno));
+			die_errno("could not read file '%s'", filename);
 		}
 	} else {
 		strbuf_getline_lf(&str, fp);
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 04/41] builtin/am.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (2 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 03/41] bisect.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 05/41] builtin/branch.c: " Nguyễn Thái Ngọc Duy
                       ` (36 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/am.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index d003939..3dfe70b 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -769,15 +769,15 @@ static int split_mail_conv(mail_conv_fn fn, struct am_state *state,
 			in = fopen(*paths, "r");
 
 		if (!in)
-			return error(_("could not open '%s' for reading: %s"),
-					*paths, strerror(errno));
+			return error_errno(_("could not open '%s' for reading"),
+					   *paths);
 
 		mail = mkpath("%s/%0*d", state->dir, state->prec, i + 1);
 
 		out = fopen(mail, "w");
 		if (!out)
-			return error(_("could not open '%s' for writing: %s"),
-					mail, strerror(errno));
+			return error_errno(_("could not open '%s' for writing"),
+					   mail);
 
 		ret = fn(out, in, keep_cr);
 
@@ -857,8 +857,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,
 
 	fp = fopen(*paths, "r");
 	if (!fp)
-		return error(_("could not open '%s' for reading: %s"), *paths,
-				strerror(errno));
+		return error_errno(_("could not open '%s' for reading"), *paths);
 
 	while (!strbuf_getline_lf(&sb, fp)) {
 		if (*sb.buf == '#')
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 05/41] builtin/branch.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (3 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 04/41] builtin/am.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 06/41] builtin/fetch.c: " Nguyễn Thái Ngọc Duy
                       ` (35 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/branch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index 0adba62..6f1572d 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -593,8 +593,7 @@ static int edit_branch_description(const char *branch_name)
 		    branch_name, comment_line_char);
 	if (write_file_gently(git_path(edit_description), "%s", buf.buf)) {
 		strbuf_release(&buf);
-		return error(_("could not write branch description template: %s"),
-			     strerror(errno));
+		return error_errno(_("could not write branch description template"));
 	}
 	strbuf_reset(&buf);
 	if (launch_editor(git_path(edit_description), &buf, NULL)) {
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 06/41] builtin/fetch.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (4 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 05/41] builtin/branch.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 07/41] builtin/help.c: use warning_errno() Nguyễn Thái Ngọc Duy
                       ` (34 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

A couple of newlines are also removed, because both error() and
error_errno() automatically append a newline.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fetch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index f8455bd..1582ca7 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -607,7 +607,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 
 	fp = fopen(filename, "a");
 	if (!fp)
-		return error(_("cannot open %s: %s\n"), filename, strerror(errno));
+		return error_errno(_("cannot open %s"), filename);
 
 	if (raw_url)
 		url = transport_anonymize_url(raw_url);
@@ -848,7 +848,7 @@ static int truncate_fetch_head(void)
 	FILE *fp = fopen_for_writing(filename);
 
 	if (!fp)
-		return error(_("cannot open %s: %s\n"), filename, strerror(errno));
+		return error_errno(_("cannot open %s"), filename);
 	fclose(fp);
 	return 0;
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 07/41] builtin/help.c: use warning_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (5 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 06/41] builtin/fetch.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 08/41] builtin/mailsplit.c: use error_errno() Nguyễn Thái Ngọc Duy
                       ` (33 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/help.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/help.c b/builtin/help.c
index 3c55ce4..8848013 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -127,7 +127,7 @@ static void exec_woman_emacs(const char *path, const char *page)
 			path = "emacsclient";
 		strbuf_addf(&man_page, "(woman \"%s\")", page);
 		execlp(path, "emacsclient", "-e", man_page.buf, (char *)NULL);
-		warning(_("failed to exec '%s': %s"), path, strerror(errno));
+		warning_errno(_("failed to exec '%s'"), path);
 	}
 }
 
@@ -148,7 +148,7 @@ static void exec_man_konqueror(const char *path, const char *page)
 			path = "kfmclient";
 		strbuf_addf(&man_page, "man:%s(1)", page);
 		execlp(path, filename, "newTab", man_page.buf, (char *)NULL);
-		warning(_("failed to exec '%s': %s"), path, strerror(errno));
+		warning_errno(_("failed to exec '%s'"), path);
 	}
 }
 
@@ -157,7 +157,7 @@ static void exec_man_man(const char *path, const char *page)
 	if (!path)
 		path = "man";
 	execlp(path, "man", page, (char *)NULL);
-	warning(_("failed to exec '%s': %s"), path, strerror(errno));
+	warning_errno(_("failed to exec '%s'"), path);
 }
 
 static void exec_man_cmd(const char *cmd, const char *page)
@@ -165,7 +165,7 @@ static void exec_man_cmd(const char *cmd, const char *page)
 	struct strbuf shell_cmd = STRBUF_INIT;
 	strbuf_addf(&shell_cmd, "%s %s", cmd, page);
 	execl(SHELL_PATH, SHELL_PATH, "-c", shell_cmd.buf, (char *)NULL);
-	warning(_("failed to exec '%s': %s"), cmd, strerror(errno));
+	warning(_("failed to exec '%s'"), cmd);
 }
 
 static void add_man_viewer(const char *name)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 08/41] builtin/mailsplit.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (6 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 07/41] builtin/help.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 09/41] builtin/merge-file.c: " Nguyễn Thái Ngọc Duy
                       ` (32 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

There's one change, in split_mbox(), where an error() without strerror()
as argument is converted to error_errno(). This is correct because the
previous call is fopen (not shown in the context lines), which should
set errno if it returns NULL.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/mailsplit.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
index 104277a..4859ede 100644
--- a/builtin/mailsplit.c
+++ b/builtin/mailsplit.c
@@ -109,7 +109,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)
 		if ((dir = opendir(name)) == NULL) {
 			if (errno == ENOENT)
 				continue;
-			error("cannot opendir %s (%s)", name, strerror(errno));
+			error_errno("cannot opendir %s", name);
 			goto out;
 		}
 
@@ -174,12 +174,12 @@ static int split_maildir(const char *maildir, const char *dir,
 
 		f = fopen(file, "r");
 		if (!f) {
-			error("cannot open mail %s (%s)", file, strerror(errno));
+			error_errno("cannot open mail %s", file);
 			goto out;
 		}
 
 		if (strbuf_getwholeline(&buf, f, '\n')) {
-			error("cannot read mail %s (%s)", file, strerror(errno));
+			error_errno("cannot read mail %s", file);
 			goto out;
 		}
 
@@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
 	int file_done = 0;
 
 	if (!f) {
-		error("cannot open mbox %s", file);
+		error_errno("cannot open mbox %s", file);
 		goto out;
 	}
 
@@ -318,7 +318,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)
 		}
 
 		if (stat(arg, &argstat) == -1) {
-			error("cannot stat %s (%s)", arg, strerror(errno));
+			error_errno("cannot stat %s", arg);
 			return 1;
 		}
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 09/41] builtin/merge-file.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (7 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 08/41] builtin/mailsplit.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 10/41] builtin/pack-objects.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                       ` (31 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

All these error() calls do not print error message previously, but
because when they are called, errno should be set. Use error_errno()
instead to give more information.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/merge-file.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 5544705..13e22a2 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -62,8 +62,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 		usage_with_options(merge_file_usage, options);
 	if (quiet) {
 		if (!freopen("/dev/null", "w", stderr))
-			return error("failed to redirect stderr to /dev/null: "
-				     "%s", strerror(errno));
+			return error_errno("failed to redirect stderr to /dev/null");
 	}
 
 	if (prefix)
@@ -95,12 +94,13 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 		FILE *f = to_stdout ? stdout : fopen(fpath, "wb");
 
 		if (!f)
-			ret = error("Could not open %s for writing", filename);
+			ret = error_errno("Could not open %s for writing",
+					  filename);
 		else if (result.size &&
 			 fwrite(result.ptr, result.size, 1, f) != 1)
-			ret = error("Could not write to %s", filename);
+			ret = error_errno("Could not write to %s", filename);
 		else if (fclose(f))
-			ret = error("Could not close %s", filename);
+			ret = error_errno("Could not close %s", filename);
 		free(result.ptr);
 	}
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 10/41] builtin/pack-objects.c: use die_errno() and warning_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (8 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 09/41] builtin/merge-file.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 11/41] builtin/rm.c: use warning_errno() Nguyễn Thái Ngọc Duy
                       ` (30 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/pack-objects.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index a27de5b..1145747 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -828,8 +828,7 @@ static void write_pack_file(void)
 			 * to preserve this property.
 			 */
 			if (stat(pack_tmp_name, &st) < 0) {
-				warning("failed to stat %s: %s",
-					pack_tmp_name, strerror(errno));
+				warning_errno("failed to stat %s", pack_tmp_name);
 			} else if (!last_mtime) {
 				last_mtime = st.st_mtime;
 			} else {
@@ -837,8 +836,7 @@ static void write_pack_file(void)
 				utb.actime = st.st_atime;
 				utb.modtime = --last_mtime;
 				if (utime(pack_tmp_name, &utb) < 0)
-					warning("failed utime() on %s: %s",
-						pack_tmp_name, strerror(errno));
+					warning_errno("failed utime() on %s", pack_tmp_name);
 			}
 
 			strbuf_addf(&tmpname, "%s-", base_name);
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 11/41] builtin/rm.c: use warning_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (9 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 10/41] builtin/pack-objects.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error Nguyễn Thái Ngọc Duy
                       ` (29 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

While at there, improve the message a bit (what operation failed?) and
mark it for translation since the format string is now a sentence.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/rm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/rm.c b/builtin/rm.c
index 8829b09..fd47d20 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only)
 
 		if (lstat(ce->name, &st) < 0) {
 			if (errno != ENOENT && errno != ENOTDIR)
-				warning("'%s': %s", ce->name, strerror(errno));
+				warning_errno(_("failed to stat '%s'"), ce->name);
 			/* It already vanished from the working tree */
 			continue;
 		}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (10 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 11/41] builtin/rm.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 13/41] builtin/upload-archive.c: use error_errno() Nguyễn Thái Ngọc Duy
                       ` (28 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

"errno" is already passed in as "err". Here we should use err instead of
errno. errno is probably a copy/paste mistake in e011054 (Teach
git-update-index about gitlinks - 2007-04-12)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/update-index.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/update-index.c b/builtin/update-index.c
index 1c94ca5..b8b8522 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -255,7 +255,7 @@ static int process_lstat_error(const char *path, int err)
 {
 	if (err == ENOENT || err == ENOTDIR)
 		return remove_one_path(path);
-	return error("lstat(\"%s\"): %s", path, strerror(errno));
+	return error("lstat(\"%s\"): %s", path, strerror(err));
 }
 
 static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 13/41] builtin/upload-archive.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (11 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 14/41] builtin/worktree.c: " Nguyễn Thái Ngọc Duy
                       ` (27 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/upload-archive.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index dbfe14f..2caedf1 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -104,8 +104,7 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
 		pfd[1].events = POLLIN;
 		if (poll(pfd, 2, -1) < 0) {
 			if (errno != EINTR) {
-				error("poll failed resuming: %s",
-				      strerror(errno));
+				error_errno("poll failed resuming");
 				sleep(1);
 			}
 			continue;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 14/41] builtin/worktree.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (12 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 13/41] builtin/upload-archive.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 15/41] check-racy.c: " Nguyễn Thái Ngọc Duy
                       ` (26 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

While at there, improve the error message to say _what_ failed to
remove.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/worktree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index d8e3795..331ecf6 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -110,7 +110,7 @@ static void prune_worktrees(void)
 		if (ret < 0 && errno == ENOTDIR)
 			ret = unlink(path.buf);
 		if (ret)
-			error(_("failed to remove: %s"), strerror(errno));
+			error_errno(_("failed to remove '%s'"), path.buf);
 	}
 	closedir(dir);
 	if (!show_only)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 15/41] check-racy.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (13 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 14/41] builtin/worktree.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 16/41] combine-diff.c: " Nguyễn Thái Ngọc Duy
                       ` (25 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 check-racy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/check-racy.c b/check-racy.c
index 00d92a1..24b6542 100644
--- a/check-racy.c
+++ b/check-racy.c
@@ -12,7 +12,7 @@ int main(int ac, char **av)
 		struct stat st;
 
 		if (lstat(ce->name, &st)) {
-			error("lstat(%s): %s", ce->name, strerror(errno));
+			error_errno("lstat(%s)", ce->name);
 			continue;
 		}
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 16/41] combine-diff.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (14 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 15/41] check-racy.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 17/41] compat/win32/syslog.c: use warning_errno() Nguyễn Thái Ngọc Duy
                       ` (24 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 combine-diff.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/combine-diff.c b/combine-diff.c
index 0e1d4b0..8f2313d 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1005,8 +1005,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 			struct strbuf buf = STRBUF_INIT;
 
 			if (strbuf_readlink(&buf, elem->path, st.st_size) < 0) {
-				error("readlink(%s): %s", elem->path,
-				      strerror(errno));
+				error_errno("readlink(%s)", elem->path);
 				return;
 			}
 			result_size = buf.len;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 17/41] compat/win32/syslog.c: use warning_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (15 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 16/41] combine-diff.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 18/41] config.c: use error_errno() Nguyễn Thái Ngọc Duy
                       ` (23 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 compat/win32/syslog.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c
index b905aea..6c7c9b6 100644
--- a/compat/win32/syslog.c
+++ b/compat/win32/syslog.c
@@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...)
 	va_end(ap);
 
 	if (str_len < 0) {
-		warning("vsnprintf failed: '%s'", strerror(errno));
+		warning_errno("vsnprintf failed");
 		return;
 	}
 
 	str = malloc(st_add(str_len, 1));
 	if (!str) {
-		warning("malloc failed: '%s'", strerror(errno));
+		warning_errno("malloc failed");
 		return;
 	}
 
@@ -45,7 +45,7 @@ void syslog(int priority, const char *fmt, ...)
 	while ((pos = strstr(str, "%1")) != NULL) {
 		str = realloc(str, st_add(++str_len, 1));
 		if (!str) {
-			warning("realloc failed: '%s'", strerror(errno));
+			warning_errno("realloc failed");
 			return;
 		}
 		memmove(pos + 2, pos + 1, strlen(pos));
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 18/41] config.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (16 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 17/41] compat/win32/syslog.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 19/41] connected.c: " Nguyễn Thái Ngọc Duy
                       ` (22 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 config.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/config.c b/config.c
index 10b5c95..80411e4 100644
--- a/config.c
+++ b/config.c
@@ -2012,7 +2012,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 	lock = xcalloc(1, sizeof(struct lock_file));
 	fd = hold_lock_file_for_update(lock, config_filename, 0);
 	if (fd < 0) {
-		error("could not lock config file %s: %s", config_filename, strerror(errno));
+		error_errno("could not lock config file %s", config_filename);
 		free(store.key);
 		ret = CONFIG_NO_LOCK;
 		goto out_free;
@@ -2026,8 +2026,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 		free(store.key);
 
 		if ( ENOENT != errno ) {
-			error("opening %s: %s", config_filename,
-			      strerror(errno));
+			error_errno("opening %s", config_filename);
 			ret = CONFIG_INVALID_FILE; /* same as "invalid config file" */
 			goto out_free;
 		}
@@ -2111,8 +2110,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 		if (contents == MAP_FAILED) {
 			if (errno == ENODEV && S_ISDIR(st.st_mode))
 				errno = EISDIR;
-			error("unable to mmap '%s': %s",
-			      config_filename, strerror(errno));
+			error_errno("unable to mmap '%s'", config_filename);
 			ret = CONFIG_INVALID_FILE;
 			contents = NULL;
 			goto out_free;
@@ -2121,8 +2119,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 		in_fd = -1;
 
 		if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
-			error("chmod on %s failed: %s",
-			      get_lock_file_path(lock), strerror(errno));
+			error_errno("chmod on %s failed", get_lock_file_path(lock));
 			ret = CONFIG_NO_WRITE;
 			goto out_free;
 		}
@@ -2178,8 +2175,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
 	}
 
 	if (commit_lock_file(lock) < 0) {
-		error("could not write config file %s: %s", config_filename,
-		      strerror(errno));
+		error_errno("could not write config file %s", config_filename);
 		ret = CONFIG_NO_WRITE;
 		lock = NULL;
 		goto out_free;
@@ -2330,8 +2326,8 @@ int git_config_rename_section_in_file(const char *config_filename,
 	fstat(fileno(config_file), &st);
 
 	if (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {
-		ret = error("chmod on %s failed: %s",
-			    get_lock_file_path(lock), strerror(errno));
+		ret = error_errno("chmod on %s failed",
+				  get_lock_file_path(lock));
 		goto out;
 	}
 
@@ -2385,8 +2381,8 @@ int git_config_rename_section_in_file(const char *config_filename,
 	fclose(config_file);
 unlock_and_out:
 	if (commit_lock_file(lock) < 0)
-		ret = error("could not write config file %s: %s",
-			    config_filename, strerror(errno));
+		ret = error_errno("could not write config file %s",
+				  config_filename);
 out:
 	free(filename_buf);
 	return ret;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 19/41] connected.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (17 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 18/41] config.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 20/41] copy.c: " Nguyễn Thái Ngọc Duy
                       ` (21 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 connected.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/connected.c b/connected.c
index 299c560..bf1b12e 100644
--- a/connected.c
+++ b/connected.c
@@ -86,17 +86,14 @@ static int check_everything_connected_real(sha1_iterate_fn fn,
 		memcpy(commit, sha1_to_hex(sha1), 40);
 		if (write_in_full(rev_list.in, commit, 41) < 0) {
 			if (errno != EPIPE && errno != EINVAL)
-				error(_("failed write to rev-list: %s"),
-				      strerror(errno));
+				error_errno(_("failed write to rev-list"));
 			err = -1;
 			break;
 		}
 	} while (!fn(cb_data, sha1));
 
-	if (close(rev_list.in)) {
-		error(_("failed to close rev-list's stdin: %s"), strerror(errno));
-		err = -1;
-	}
+	if (close(rev_list.in))
+		err = error_errno(_("failed to close rev-list's stdin"));
 
 	sigchain_pop(SIGPIPE);
 	return finish_command(&rev_list) || err;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 20/41] copy.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (18 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 19/41] connected.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 21/41] credential-cache--daemon.c: use warning_errno() Nguyễn Thái Ngọc Duy
                       ` (20 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 copy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/copy.c b/copy.c
index 574fa1f..4de6a11 100644
--- a/copy.c
+++ b/copy.c
@@ -42,15 +42,15 @@ int copy_file(const char *dst, const char *src, int mode)
 	status = copy_fd(fdi, fdo);
 	switch (status) {
 	case COPY_READ_ERROR:
-		error("copy-fd: read returned %s", strerror(errno));
+		error_errno("copy-fd: read returned");
 		break;
 	case COPY_WRITE_ERROR:
-		error("copy-fd: write returned %s", strerror(errno));
+		error_errno("copy-fd: write returned");
 		break;
 	}
 	close(fdi);
 	if (close(fdo) != 0)
-		return error("%s: close error: %s", dst, strerror(errno));
+		return error_errno("%s: close error", dst);
 
 	if (!status && adjust_shared_perm(dst))
 		return -1;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 21/41] credential-cache--daemon.c: use warning_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (19 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 20/41] copy.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 22/41] diff-no-index.c: use error_errno() Nguyễn Thái Ngọc Duy
                       ` (19 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 credential-cache--daemon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
index 291c0fd..1f14d56 100644
--- a/credential-cache--daemon.c
+++ b/credential-cache--daemon.c
@@ -179,12 +179,12 @@ static int serve_cache_loop(int fd)
 
 		client = accept(fd, NULL, NULL);
 		if (client < 0) {
-			warning("accept failed: %s", strerror(errno));
+			warning_errno("accept failed");
 			return 1;
 		}
 		client2 = dup(client);
 		if (client2 < 0) {
-			warning("dup failed: %s", strerror(errno));
+			warning_errno("dup failed");
 			close(client);
 			return 1;
 		}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 22/41] diff-no-index.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (20 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 21/41] credential-cache--daemon.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 23/41] editor.c: " Nguyễn Thái Ngọc Duy
                       ` (18 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 diff-no-index.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/diff-no-index.c b/diff-no-index.c
index 03daadb..1f8999b 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -65,8 +65,7 @@ static int populate_from_stdin(struct diff_filespec *s)
 	size_t size = 0;
 
 	if (strbuf_read(&buf, 0, 0) < 0)
-		return error("error while reading from stdin %s",
-				     strerror(errno));
+		return error_errno("error while reading from stdin");
 
 	s->should_munmap = 0;
 	s->data = strbuf_detach(&buf, &size);
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 23/41] editor.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (21 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 22/41] diff-no-index.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 24/41] entry.c: " Nguyễn Thái Ngọc Duy
                       ` (17 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 editor.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/editor.c b/editor.c
index 01c644c..7519ede 100644
--- a/editor.c
+++ b/editor.c
@@ -63,7 +63,6 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
 	if (!buffer)
 		return 0;
 	if (strbuf_read_file(buffer, path, 0) < 0)
-		return error("could not read file '%s': %s",
-				path, strerror(errno));
+		return error_errno("could not read file '%s'", path);
 	return 0;
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 24/41] entry.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (22 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 23/41] editor.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 25/41] fast-import.c: " Nguyễn Thái Ngọc Duy
                       ` (16 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 entry.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/entry.c b/entry.c
index a410957..519e042 100644
--- a/entry.c
+++ b/entry.c
@@ -168,8 +168,8 @@ static int write_entry(struct cache_entry *ce,
 			ret = symlink(new, path);
 			free(new);
 			if (ret)
-				return error("unable to create symlink %s (%s)",
-					     path, strerror(errno));
+				return error_errno("unable to create symlink %s",
+						   path);
 			break;
 		}
 
@@ -186,8 +186,7 @@ static int write_entry(struct cache_entry *ce,
 		fd = open_output_fd(path, ce, to_tempfile);
 		if (fd < 0) {
 			free(new);
-			return error("unable to create file %s (%s)",
-				path, strerror(errno));
+			return error_errno("unable to create file %s", path);
 		}
 
 		wrote = write_in_full(fd, new, size);
@@ -284,8 +283,7 @@ int checkout_entry(struct cache_entry *ce,
 				return error("%s is a directory", path.buf);
 			remove_subtree(&path);
 		} else if (unlink(path.buf))
-			return error("unable to unlink old '%s' (%s)",
-				     path.buf, strerror(errno));
+			return error_errno("unable to unlink old '%s'", path.buf);
 	} else if (state->not_new)
 		return 0;
 
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 25/41] fast-import.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (23 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 24/41] entry.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 26/41] gpg-interface.c: " Nguyễn Thái Ngọc Duy
                       ` (15 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 fast-import.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index 9fc7093..21881d1 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -414,7 +414,7 @@ static void write_crash_report(const char *err)
 	struct recent_command *rc;
 
 	if (!rpt) {
-		error("can't write crash report %s: %s", loc, strerror(errno));
+		error_errno("can't write crash report %s", loc);
 		free(loc);
 		return;
 	}
@@ -1806,8 +1806,8 @@ static void dump_marks(void)
 		return;
 
 	if (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) {
-		failure |= error("Unable to write marks file %s: %s",
-			export_marks_file, strerror(errno));
+		failure |= error_errno("Unable to write marks file %s",
+				       export_marks_file);
 		return;
 	}
 
@@ -1822,8 +1822,8 @@ static void dump_marks(void)
 
 	dump_marks_helper(f, 0, marks);
 	if (commit_lock_file(&mark_lock)) {
-		failure |= error("Unable to write file %s: %s",
-			export_marks_file, strerror(errno));
+		failure |= error_errno("Unable to write file %s",
+				       export_marks_file);
 		return;
 	}
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 26/41] gpg-interface.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (24 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 25/41] fast-import.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 27/41] grep.c: " Nguyễn Thái Ngọc Duy
                       ` (14 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 gpg-interface.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/gpg-interface.c b/gpg-interface.c
index 2259938..c4b1e8c 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -219,11 +219,9 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
 	args_gpg[0] = gpg_program;
 	fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXXXXXX");
 	if (fd < 0)
-		return error(_("could not create temporary file '%s': %s"),
-			     path, strerror(errno));
+		return error_errno(_("could not create temporary file '%s'"), path);
 	if (write_in_full(fd, signature, signature_size) < 0)
-		return error(_("failed writing detached signature to '%s': %s"),
-			     path, strerror(errno));
+		return error_errno(_("failed writing detached signature to '%s'"), path);
 	close(fd);
 
 	gpg.argv = args_gpg;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 27/41] grep.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (25 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 26/41] gpg-interface.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 28/41] http.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                       ` (13 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

While at there, improve the error message a bit (what operation failed?)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 grep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grep.c b/grep.c
index 528b652..ec6f7ff 100644
--- a/grep.c
+++ b/grep.c
@@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)
 	if (lstat(filename, &st) < 0) {
 	err_ret:
 		if (errno != ENOENT)
-			error(_("'%s': %s"), filename, strerror(errno));
+			error_errno(_("failed to stat '%s'"), filename);
 		return -1;
 	}
 	if (!S_ISREG(st.st_mode))
@@ -1743,7 +1743,7 @@ static int grep_source_load_file(struct grep_source *gs)
 		goto err_ret;
 	data = xmallocz(size);
 	if (st.st_size != read_in_full(i, data, size)) {
-		error(_("'%s': short read %s"), filename, strerror(errno));
+		error_errno(_("'%s': short read"), filename);
 		close(i);
 		free(data);
 		return -1;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 28/41] http.c: use error_errno() and warning_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (26 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 27/41] grep.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 29/41] ident.c: use warning_errno() Nguyễn Thái Ngọc Duy
                       ` (12 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 http.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/http.c b/http.c
index 4304b80..7565c93 100644
--- a/http.c
+++ b/http.c
@@ -446,8 +446,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)
 
 	rc = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&ka, len);
 	if (rc < 0)
-		warning("unable to set SO_KEEPALIVE on socket %s",
-			strerror(errno));
+		warning_errno("unable to set SO_KEEPALIVE on socket");
 
 	return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */
 }
@@ -1894,8 +1893,7 @@ struct http_object_request *new_http_object_request(const char *base_url,
 	}
 
 	if (freq->localfile < 0) {
-		error("Couldn't create temporary file %s: %s",
-		      freq->tmpfile, strerror(errno));
+		error_errno("Couldn't create temporary file %s", freq->tmpfile);
 		goto abort;
 	}
 
@@ -1940,8 +1938,8 @@ struct http_object_request *new_http_object_request(const char *base_url,
 			prev_posn = 0;
 			lseek(freq->localfile, 0, SEEK_SET);
 			if (ftruncate(freq->localfile, 0) < 0) {
-				error("Couldn't truncate temporary file %s: %s",
-					  freq->tmpfile, strerror(errno));
+				error_errno("Couldn't truncate temporary file %s",
+					    freq->tmpfile);
 				goto abort;
 			}
 		}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 29/41] ident.c: use warning_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (27 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 28/41] http.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 30/41] mailmap.c: use error_errno() Nguyễn Thái Ngọc Duy
                       ` (11 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 ident.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/ident.c b/ident.c
index 4fd82d1..139c528 100644
--- a/ident.c
+++ b/ident.c
@@ -75,14 +75,12 @@ static int add_mailname_host(struct strbuf *buf)
 	mailname = fopen("/etc/mailname", "r");
 	if (!mailname) {
 		if (errno != ENOENT)
-			warning("cannot open /etc/mailname: %s",
-				strerror(errno));
+			warning_errno("cannot open /etc/mailname");
 		return -1;
 	}
 	if (strbuf_getline(&mailnamebuf, mailname) == EOF) {
 		if (ferror(mailname))
-			warning("cannot read /etc/mailname: %s",
-				strerror(errno));
+			warning_errno("cannot read /etc/mailname");
 		strbuf_release(&mailnamebuf);
 		fclose(mailname);
 		return -1;
@@ -125,7 +123,7 @@ static void add_domainname(struct strbuf *out, int *is_bogus)
 	char buf[1024];
 
 	if (gethostname(buf, sizeof(buf))) {
-		warning("cannot get host name: %s", strerror(errno));
+		warning_errno("cannot get host name");
 		strbuf_addstr(out, "(none)");
 		*is_bogus = 1;
 		return;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 30/41] mailmap.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (28 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 29/41] ident.c: use warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 31/41] reachable.c: " Nguyễn Thái Ngọc Duy
                       ` (10 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 mailmap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mailmap.c b/mailmap.c
index 9726237..b5c521f 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -189,8 +189,7 @@ static int read_mailmap_file(struct string_list *map, const char *filename,
 	if (!f) {
 		if (errno == ENOENT)
 			return 0;
-		return error("unable to open mailmap at %s: %s",
-			     filename, strerror(errno));
+		return error_errno("unable to open mailmap at %s", filename);
 	}
 
 	while (fgets(buffer, sizeof(buffer), f) != NULL)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 31/41] reachable.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (29 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 30/41] mailmap.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 32/41] rerere.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
                       ` (9 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 reachable.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/reachable.c b/reachable.c
index ed35201..d0199ca 100644
--- a/reachable.c
+++ b/reachable.c
@@ -119,8 +119,7 @@ static int add_recent_loose(const unsigned char *sha1,
 		 */
 		if (errno == ENOENT)
 			return 0;
-		return error("unable to stat %s: %s",
-			     sha1_to_hex(sha1), strerror(errno));
+		return error_errno("unable to stat %s", sha1_to_hex(sha1));
 	}
 
 	add_recent_object(sha1, st.st_mtime, data);
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 32/41] rerere.c: use error_errno() and warning_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (30 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 31/41] reachable.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 33/41] run-command.c: use error_errno() Nguyễn Thái Ngọc Duy
                       ` (8 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 rerere.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/rerere.c b/rerere.c
index c8b9f40..1810c04 100644
--- a/rerere.c
+++ b/rerere.c
@@ -501,8 +501,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
 		error("There were errors while writing %s (%s)",
 		      path, strerror(io.io.wrerror));
 	if (io.io.output && fclose(io.io.output))
-		io.io.wrerror = error("Failed to flush %s: %s",
-				      path, strerror(errno));
+		io.io.wrerror = error_errno("Failed to flush %s", path);
 
 	if (hunk_no < 0) {
 		if (output)
@@ -684,20 +683,17 @@ static int merge(const struct rerere_id *id, const char *path)
 	 * Mark that "postimage" was used to help gc.
 	 */
 	if (utime(rerere_path(id, "postimage"), NULL) < 0)
-		warning("failed utime() on %s: %s",
-			rerere_path(id, "postimage"),
-			strerror(errno));
+		warning_errno("failed utime() on %s",
+			      rerere_path(id, "postimage"));
 
 	/* Update "path" with the resolution */
 	f = fopen(path, "w");
 	if (!f)
-		return error("Could not open %s: %s", path,
-			     strerror(errno));
+		return error_errno("Could not open %s", path);
 	if (fwrite(result.ptr, result.size, 1, f) != 1)
-		error("Could not write %s: %s", path, strerror(errno));
+		error_errno("Could not write %s", path);
 	if (fclose(f))
-		return error("Writing %s failed: %s", path,
-			     strerror(errno));
+		return error_errno("Writing %s failed", path);
 
 out:
 	free(cur.ptr);
@@ -1071,7 +1067,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
 	if (unlink(filename))
 		return (errno == ENOENT
 			? error("no remembered resolution for %s", path)
-			: error("cannot unlink %s: %s", filename, strerror(errno)));
+			: error_errno("cannot unlink %s", filename));
 
 	/*
 	 * Update the preimage so that the user can resolve the
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 33/41] run-command.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (31 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 32/41] rerere.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 34/41] sequencer.c: " Nguyễn Thái Ngọc Duy
                       ` (7 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 run-command.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/run-command.c b/run-command.c
index e4593cd..842c8d1 100644
--- a/run-command.c
+++ b/run-command.c
@@ -233,7 +233,7 @@ static int wait_or_whine(pid_t pid, const char *argv0, int in_signal)
 
 	if (waiting < 0) {
 		failed_errno = errno;
-		error("waitpid for %s failed: %s", argv0, strerror(errno));
+		error_errno("waitpid for %s failed", argv0);
 	} else if (waiting != pid) {
 		error("waitpid is confused (%s)", argv0);
 	} else if (WIFSIGNALED(status)) {
@@ -420,8 +420,7 @@ fail_pipe:
 		}
 	}
 	if (cmd->pid < 0)
-		error("cannot fork() for %s: %s", cmd->argv[0],
-			strerror(errno));
+		error_errno("cannot fork() for %s", cmd->argv[0]);
 	else if (cmd->clean_on_exit)
 		mark_child_for_cleanup(cmd->pid);
 
@@ -482,7 +481,7 @@ fail_pipe:
 			cmd->dir, fhin, fhout, fherr);
 	failed_errno = errno;
 	if (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))
-		error("cannot spawn %s: %s", cmd->argv[0], strerror(errno));
+		error_errno("cannot spawn %s", cmd->argv[0]);
 	if (cmd->clean_on_exit && cmd->pid >= 0)
 		mark_child_for_cleanup(cmd->pid);
 
@@ -703,7 +702,7 @@ int start_async(struct async *async)
 		if (pipe(fdin) < 0) {
 			if (async->out > 0)
 				close(async->out);
-			return error("cannot create pipe: %s", strerror(errno));
+			return error_errno("cannot create pipe");
 		}
 		async->in = fdin[1];
 	}
@@ -715,7 +714,7 @@ int start_async(struct async *async)
 				close_pair(fdin);
 			else if (async->in)
 				close(async->in);
-			return error("cannot create pipe: %s", strerror(errno));
+			return error_errno("cannot create pipe");
 		}
 		async->out = fdout[0];
 	}
@@ -740,7 +739,7 @@ int start_async(struct async *async)
 
 	async->pid = fork();
 	if (async->pid < 0) {
-		error("fork (async) failed: %s", strerror(errno));
+		error_errno("fork (async) failed");
 		goto error;
 	}
 	if (!async->pid) {
@@ -787,7 +786,7 @@ int start_async(struct async *async)
 	{
 		int err = pthread_create(&async->tid, NULL, run_thread, async);
 		if (err) {
-			error("cannot create thread: %s", strerror(err));
+			error_errno("cannot create thread");
 			goto error;
 		}
 	}
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 34/41] sequencer.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (32 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 33/41] run-command.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 35/41] server-info.c: " Nguyễn Thái Ngọc Duy
                       ` (6 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 sequencer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index e66f2fe..4687ad4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -875,8 +875,7 @@ static int sequencer_rollback(struct replay_opts *opts)
 		return rollback_single_pick();
 	}
 	if (!f)
-		return error(_("cannot open %s: %s"), git_path_head_file(),
-						strerror(errno));
+		return error_errno(_("cannot open %s"), git_path_head_file());
 	if (strbuf_getline_lf(&buf, f)) {
 		error(_("cannot read %s: %s"), git_path_head_file(),
 		      ferror(f) ?  strerror(errno) : _("unexpected end of file"));
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 35/41] server-info.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (33 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 34/41] sequencer.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 36/41] sha1_file.c: use {error,die,warning}_errno() Nguyễn Thái Ngọc Duy
                       ` (5 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 server-info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server-info.c b/server-info.c
index 5a86e29..75dd677 100644
--- a/server-info.c
+++ b/server-info.c
@@ -36,7 +36,7 @@ static int update_info_file(char *path, int (*generate)(FILE *))
 
 out:
 	if (ret) {
-		error("unable to update %s: %s", path, strerror(errno));
+		error_errno("unable to update %s", path);
 		if (fp)
 			fclose(fp);
 		else if (fd >= 0)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 36/41] sha1_file.c: use {error,die,warning}_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (34 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 35/41] server-info.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 37/41] transport-helper.c: use error_errno() Nguyễn Thái Ngọc Duy
                       ` (4 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 sha1_file.c | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index d0f2aa0..a7f45b3 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1107,9 +1107,8 @@ unsigned char *use_pack(struct packed_git *p,
 				PROT_READ, MAP_PRIVATE,
 				p->pack_fd, win->offset);
 			if (win->base == MAP_FAILED)
-				die("packfile %s cannot be mapped: %s",
-					p->pack_name,
-					strerror(errno));
+				die_errno("packfile %s cannot be mapped",
+					  p->pack_name);
 			if (!win->offset && win->len == p->pack_size
 				&& !p->do_not_close)
 				close_pack_fd(p);
@@ -1279,8 +1278,8 @@ static void prepare_packed_git_one(char *objdir, int local)
 	dir = opendir(path.buf);
 	if (!dir) {
 		if (errno != ENOENT)
-			error("unable to open object pack directory: %s: %s",
-			      path.buf, strerror(errno));
+			error_errno("unable to open object pack directory: %s",
+				    path.buf);
 		strbuf_release(&path);
 		return;
 	}
@@ -2984,7 +2983,7 @@ int finalize_object_file(const char *tmpfile, const char *filename)
 	unlink_or_warn(tmpfile);
 	if (ret) {
 		if (ret != EEXIST) {
-			return error("unable to write sha1 filename %s: %s", filename, strerror(ret));
+			return error_errno("unable to write sha1 filename %s", filename);
 		}
 		/* FIXME!!! Collision check here ? */
 	}
@@ -2998,7 +2997,7 @@ out:
 static int write_buffer(int fd, const void *buf, size_t len)
 {
 	if (write_in_full(fd, buf, len) < 0)
-		return error("file write error (%s)", strerror(errno));
+		return error_errno("file write error");
 	return 0;
 }
 
@@ -3081,7 +3080,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
 		if (errno == EACCES)
 			return error("insufficient permission for adding an object to repository database %s", get_object_directory());
 		else
-			return error("unable to create temporary file: %s", strerror(errno));
+			return error_errno("unable to create temporary file");
 	}
 
 	/* Set it up */
@@ -3126,8 +3125,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
 		utb.actime = mtime;
 		utb.modtime = mtime;
 		if (utime(tmp_file.buf, &utb) < 0)
-			warning("failed utime() on %s: %s",
-				tmp_file.buf, strerror(errno));
+			warning_errno("failed utime() on %s", tmp_file.buf);
 	}
 
 	return finalize_object_file(tmp_file.buf, filename);
@@ -3360,7 +3358,7 @@ static int index_core(unsigned char *sha1, int fd, size_t size,
 		if (size == read_in_full(fd, buf, size))
 			ret = index_mem(sha1, buf, size, type, path, flags);
 		else
-			ret = error("short read %s", strerror(errno));
+			ret = error_errno("short read");
 		free(buf);
 	} else {
 		void *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
@@ -3425,18 +3423,14 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned
 	case S_IFREG:
 		fd = open(path, O_RDONLY);
 		if (fd < 0)
-			return error("open(\"%s\"): %s", path,
-				     strerror(errno));
+			return error_errno("open(\"%s\")", path);
 		if (index_fd(sha1, fd, st, OBJ_BLOB, path, flags) < 0)
 			return error("%s: failed to insert into database",
 				     path);
 		break;
 	case S_IFLNK:
-		if (strbuf_readlink(&sb, path, st->st_size)) {
-			char *errstr = strerror(errno);
-			return error("readlink(\"%s\"): %s", path,
-			             errstr);
-		}
+		if (strbuf_readlink(&sb, path, st->st_size))
+			return error_errno("readlink(\"%s\")", path);
 		if (!(flags & HASH_WRITE_OBJECT))
 			hash_sha1_file(sb.buf, sb.len, blob_type, sha1);
 		else if (write_sha1_file(sb.buf, sb.len, blob_type, sha1))
@@ -3492,7 +3486,7 @@ static int for_each_file_in_obj_subdir(int subdir_nr,
 	if (!dir) {
 		if (errno == ENOENT)
 			return 0;
-		return error("unable to open %s: %s", path->buf, strerror(errno));
+		return error_errno("unable to open %s", path->buf);
 	}
 
 	while ((de = readdir(dir))) {
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 37/41] transport-helper.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (35 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 36/41] sha1_file.c: use {error,die,warning}_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 38/41] unpack-trees.c: " Nguyễn Thái Ngọc Duy
                       ` (3 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 transport-helper.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index b934183..f09fadc 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1166,7 +1166,7 @@ static int udt_do_read(struct unidirectional_transfer *t)
 	bytes = read(t->src, t->buf + t->bufuse, BUFFERSIZE - t->bufuse);
 	if (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN &&
 		errno != EINTR) {
-		error("read(%s) failed: %s", t->src_name, strerror(errno));
+		error_errno("read(%s) failed", t->src_name);
 		return -1;
 	} else if (bytes == 0) {
 		transfer_debug("%s EOF (with %i bytes in buffer)",
@@ -1193,7 +1193,7 @@ static int udt_do_write(struct unidirectional_transfer *t)
 	transfer_debug("%s is writable", t->dest_name);
 	bytes = xwrite(t->dest, t->buf, t->bufuse);
 	if (bytes < 0 && errno != EWOULDBLOCK) {
-		error("write(%s) failed: %s", t->dest_name, strerror(errno));
+		error_errno("write(%s) failed", t->dest_name);
 		return -1;
 	} else if (bytes > 0) {
 		t->bufuse -= bytes;
@@ -1306,7 +1306,7 @@ static int tloop_join(pid_t pid, const char *name)
 {
 	int tret;
 	if (waitpid(pid, &tret, 0) < 0) {
-		error("%s process failed to wait: %s", name, strerror(errno));
+		error_errno("%s process failed to wait", name);
 		return 1;
 	}
 	if (!WIFEXITED(tret) || WEXITSTATUS(tret)) {
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 38/41] unpack-trees.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (36 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 37/41] transport-helper.c: use error_errno() Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:47     ` [PATCH v3 39/41] upload-pack.c: " Nguyễn Thái Ngọc Duy
                       ` (2 subsequent siblings)
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 unpack-trees.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index 9f55cc2..bb0d142 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1499,8 +1499,7 @@ static int verify_absent_1(const struct cache_entry *ce,
 
 		path = xmemdupz(ce->name, len);
 		if (lstat(path, &st))
-			ret = error("cannot stat '%s': %s", path,
-					strerror(errno));
+			ret = error_errno("cannot stat '%s'", path);
 		else
 			ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,
 						 &st, error_type, o);
@@ -1508,8 +1507,7 @@ static int verify_absent_1(const struct cache_entry *ce,
 		return ret;
 	} else if (lstat(ce->name, &st)) {
 		if (errno != ENOENT)
-			return error("cannot stat '%s': %s", ce->name,
-				     strerror(errno));
+			return error_errno("cannot stat '%s'", ce->name);
 		return 0;
 	} else {
 		return check_ok_to_remove(ce->name, ce_namelen(ce),
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 39/41] upload-pack.c: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (37 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 38/41] unpack-trees.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:47     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:48     ` [PATCH v3 40/41] vcs-svn: " Nguyễn Thái Ngọc Duy
  2016-05-08  9:48     ` [PATCH v3 41/41] wrapper.c: use warning_errno() Nguyễn Thái Ngọc Duy
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:47 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 upload-pack.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/upload-pack.c b/upload-pack.c
index dc802a0..f19444d 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -174,8 +174,7 @@ static void create_pack_file(void)
 
 		if (ret < 0) {
 			if (errno != EINTR) {
-				error("poll failed, resuming: %s",
-				      strerror(errno));
+				error_errno("poll failed, resuming");
 				sleep(1);
 			}
 			continue;
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 40/41] vcs-svn: use error_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (38 preceding siblings ...)
  2016-05-08  9:47     ` [PATCH v3 39/41] upload-pack.c: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:48     ` Nguyễn Thái Ngọc Duy
  2016-05-08  9:48     ` [PATCH v3 41/41] wrapper.c: use warning_errno() Nguyễn Thái Ngọc Duy
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:48 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 vcs-svn/line_buffer.c    | 4 ++--
 vcs-svn/sliding_window.c | 2 +-
 vcs-svn/svndiff.c        | 4 ++--
 vcs-svn/svndump.c        | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/vcs-svn/line_buffer.c b/vcs-svn/line_buffer.c
index 57cc1ce..e416caf 100644
--- a/vcs-svn/line_buffer.c
+++ b/vcs-svn/line_buffer.c
@@ -53,9 +53,9 @@ long buffer_tmpfile_prepare_to_read(struct line_buffer *buf)
 {
 	long pos = ftell(buf->infile);
 	if (pos < 0)
-		return error("ftell error: %s", strerror(errno));
+		return error_errno("ftell error");
 	if (fseek(buf->infile, 0, SEEK_SET))
-		return error("seek error: %s", strerror(errno));
+		return error_errno("seek error");
 	return pos;
 }
 
diff --git a/vcs-svn/sliding_window.c b/vcs-svn/sliding_window.c
index f11d490..06d273c 100644
--- a/vcs-svn/sliding_window.c
+++ b/vcs-svn/sliding_window.c
@@ -12,7 +12,7 @@ static int input_error(struct line_buffer *file)
 {
 	if (!buffer_ferror(file))
 		return error("delta preimage ends early");
-	return error("cannot read delta preimage: %s", strerror(errno));
+	return error_errno("cannot read delta preimage");
 }
 
 static int skip_or_whine(struct line_buffer *file, off_t gap)
diff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c
index 74c97c4..75c7531 100644
--- a/vcs-svn/svndiff.c
+++ b/vcs-svn/svndiff.c
@@ -64,13 +64,13 @@ static int write_strbuf(struct strbuf *sb, FILE *out)
 {
 	if (fwrite(sb->buf, 1, sb->len, out) == sb->len)	/* Success. */
 		return 0;
-	return error("cannot write delta postimage: %s", strerror(errno));
+	return error_errno("cannot write delta postimage");
 }
 
 static int error_short_read(struct line_buffer *input)
 {
 	if (buffer_ferror(input))
-		return error("error reading delta: %s", strerror(errno));
+		return error_errno("error reading delta");
 	return error("invalid delta: unexpected end of file");
 }
 
diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c
index 31d1d83..e4b3959 100644
--- a/vcs-svn/svndump.c
+++ b/vcs-svn/svndump.c
@@ -501,7 +501,7 @@ static void init(int report_fd)
 int svndump_init(const char *filename)
 {
 	if (buffer_init(&input, filename))
-		return error("cannot open %s: %s", filename ? filename : "NULL", strerror(errno));
+		return error_errno("cannot open %s", filename ? filename : "NULL");
 	init(REPORT_FILENO);
 	return 0;
 }
@@ -509,7 +509,7 @@ int svndump_init(const char *filename)
 int svndump_init_fd(int in_fd, int back_fd)
 {
 	if(buffer_fdinit(&input, xdup(in_fd)))
-		return error("cannot open fd %d: %s", in_fd, strerror(errno));
+		return error_errno("cannot open fd %d", in_fd);
 	init(xdup(back_fd));
 	return 0;
 }
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

* [PATCH v3 41/41] wrapper.c: use warning_errno()
  2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
                       ` (39 preceding siblings ...)
  2016-05-08  9:48     ` [PATCH v3 40/41] vcs-svn: " Nguyễn Thái Ngọc Duy
@ 2016-05-08  9:48     ` Nguyễn Thái Ngọc Duy
  40 siblings, 0 replies; 145+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-05-08  9:48 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jeff King, Eric Sunshine,
	Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 wrapper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/wrapper.c b/wrapper.c
index 9afc1a0..3df2fe0 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -572,7 +572,7 @@ static int warn_if_unremovable(const char *op, const char *file, int rc)
 	if (!rc || errno == ENOENT)
 		return 0;
 	err = errno;
-	warning("unable to %s %s: %s", op, file, strerror(errno));
+	warning_errno("unable to %s %s", op, file);
 	errno = err;
 	return rc;
 }
@@ -608,7 +608,7 @@ int remove_or_warn(unsigned int mode, const char *file)
 
 void warn_on_inaccessible(const char *path)
 {
-	warning(_("unable to access '%s': %s"), path, strerror(errno));
+	warning_errno(_("unable to access '%s'"), path);
 }
 
 static int access_error_is_ok(int err, unsigned flag)
-- 
2.8.0.rc0.210.gd302cd2

^ permalink raw reply related	[flat|nested] 145+ messages in thread

end of thread, other threads:[~2016-05-08  9:52 UTC | newest]

Thread overview: 145+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-01 11:14 [PATCH 00/41] Add and use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
2016-05-01 18:23   ` Eric Sunshine
2016-05-02 18:26     ` Junio C Hamano
2016-05-03  4:45       ` Jeff King
2016-05-03  9:39         ` Duy Nguyen
2016-05-03 10:15           ` Jeff King
2016-05-01 11:14 ` [PATCH 02/41] usage.c: add warning_errno() and error_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 03/41] bisect.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 04/41] builtin/am.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 05/41] builtin/branch.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 06/41] builtin/fetch.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 07/41] builtin/help.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 08/41] builtin/mailsplit.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-01 18:31   ` Eric Sunshine
2016-05-01 11:14 ` [PATCH 09/41] builtin/merge-file.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 10/41] builtin/pack-objects.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 11/41] builtin/rm.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 12/41] builtin/update-index.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-01 18:40   ` Eric Sunshine
2016-05-02  8:47     ` Duy Nguyen
2016-05-01 11:14 ` [PATCH 13/41] builtin/upload-archive.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 14/41] builtin/worktree.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 15/41] check-racy.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 16/41] combine-diff.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 17/41] compat/win32/syslog.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-01 18:40   ` Eric Sunshine
2016-05-01 11:14 ` [PATCH 18/41] config.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 19/41] connected.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 20/41] copy.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 21/41] credential-cache--daemon.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 22/41] diff-no-index.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 23/41] editor.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 24/41] entry.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 25/41] fast-import.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 26/41] gpg-interface.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 27/41] grep.c: " Nguyễn Thái Ngọc Duy
2016-05-01 18:46   ` Eric Sunshine
2016-05-01 11:14 ` [PATCH 28/41] http.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 29/41] ident.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 30/41] mailmap.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 31/41] reachable.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 32/41] rerere.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 33/41] run-command.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 34/41] sequencer.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 35/41] server-info.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 36/41] sha1_file.c: use {error,die,warning}_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 37/41] transport-helper.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 38/41] unpack-trees.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 39/41] upload-pack.c: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 40/41] vcs-svn: " Nguyễn Thái Ngọc Duy
2016-05-01 11:14 ` [PATCH 41/41] wrapper.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-01 11:21 ` [PATCH 00/41] Add and use error_errno() and warning_errno() Duy Nguyen
2016-05-03 12:03 ` [PATCH v2 " Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 02/41] usage.c: add warning_errno() and error_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 03/41] bisect.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 04/41] builtin/am.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 05/41] builtin/branch.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 06/41] builtin/fetch.c: " Nguyễn Thái Ngọc Duy
2016-05-03 19:22     ` Junio C Hamano
2016-05-03 12:03   ` [PATCH v2 07/41] builtin/help.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 08/41] builtin/mailsplit.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-03 19:48     ` Junio C Hamano
2016-05-03 12:03   ` [PATCH v2 09/41] builtin/merge-file.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 10/41] builtin/pack-objects.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-03 19:54     ` Junio C Hamano
2016-05-03 12:03   ` [PATCH v2 11/41] builtin/rm.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-03 19:58     ` Junio C Hamano
2016-05-03 12:03   ` [PATCH v2 12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error Nguyễn Thái Ngọc Duy
2016-05-03 16:52     ` Eric Sunshine
2016-05-03 12:03   ` [PATCH v2 13/41] builtin/upload-archive.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 14/41] builtin/worktree.c: " Nguyễn Thái Ngọc Duy
2016-05-03 20:02     ` Junio C Hamano
2016-05-03 12:03   ` [PATCH v2 15/41] check-racy.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 16/41] combine-diff.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 17/41] compat/win32/syslog.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 18/41] config.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 19/41] connected.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 20/41] copy.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 21/41] credential-cache--daemon.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 22/41] diff-no-index.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 23/41] editor.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 24/41] entry.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 25/41] fast-import.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:03   ` [PATCH v2 26/41] gpg-interface.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 27/41] grep.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 28/41] http.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 29/41] ident.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 30/41] mailmap.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 31/41] reachable.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 32/41] rerere.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 33/41] run-command.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 34/41] sequencer.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 35/41] server-info.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 36/41] sha1_file.c: use {error,die,warning}_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 37/41] transport-helper.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 38/41] unpack-trees.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 39/41] upload-pack.c: " Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 40/41] vcs-svn: " Nguyễn Thái Ngọc Duy
2016-05-03 12:04   ` [PATCH v2 41/41] wrapper.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-03 16:55   ` [PATCH v2 00/41] Add and use error_errno() and warning_errno() Eric Sunshine
2016-05-03 20:11   ` Junio C Hamano
2016-05-08  9:47   ` [PATCH v3 " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 01/41] usage.c: move format processing out of die_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 02/41] usage.c: add warning_errno() and error_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 03/41] bisect.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 04/41] builtin/am.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 05/41] builtin/branch.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 06/41] builtin/fetch.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 07/41] builtin/help.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 08/41] builtin/mailsplit.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 09/41] builtin/merge-file.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 10/41] builtin/pack-objects.c: use die_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 11/41] builtin/rm.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 12/41] builtin/update-index.c: prefer "err" to "errno" in process_lstat_error Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 13/41] builtin/upload-archive.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 14/41] builtin/worktree.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 15/41] check-racy.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 16/41] combine-diff.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 17/41] compat/win32/syslog.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 18/41] config.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 19/41] connected.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 20/41] copy.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 21/41] credential-cache--daemon.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 22/41] diff-no-index.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 23/41] editor.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 24/41] entry.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 25/41] fast-import.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 26/41] gpg-interface.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 27/41] grep.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 28/41] http.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 29/41] ident.c: use warning_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 30/41] mailmap.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 31/41] reachable.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 32/41] rerere.c: use error_errno() and warning_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 33/41] run-command.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 34/41] sequencer.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 35/41] server-info.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 36/41] sha1_file.c: use {error,die,warning}_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 37/41] transport-helper.c: use error_errno() Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 38/41] unpack-trees.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:47     ` [PATCH v3 39/41] upload-pack.c: " Nguyễn Thái Ngọc Duy
2016-05-08  9:48     ` [PATCH v3 40/41] vcs-svn: " Nguyễn Thái Ngọc Duy
2016-05-08  9:48     ` [PATCH v3 41/41] wrapper.c: use warning_errno() Nguyễn Thái Ngọc Duy

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).