{"thread":{"id":"42194","subject":"[PATCH 00/41] Add and use error_errno() and warning_errno()","startedAt":"2016-05-01T11:14:16Z","lastAt":"2016-05-08T09:48:01Z","messageCount":145,"participants":["Nguyễn Thái Ngọc Duy","Duy Nguyen","Eric Sunshine","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":41},"messages":[{"id":"285072","messageId":"1462101297-8610-1-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":null,"subject":"[PATCH 00/41] Add and use error_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:16Z","receivedAt":"2016-05-01T11:14:16Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This is a spinoff from my worktree-move topic. This series adds\ndie_errno() companions, error_errno() and warning_errno(), and use them\nwhere applicable to reduce the amount of typing (in future). Changes\nare split by file (which explains the huge number of patches). I leave\nbuiltin/apply.c and refs/files-backend.c untouched because they are\ncurrently hot zones.\n\nNguyễn Thái Ngọc Duy (41):\n  usage.c: move format processing out of die_errno()\n  usage.c: add warning_errno() and error_errno()\n  bisect.c: use die_errno() and warning_errno()\n  builtin/am.c: use error_errno()\n  builtin/branch.c: use error_errno()\n  builtin/fetch.c: use error_errno()\n  builtin/help.c: use warning_errno()\n  builtin/mailsplit.c: use error_errno()\n  builtin/merge-file.c: use error_errno()\n  builtin/pack-objects.c: use die_errno() and warning_errno()\n  builtin/rm.c: use warning_errno()\n  builtin/update-index.c: use error_errno()\n  builtin/upload-archive.c: use error_errno()\n  builtin/worktree.c: use error_errno()\n  check-racy.c: use error_errno()\n  combine-diff.c: use error_errno()\n  compat/win32/syslog.c: use warning_errno()\n  config.c: use error_errno()\n  connected.c: use error_errno()\n  copy.c: use error_errno()\n  credential-cache--daemon.c: use warning_errno()\n  diff-no-index.c: use error_errno()\n  editor.c: use error_errno()\n  entry.c: use error_errno()\n  fast-import.c: use error_errno()\n  gpg-interface.c: use error_errno()\n  grep.c: use error_errno()\n  http.c: use error_errno() and warning_errno()\n  ident.c: use warning_errno()\n  mailmap.c: use error_errno()\n  reachable.c: use error_errno()\n  rerere.c: use error_errno() and warning_errno()\n  run-command.c: use error_errno()\n  sequencer.c: use error_errno()\n  server-info.c: use error_errno()\n  sha1_file.c: use {error,die,warning}_errno()\n  transport-helper.c: use error_errno()\n  unpack-trees.c: use error_errno()\n  upload-pack.c: use error_errno()\n  vcs-svn: use error_errno()\n  wrapper.c: use warning_errno()\n\n bisect.c                   |  7 +++----\n builtin/am.c               | 11 +++++------\n builtin/branch.c           |  3 +--\n builtin/fetch.c            |  4 ++--\n builtin/help.c             |  8 ++++----\n builtin/mailsplit.c        | 10 +++++-----\n builtin/merge-file.c       | 10 +++++-----\n builtin/pack-objects.c     |  8 +++-----\n builtin/rm.c               |  2 +-\n builtin/update-index.c     |  8 ++++----\n builtin/upload-archive.c   |  3 +--\n builtin/worktree.c         |  2 +-\n check-racy.c               |  2 +-\n combine-diff.c             |  3 +--\n compat/win32/syslog.c      |  6 +++---\n config.c                   | 22 +++++++++-------------\n connected.c                |  9 +++------\n copy.c                     |  6 +++---\n credential-cache--daemon.c |  4 ++--\n diff-no-index.c            |  3 +--\n editor.c                   |  3 +--\n entry.c                    | 10 ++++------\n fast-import.c              | 10 +++++-----\n git-compat-util.h          |  2 ++\n gpg-interface.c            |  6 ++----\n grep.c                     |  4 ++--\n http.c                     | 10 ++++------\n ident.c                    |  8 +++-----\n mailmap.c                  |  3 +--\n reachable.c                |  3 +--\n rerere.c                   | 18 +++++++-----------\n run-command.c              | 15 +++++++--------\n sequencer.c                |  3 +--\n server-info.c              |  2 +-\n sha1_file.c                | 32 +++++++++++++-------------------\n transport-helper.c         |  6 +++---\n unpack-trees.c             |  6 ++----\n upload-pack.c              |  3 +--\n usage.c                    | 44 ++++++++++++++++++++++++++++++++++----------\n vcs-svn/line_buffer.c      |  4 ++--\n vcs-svn/sliding_window.c   |  2 +-\n vcs-svn/svndiff.c          |  4 ++--\n vcs-svn/svndump.c          |  4 ++--\n wrapper.c                  |  4 ++--\n 44 files changed, 161 insertions(+), 176 deletions(-)\n\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285073","messageId":"1462101297-8610-2-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 01/41] usage.c: move format processing out of die_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:17Z","receivedAt":"2016-05-01T11:14:17Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"fmt_with_err() will be shared with the coming error_errno() and\nwarning_errno().\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n usage.c | 25 +++++++++++++++----------\n 1 file changed, 15 insertions(+), 10 deletions(-)\n\ndiff --git a/usage.c b/usage.c\nindex 82ff131..0dba0c5 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -109,19 +109,12 @@ void NORETURN die(const char *err, ...)\n \tva_end(params);\n }\n \n-void NORETURN die_errno(const char *fmt, ...)\n+static const char *fmt_with_err(const char *fmt)\n {\n-\tva_list params;\n-\tchar fmt_with_err[1024];\n+\tstatic char fmt_with_err[1024];\n \tchar str_error[256], *err;\n \tint i, j;\n \n-\tif (die_is_recursing()) {\n-\t\tfputs(\"fatal: recursion detected in die_errno handler\\n\",\n-\t\t\tstderr);\n-\t\texit(128);\n-\t}\n-\n \terr = strerror(errno);\n \tfor (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {\n \t\tif ((str_error[j++] = err[i++]) != '%')\n@@ -137,9 +130,21 @@ void NORETURN die_errno(const char *fmt, ...)\n \t}\n \tstr_error[j] = 0;\n \tsnprintf(fmt_with_err, sizeof(fmt_with_err), \"%s: %s\", fmt, str_error);\n+\treturn fmt_with_err;\n+}\n+\n+void NORETURN die_errno(const char *fmt, ...)\n+{\n+\tva_list params;\n+\n+\tif (die_is_recursing()) {\n+\t\tfputs(\"fatal: recursion detected in die_errno handler\\n\",\n+\t\t\tstderr);\n+\t\texit(128);\n+\t}\n \n \tva_start(params, fmt);\n-\tdie_routine(fmt_with_err, params);\n+\tdie_routine(fmt_with_err(fmt), params);\n \tva_end(params);\n }\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285074","messageId":"1462101297-8610-3-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 02/41] usage.c: add warning_errno() and error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:18Z","receivedAt":"2016-05-01T11:14:18Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Similar to die_errno(), these functions will append strerror()\nautomatically.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n git-compat-util.h |  2 ++\n usage.c           | 19 +++++++++++++++++++\n 2 files changed, 21 insertions(+)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 1f8b5f3..49d4029 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -409,7 +409,9 @@ extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf,\n extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));\n+extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));\n+extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));\n \n #ifndef NO_OPENSSL\n #ifdef APPLE_COMMON_CRYPTO\ndiff --git a/usage.c b/usage.c\nindex 0dba0c5..af1b7d1 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -148,6 +148,16 @@ void NORETURN die_errno(const char *fmt, ...)\n \tva_end(params);\n }\n \n+int error_errno(const char *fmt, ...)\n+{\n+\tva_list params;\n+\n+\tva_start(params, fmt);\n+\terror_routine(fmt_with_err(fmt), params);\n+\tva_end(params);\n+\treturn -1;\n+}\n+\n #undef error\n int error(const char *err, ...)\n {\n@@ -159,6 +169,15 @@ int error(const char *err, ...)\n \treturn -1;\n }\n \n+void warning_errno(const char *warn, ...)\n+{\n+\tva_list params;\n+\n+\tva_start(params, warn);\n+\twarn_routine(fmt_with_err(warn), params);\n+\tva_end(params);\n+}\n+\n void warning(const char *warn, ...)\n {\n \tva_list params;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285075","messageId":"1462101297-8610-4-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 03/41] bisect.c: use die_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:19Z","receivedAt":"2016-05-01T11:14:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n bisect.c | 7 +++----\n 1 file changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 7996c29..6d93edb 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -860,8 +860,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)\n \t/* Create file BISECT_ANCESTORS_OK. */\n \tfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);\n \tif (fd < 0)\n-\t\twarning(\"could not create file '%s': %s\",\n-\t\t\tfilename, strerror(errno));\n+\t\twarning_errno(\"could not create file '%s'\",\n+\t\t\t      filename);\n \telse\n \t\tclose(fd);\n  done:\n@@ -910,8 +910,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)\n \t\t\t*read_good = \"good\";\n \t\t\treturn;\n \t\t} else {\n-\t\t\tdie(\"could not read file '%s': %s\", filename,\n-\t\t\t\tstrerror(errno));\n+\t\t\tdie_errno(\"could not read file '%s'\", filename);\n \t\t}\n \t} else {\n \t\tstrbuf_getline_lf(&str, fp);\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285076","messageId":"1462101297-8610-5-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 04/41] builtin/am.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:20Z","receivedAt":"2016-05-01T11:14:20Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/am.c | 11 +++++------\n 1 file changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex d003939..3dfe70b 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -769,15 +769,15 @@ static int split_mail_conv(mail_conv_fn fn, struct am_state *state,\n \t\t\tin = fopen(*paths, \"r\");\n \n \t\tif (!in)\n-\t\t\treturn error(_(\"could not open '%s' for reading: %s\"),\n-\t\t\t\t\t*paths, strerror(errno));\n+\t\t\treturn error_errno(_(\"could not open '%s' for reading\"),\n+\t\t\t\t\t   *paths);\n \n \t\tmail = mkpath(\"%s/%0*d\", state->dir, state->prec, i + 1);\n \n \t\tout = fopen(mail, \"w\");\n \t\tif (!out)\n-\t\t\treturn error(_(\"could not open '%s' for writing: %s\"),\n-\t\t\t\t\tmail, strerror(errno));\n+\t\t\treturn error_errno(_(\"could not open '%s' for writing\"),\n+\t\t\t\t\t   mail);\n \n \t\tret = fn(out, in, keep_cr);\n \n@@ -857,8 +857,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,\n \n \tfp = fopen(*paths, \"r\");\n \tif (!fp)\n-\t\treturn error(_(\"could not open '%s' for reading: %s\"), *paths,\n-\t\t\t\tstrerror(errno));\n+\t\treturn error_errno(_(\"could not open '%s' for reading\"), *paths);\n \n \twhile (!strbuf_getline_lf(&sb, fp)) {\n \t\tif (*sb.buf == '#')\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285077","messageId":"1462101297-8610-6-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 05/41] builtin/branch.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:21Z","receivedAt":"2016-05-01T11:14:21Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/branch.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 0adba62..6f1572d 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -593,8 +593,7 @@ static int edit_branch_description(const char *branch_name)\n \t\t    branch_name, comment_line_char);\n \tif (write_file_gently(git_path(edit_description), \"%s\", buf.buf)) {\n \t\tstrbuf_release(&buf);\n-\t\treturn error(_(\"could not write branch description template: %s\"),\n-\t\t\t     strerror(errno));\n+\t\treturn error_errno(_(\"could not write branch description template\"));\n \t}\n \tstrbuf_reset(&buf);\n \tif (launch_editor(git_path(edit_description), &buf, NULL)) {\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285078","messageId":"1462101297-8610-7-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 06/41] builtin/fetch.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:22Z","receivedAt":"2016-05-01T11:14:22Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/fetch.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex f8455bd..1582ca7 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -607,7 +607,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \n \tfp = fopen(filename, \"a\");\n \tif (!fp)\n-\t\treturn error(_(\"cannot open %s: %s\\n\"), filename, strerror(errno));\n+\t\treturn error_errno(_(\"cannot open %s\"), filename);\n \n \tif (raw_url)\n \t\turl = transport_anonymize_url(raw_url);\n@@ -848,7 +848,7 @@ static int truncate_fetch_head(void)\n \tFILE *fp = fopen_for_writing(filename);\n \n \tif (!fp)\n-\t\treturn error(_(\"cannot open %s: %s\\n\"), filename, strerror(errno));\n+\t\treturn error_errno(_(\"cannot open %s\"), filename);\n \tfclose(fp);\n \treturn 0;\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285080","messageId":"1462101297-8610-8-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 07/41] builtin/help.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:23Z","receivedAt":"2016-05-01T11:14:23Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/help.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 3c55ce4..8848013 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -127,7 +127,7 @@ static void exec_woman_emacs(const char *path, const char *page)\n \t\t\tpath = \"emacsclient\";\n \t\tstrbuf_addf(&man_page, \"(woman \\\"%s\\\")\", page);\n \t\texeclp(path, \"emacsclient\", \"-e\", man_page.buf, (char *)NULL);\n-\t\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n+\t\twarning_errno(_(\"failed to exec '%s'\"), path);\n \t}\n }\n \n@@ -148,7 +148,7 @@ static void exec_man_konqueror(const char *path, const char *page)\n \t\t\tpath = \"kfmclient\";\n \t\tstrbuf_addf(&man_page, \"man:%s(1)\", page);\n \t\texeclp(path, filename, \"newTab\", man_page.buf, (char *)NULL);\n-\t\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n+\t\twarning_errno(_(\"failed to exec '%s'\"), path);\n \t}\n }\n \n@@ -157,7 +157,7 @@ static void exec_man_man(const char *path, const char *page)\n \tif (!path)\n \t\tpath = \"man\";\n \texeclp(path, \"man\", page, (char *)NULL);\n-\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n+\twarning_errno(_(\"failed to exec '%s'\"), path);\n }\n \n static void exec_man_cmd(const char *cmd, const char *page)\n@@ -165,7 +165,7 @@ static void exec_man_cmd(const char *cmd, const char *page)\n \tstruct strbuf shell_cmd = STRBUF_INIT;\n \tstrbuf_addf(&shell_cmd, \"%s %s\", cmd, page);\n \texecl(SHELL_PATH, SHELL_PATH, \"-c\", shell_cmd.buf, (char *)NULL);\n-\twarning(_(\"failed to exec '%s': %s\"), cmd, strerror(errno));\n+\twarning(_(\"failed to exec '%s'\"), cmd);\n }\n \n static void add_man_viewer(const char *name)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285079","messageId":"1462101297-8610-9-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 08/41] builtin/mailsplit.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:24Z","receivedAt":"2016-05-01T11:14:24Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/mailsplit.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/mailsplit.c b/builtin/mailsplit.c\nindex 104277a..4859ede 100644\n--- a/builtin/mailsplit.c\n+++ b/builtin/mailsplit.c\n@@ -109,7 +109,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)\n \t\tif ((dir = opendir(name)) == NULL) {\n \t\t\tif (errno == ENOENT)\n \t\t\t\tcontinue;\n-\t\t\terror(\"cannot opendir %s (%s)\", name, strerror(errno));\n+\t\t\terror_errno(\"cannot opendir %s\", name);\n \t\t\tgoto out;\n \t\t}\n \n@@ -174,12 +174,12 @@ static int split_maildir(const char *maildir, const char *dir,\n \n \t\tf = fopen(file, \"r\");\n \t\tif (!f) {\n-\t\t\terror(\"cannot open mail %s (%s)\", file, strerror(errno));\n+\t\t\terror_errno(\"cannot open mail %s\", file);\n \t\t\tgoto out;\n \t\t}\n \n \t\tif (strbuf_getwholeline(&buf, f, '\\n')) {\n-\t\t\terror(\"cannot read mail %s (%s)\", file, strerror(errno));\n+\t\t\terror_errno(\"cannot read mail %s\", file);\n \t\t\tgoto out;\n \t\t}\n \n@@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,\n \tint file_done = 0;\n \n \tif (!f) {\n-\t\terror(\"cannot open mbox %s\", file);\n+\t\terror_errno(\"cannot open mbox %s\", file);\n \t\tgoto out;\n \t}\n \n@@ -318,7 +318,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)\n \t\t}\n \n \t\tif (stat(arg, &argstat) == -1) {\n-\t\t\terror(\"cannot stat %s (%s)\", arg, strerror(errno));\n+\t\t\terror_errno(\"cannot stat %s\", arg);\n \t\t\treturn 1;\n \t\t}\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285081","messageId":"1462101297-8610-10-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 09/41] builtin/merge-file.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:25Z","receivedAt":"2016-05-01T11:14:25Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/merge-file.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 5544705..13e22a2 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -62,8 +62,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \t\tusage_with_options(merge_file_usage, options);\n \tif (quiet) {\n \t\tif (!freopen(\"/dev/null\", \"w\", stderr))\n-\t\t\treturn error(\"failed to redirect stderr to /dev/null: \"\n-\t\t\t\t     \"%s\", strerror(errno));\n+\t\t\treturn error_errno(\"failed to redirect stderr to /dev/null\");\n \t}\n \n \tif (prefix)\n@@ -95,12 +94,13 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \t\tFILE *f = to_stdout ? stdout : fopen(fpath, \"wb\");\n \n \t\tif (!f)\n-\t\t\tret = error(\"Could not open %s for writing\", filename);\n+\t\t\tret = error_errno(\"Could not open %s for writing\",\n+\t\t\t\t\t  filename);\n \t\telse if (result.size &&\n \t\t\t fwrite(result.ptr, result.size, 1, f) != 1)\n-\t\t\tret = error(\"Could not write to %s\", filename);\n+\t\t\tret = error_errno(\"Could not write to %s\", filename);\n \t\telse if (fclose(f))\n-\t\t\tret = error(\"Could not close %s\", filename);\n+\t\t\tret = error_errno(\"Could not close %s\", filename);\n \t\tfree(result.ptr);\n \t}\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285082","messageId":"1462101297-8610-11-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 10/41] builtin/pack-objects.c: use die_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:26Z","receivedAt":"2016-05-01T11:14:26Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/pack-objects.c | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex a27de5b..e18e190 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -828,8 +828,7 @@ static void write_pack_file(void)\n \t\t\t * to preserve this property.\n \t\t\t */\n \t\t\tif (stat(pack_tmp_name, &st) < 0) {\n-\t\t\t\twarning(\"failed to stat %s: %s\",\n-\t\t\t\t\tpack_tmp_name, strerror(errno));\n+\t\t\t\twarning_errno(\"failed to stat %s\", pack_tmp_name);\n \t\t\t} else if (!last_mtime) {\n \t\t\t\tlast_mtime = st.st_mtime;\n \t\t\t} else {\n@@ -837,8 +836,7 @@ static void write_pack_file(void)\n \t\t\t\tutb.actime = st.st_atime;\n \t\t\t\tutb.modtime = --last_mtime;\n \t\t\t\tif (utime(pack_tmp_name, &utb) < 0)\n-\t\t\t\t\twarning(\"failed utime() on %s: %s\",\n-\t\t\t\t\t\tpack_tmp_name, strerror(errno));\n+\t\t\t\t\twarning_errno(\"failed utime() on %s\", pack_tmp_name);\n \t\t\t}\n \n \t\t\tstrbuf_addf(&tmpname, \"%s-\", base_name);\n@@ -2020,7 +2018,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,\n \t\tret = pthread_create(&p[i].thread, NULL,\n \t\t\t\t     threaded_find_deltas, &p[i]);\n \t\tif (ret)\n-\t\t\tdie(\"unable to create thread: %s\", strerror(ret));\n+\t\t\tdie_errno(\"unable to create thread\");\n \t\tactive_threads++;\n \t}\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285084","messageId":"1462101297-8610-12-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 11/41] builtin/rm.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:27Z","receivedAt":"2016-05-01T11:14:27Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/rm.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 8829b09..13b9639 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only)\n \n \t\tif (lstat(ce->name, &st) < 0) {\n \t\t\tif (errno != ENOENT && errno != ENOTDIR)\n-\t\t\t\twarning(\"'%s': %s\", ce->name, strerror(errno));\n+\t\t\t\twarning_errno(\"'%s'\", ce->name);\n \t\t\t/* It already vanished from the working tree */\n \t\t\tcontinue;\n \t\t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285083","messageId":"1462101297-8610-13-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 12/41] builtin/update-index.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:28Z","receivedAt":"2016-05-01T11:14:28Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\"err\" is deleted because it just causes confusion when \"errno\" is also\nused directly in process_lstat_error().\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/update-index.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 1c94ca5..0c539ed 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -251,11 +251,11 @@ static int remove_one_path(const char *path)\n  *    succeeds.\n  *  - permission error. That's never ok.\n  */\n-static int process_lstat_error(const char *path, int err)\n+static int process_lstat_error(const char *path)\n {\n-\tif (err == ENOENT || err == ENOTDIR)\n+\tif (errno == ENOENT || errno == ENOTDIR)\n \t\treturn remove_one_path(path);\n-\treturn error(\"lstat(\\\"%s\\\"): %s\", path, strerror(errno));\n+\treturn error_errno(\"lstat(\\\"%s\\\")\", path);\n }\n \n static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)\n@@ -382,7 +382,7 @@ static int process_path(const char *path)\n \t * what to do about the pathname!\n \t */\n \tif (lstat(path, &st) < 0)\n-\t\treturn process_lstat_error(path, errno);\n+\t\treturn process_lstat_error(path);\n \n \tif (S_ISDIR(st.st_mode))\n \t\treturn process_directory(path, len, &st);\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285085","messageId":"1462101297-8610-14-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 13/41] builtin/upload-archive.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:29Z","receivedAt":"2016-05-01T11:14:29Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/upload-archive.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/builtin/upload-archive.c b/builtin/upload-archive.c\nindex dbfe14f..2caedf1 100644\n--- a/builtin/upload-archive.c\n+++ b/builtin/upload-archive.c\n@@ -104,8 +104,7 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)\n \t\tpfd[1].events = POLLIN;\n \t\tif (poll(pfd, 2, -1) < 0) {\n \t\t\tif (errno != EINTR) {\n-\t\t\t\terror(\"poll failed resuming: %s\",\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(\"poll failed resuming\");\n \t\t\t\tsleep(1);\n \t\t\t}\n \t\t\tcontinue;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285086","messageId":"1462101297-8610-15-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 14/41] builtin/worktree.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:30Z","receivedAt":"2016-05-01T11:14:30Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/worktree.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex d8e3795..331ecf6 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -110,7 +110,7 @@ static void prune_worktrees(void)\n \t\tif (ret < 0 && errno == ENOTDIR)\n \t\t\tret = unlink(path.buf);\n \t\tif (ret)\n-\t\t\terror(_(\"failed to remove: %s\"), strerror(errno));\n+\t\t\terror_errno(_(\"failed to remove '%s'\"), path.buf);\n \t}\n \tclosedir(dir);\n \tif (!show_only)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285088","messageId":"1462101297-8610-16-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 15/41] check-racy.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:31Z","receivedAt":"2016-05-01T11:14:31Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n check-racy.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/check-racy.c b/check-racy.c\nindex 00d92a1..24b6542 100644\n--- a/check-racy.c\n+++ b/check-racy.c\n@@ -12,7 +12,7 @@ int main(int ac, char **av)\n \t\tstruct stat st;\n \n \t\tif (lstat(ce->name, &st)) {\n-\t\t\terror(\"lstat(%s): %s\", ce->name, strerror(errno));\n+\t\t\terror_errno(\"lstat(%s)\", ce->name);\n \t\t\tcontinue;\n \t\t}\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285087","messageId":"1462101297-8610-17-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 16/41] combine-diff.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:32Z","receivedAt":"2016-05-01T11:14:32Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n combine-diff.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 0e1d4b0..8f2313d 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1005,8 +1005,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\tstruct strbuf buf = STRBUF_INIT;\n \n \t\t\tif (strbuf_readlink(&buf, elem->path, st.st_size) < 0) {\n-\t\t\t\terror(\"readlink(%s): %s\", elem->path,\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(\"readlink(%s)\", elem->path);\n \t\t\t\treturn;\n \t\t\t}\n \t\t\tresult_size = buf.len;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285089","messageId":"1462101297-8610-18-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 17/41] compat/win32/syslog.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:33Z","receivedAt":"2016-05-01T11:14:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n compat/win32/syslog.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/compat/win32/syslog.c b/compat/win32/syslog.c\nindex b905aea..1c2ae18 100644\n--- a/compat/win32/syslog.c\n+++ b/compat/win32/syslog.c\n@@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...)\n \tva_end(ap);\n \n \tif (str_len < 0) {\n-\t\twarning(\"vsnprintf failed: '%s'\", strerror(errno));\n+\t\twarning_errno(\"vsnprintf failed:\");\n \t\treturn;\n \t}\n \n \tstr = malloc(st_add(str_len, 1));\n \tif (!str) {\n-\t\twarning(\"malloc failed: '%s'\", strerror(errno));\n+\t\twarning_errno(\"malloc failed\");\n \t\treturn;\n \t}\n \n@@ -45,7 +45,7 @@ void syslog(int priority, const char *fmt, ...)\n \twhile ((pos = strstr(str, \"%1\")) != NULL) {\n \t\tstr = realloc(str, st_add(++str_len, 1));\n \t\tif (!str) {\n-\t\t\twarning(\"realloc failed: '%s'\", strerror(errno));\n+\t\t\twarning_errno(\"realloc failed\");\n \t\t\treturn;\n \t\t}\n \t\tmemmove(pos + 2, pos + 1, strlen(pos));\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285090","messageId":"1462101297-8610-19-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 18/41] config.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:34Z","receivedAt":"2016-05-01T11:14:34Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n config.c | 22 +++++++++-------------\n 1 file changed, 9 insertions(+), 13 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex 10b5c95..80411e4 100644\n--- a/config.c\n+++ b/config.c\n@@ -2012,7 +2012,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \tlock = xcalloc(1, sizeof(struct lock_file));\n \tfd = hold_lock_file_for_update(lock, config_filename, 0);\n \tif (fd < 0) {\n-\t\terror(\"could not lock config file %s: %s\", config_filename, strerror(errno));\n+\t\terror_errno(\"could not lock config file %s\", config_filename);\n \t\tfree(store.key);\n \t\tret = CONFIG_NO_LOCK;\n \t\tgoto out_free;\n@@ -2026,8 +2026,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t\tfree(store.key);\n \n \t\tif ( ENOENT != errno ) {\n-\t\t\terror(\"opening %s: %s\", config_filename,\n-\t\t\t      strerror(errno));\n+\t\t\terror_errno(\"opening %s\", config_filename);\n \t\t\tret = CONFIG_INVALID_FILE; /* same as \"invalid config file\" */\n \t\t\tgoto out_free;\n \t\t}\n@@ -2111,8 +2110,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t\tif (contents == MAP_FAILED) {\n \t\t\tif (errno == ENODEV && S_ISDIR(st.st_mode))\n \t\t\t\terrno = EISDIR;\n-\t\t\terror(\"unable to mmap '%s': %s\",\n-\t\t\t      config_filename, strerror(errno));\n+\t\t\terror_errno(\"unable to mmap '%s'\", config_filename);\n \t\t\tret = CONFIG_INVALID_FILE;\n \t\t\tcontents = NULL;\n \t\t\tgoto out_free;\n@@ -2121,8 +2119,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t\tin_fd = -1;\n \n \t\tif (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {\n-\t\t\terror(\"chmod on %s failed: %s\",\n-\t\t\t      get_lock_file_path(lock), strerror(errno));\n+\t\t\terror_errno(\"chmod on %s failed\", get_lock_file_path(lock));\n \t\t\tret = CONFIG_NO_WRITE;\n \t\t\tgoto out_free;\n \t\t}\n@@ -2178,8 +2175,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t}\n \n \tif (commit_lock_file(lock) < 0) {\n-\t\terror(\"could not write config file %s: %s\", config_filename,\n-\t\t      strerror(errno));\n+\t\terror_errno(\"could not write config file %s\", config_filename);\n \t\tret = CONFIG_NO_WRITE;\n \t\tlock = NULL;\n \t\tgoto out_free;\n@@ -2330,8 +2326,8 @@ int git_config_rename_section_in_file(const char *config_filename,\n \tfstat(fileno(config_file), &st);\n \n \tif (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {\n-\t\tret = error(\"chmod on %s failed: %s\",\n-\t\t\t    get_lock_file_path(lock), strerror(errno));\n+\t\tret = error_errno(\"chmod on %s failed\",\n+\t\t\t\t  get_lock_file_path(lock));\n \t\tgoto out;\n \t}\n \n@@ -2385,8 +2381,8 @@ int git_config_rename_section_in_file(const char *config_filename,\n \tfclose(config_file);\n unlock_and_out:\n \tif (commit_lock_file(lock) < 0)\n-\t\tret = error(\"could not write config file %s: %s\",\n-\t\t\t    config_filename, strerror(errno));\n+\t\tret = error_errno(\"could not write config file %s\",\n+\t\t\t\t  config_filename);\n out:\n \tfree(filename_buf);\n \treturn ret;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285091","messageId":"1462101297-8610-20-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 19/41] connected.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:35Z","receivedAt":"2016-05-01T11:14:35Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n connected.c | 9 +++------\n 1 file changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/connected.c b/connected.c\nindex 299c560..bf1b12e 100644\n--- a/connected.c\n+++ b/connected.c\n@@ -86,17 +86,14 @@ static int check_everything_connected_real(sha1_iterate_fn fn,\n \t\tmemcpy(commit, sha1_to_hex(sha1), 40);\n \t\tif (write_in_full(rev_list.in, commit, 41) < 0) {\n \t\t\tif (errno != EPIPE && errno != EINVAL)\n-\t\t\t\terror(_(\"failed write to rev-list: %s\"),\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(_(\"failed write to rev-list\"));\n \t\t\terr = -1;\n \t\t\tbreak;\n \t\t}\n \t} while (!fn(cb_data, sha1));\n \n-\tif (close(rev_list.in)) {\n-\t\terror(_(\"failed to close rev-list's stdin: %s\"), strerror(errno));\n-\t\terr = -1;\n-\t}\n+\tif (close(rev_list.in))\n+\t\terr = error_errno(_(\"failed to close rev-list's stdin\"));\n \n \tsigchain_pop(SIGPIPE);\n \treturn finish_command(&rev_list) || err;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285092","messageId":"1462101297-8610-21-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 20/41] copy.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:36Z","receivedAt":"2016-05-01T11:14:36Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n copy.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/copy.c b/copy.c\nindex 574fa1f..4de6a11 100644\n--- a/copy.c\n+++ b/copy.c\n@@ -42,15 +42,15 @@ int copy_file(const char *dst, const char *src, int mode)\n \tstatus = copy_fd(fdi, fdo);\n \tswitch (status) {\n \tcase COPY_READ_ERROR:\n-\t\terror(\"copy-fd: read returned %s\", strerror(errno));\n+\t\terror_errno(\"copy-fd: read returned\");\n \t\tbreak;\n \tcase COPY_WRITE_ERROR:\n-\t\terror(\"copy-fd: write returned %s\", strerror(errno));\n+\t\terror_errno(\"copy-fd: write returned\");\n \t\tbreak;\n \t}\n \tclose(fdi);\n \tif (close(fdo) != 0)\n-\t\treturn error(\"%s: close error: %s\", dst, strerror(errno));\n+\t\treturn error_errno(\"%s: close error\", dst);\n \n \tif (!status && adjust_shared_perm(dst))\n \t\treturn -1;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285093","messageId":"1462101297-8610-22-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 21/41] credential-cache--daemon.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:37Z","receivedAt":"2016-05-01T11:14:37Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n credential-cache--daemon.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/credential-cache--daemon.c b/credential-cache--daemon.c\nindex 291c0fd..1f14d56 100644\n--- a/credential-cache--daemon.c\n+++ b/credential-cache--daemon.c\n@@ -179,12 +179,12 @@ static int serve_cache_loop(int fd)\n \n \t\tclient = accept(fd, NULL, NULL);\n \t\tif (client < 0) {\n-\t\t\twarning(\"accept failed: %s\", strerror(errno));\n+\t\t\twarning_errno(\"accept failed\");\n \t\t\treturn 1;\n \t\t}\n \t\tclient2 = dup(client);\n \t\tif (client2 < 0) {\n-\t\t\twarning(\"dup failed: %s\", strerror(errno));\n+\t\t\twarning_errno(\"dup failed\");\n \t\t\tclose(client);\n \t\t\treturn 1;\n \t\t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285094","messageId":"1462101297-8610-23-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 22/41] diff-no-index.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:38Z","receivedAt":"2016-05-01T11:14:38Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff-no-index.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 03daadb..1f8999b 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -65,8 +65,7 @@ static int populate_from_stdin(struct diff_filespec *s)\n \tsize_t size = 0;\n \n \tif (strbuf_read(&buf, 0, 0) < 0)\n-\t\treturn error(\"error while reading from stdin %s\",\n-\t\t\t\t     strerror(errno));\n+\t\treturn error_errno(\"error while reading from stdin\");\n \n \ts->should_munmap = 0;\n \ts->data = strbuf_detach(&buf, &size);\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285095","messageId":"1462101297-8610-24-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 23/41] editor.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:39Z","receivedAt":"2016-05-01T11:14:39Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n editor.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/editor.c b/editor.c\nindex 01c644c..7519ede 100644\n--- a/editor.c\n+++ b/editor.c\n@@ -63,7 +63,6 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en\n \tif (!buffer)\n \t\treturn 0;\n \tif (strbuf_read_file(buffer, path, 0) < 0)\n-\t\treturn error(\"could not read file '%s': %s\",\n-\t\t\t\tpath, strerror(errno));\n+\t\treturn error_errno(\"could not read file '%s'\", path);\n \treturn 0;\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285096","messageId":"1462101297-8610-25-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 24/41] entry.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:40Z","receivedAt":"2016-05-01T11:14:40Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n entry.c | 10 ++++------\n 1 file changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/entry.c b/entry.c\nindex a410957..519e042 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -168,8 +168,8 @@ static int write_entry(struct cache_entry *ce,\n \t\t\tret = symlink(new, path);\n \t\t\tfree(new);\n \t\t\tif (ret)\n-\t\t\t\treturn error(\"unable to create symlink %s (%s)\",\n-\t\t\t\t\t     path, strerror(errno));\n+\t\t\t\treturn error_errno(\"unable to create symlink %s\",\n+\t\t\t\t\t\t   path);\n \t\t\tbreak;\n \t\t}\n \n@@ -186,8 +186,7 @@ static int write_entry(struct cache_entry *ce,\n \t\tfd = open_output_fd(path, ce, to_tempfile);\n \t\tif (fd < 0) {\n \t\t\tfree(new);\n-\t\t\treturn error(\"unable to create file %s (%s)\",\n-\t\t\t\tpath, strerror(errno));\n+\t\t\treturn error_errno(\"unable to create file %s\", path);\n \t\t}\n \n \t\twrote = write_in_full(fd, new, size);\n@@ -284,8 +283,7 @@ int checkout_entry(struct cache_entry *ce,\n \t\t\t\treturn error(\"%s is a directory\", path.buf);\n \t\t\tremove_subtree(&path);\n \t\t} else if (unlink(path.buf))\n-\t\t\treturn error(\"unable to unlink old '%s' (%s)\",\n-\t\t\t\t     path.buf, strerror(errno));\n+\t\t\treturn error_errno(\"unable to unlink old '%s'\", path.buf);\n \t} else if (state->not_new)\n \t\treturn 0;\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285097","messageId":"1462101297-8610-26-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 25/41] fast-import.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:41Z","receivedAt":"2016-05-01T11:14:41Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n fast-import.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 9fc7093..21881d1 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -414,7 +414,7 @@ static void write_crash_report(const char *err)\n \tstruct recent_command *rc;\n \n \tif (!rpt) {\n-\t\terror(\"can't write crash report %s: %s\", loc, strerror(errno));\n+\t\terror_errno(\"can't write crash report %s\", loc);\n \t\tfree(loc);\n \t\treturn;\n \t}\n@@ -1806,8 +1806,8 @@ static void dump_marks(void)\n \t\treturn;\n \n \tif (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) {\n-\t\tfailure |= error(\"Unable to write marks file %s: %s\",\n-\t\t\texport_marks_file, strerror(errno));\n+\t\tfailure |= error_errno(\"Unable to write marks file %s\",\n+\t\t\t\t       export_marks_file);\n \t\treturn;\n \t}\n \n@@ -1822,8 +1822,8 @@ static void dump_marks(void)\n \n \tdump_marks_helper(f, 0, marks);\n \tif (commit_lock_file(&mark_lock)) {\n-\t\tfailure |= error(\"Unable to write file %s: %s\",\n-\t\t\texport_marks_file, strerror(errno));\n+\t\tfailure |= error_errno(\"Unable to write file %s\",\n+\t\t\t\t       export_marks_file);\n \t\treturn;\n \t}\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285098","messageId":"1462101297-8610-27-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 26/41] gpg-interface.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:42Z","receivedAt":"2016-05-01T11:14:42Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n gpg-interface.c | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/gpg-interface.c b/gpg-interface.c\nindex 2259938..c4b1e8c 100644\n--- a/gpg-interface.c\n+++ b/gpg-interface.c\n@@ -219,11 +219,9 @@ int verify_signed_buffer(const char *payload, size_t payload_size,\n \targs_gpg[0] = gpg_program;\n \tfd = git_mkstemp(path, PATH_MAX, \".git_vtag_tmpXXXXXX\");\n \tif (fd < 0)\n-\t\treturn error(_(\"could not create temporary file '%s': %s\"),\n-\t\t\t     path, strerror(errno));\n+\t\treturn error_errno(_(\"could not create temporary file '%s'\"), path);\n \tif (write_in_full(fd, signature, signature_size) < 0)\n-\t\treturn error(_(\"failed writing detached signature to '%s': %s\"),\n-\t\t\t     path, strerror(errno));\n+\t\treturn error_errno(_(\"failed writing detached signature to '%s'\"), path);\n \tclose(fd);\n \n \tgpg.argv = args_gpg;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285099","messageId":"1462101297-8610-28-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 27/41] grep.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:43Z","receivedAt":"2016-05-01T11:14:43Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n grep.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 528b652..87c1890 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)\n \tif (lstat(filename, &st) < 0) {\n \terr_ret:\n \t\tif (errno != ENOENT)\n-\t\t\terror(_(\"'%s': %s\"), filename, strerror(errno));\n+\t\t\terror_errno(_(\"'%s'\"), filename);\n \t\treturn -1;\n \t}\n \tif (!S_ISREG(st.st_mode))\n@@ -1743,7 +1743,7 @@ static int grep_source_load_file(struct grep_source *gs)\n \t\tgoto err_ret;\n \tdata = xmallocz(size);\n \tif (st.st_size != read_in_full(i, data, size)) {\n-\t\terror(_(\"'%s': short read %s\"), filename, strerror(errno));\n+\t\terror_errno(_(\"'%s': short read\"), filename);\n \t\tclose(i);\n \t\tfree(data);\n \t\treturn -1;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285100","messageId":"1462101297-8610-29-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 28/41] http.c: use error_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:44Z","receivedAt":"2016-05-01T11:14:44Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n http.c | 10 ++++------\n 1 file changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 4304b80..7565c93 100644\n--- a/http.c\n+++ b/http.c\n@@ -446,8 +446,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)\n \n \trc = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&ka, len);\n \tif (rc < 0)\n-\t\twarning(\"unable to set SO_KEEPALIVE on socket %s\",\n-\t\t\tstrerror(errno));\n+\t\twarning_errno(\"unable to set SO_KEEPALIVE on socket\");\n \n \treturn 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */\n }\n@@ -1894,8 +1893,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \t}\n \n \tif (freq->localfile < 0) {\n-\t\terror(\"Couldn't create temporary file %s: %s\",\n-\t\t      freq->tmpfile, strerror(errno));\n+\t\terror_errno(\"Couldn't create temporary file %s\", freq->tmpfile);\n \t\tgoto abort;\n \t}\n \n@@ -1940,8 +1938,8 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \t\t\tprev_posn = 0;\n \t\t\tlseek(freq->localfile, 0, SEEK_SET);\n \t\t\tif (ftruncate(freq->localfile, 0) < 0) {\n-\t\t\t\terror(\"Couldn't truncate temporary file %s: %s\",\n-\t\t\t\t\t  freq->tmpfile, strerror(errno));\n+\t\t\t\terror_errno(\"Couldn't truncate temporary file %s\",\n+\t\t\t\t\t    freq->tmpfile);\n \t\t\t\tgoto abort;\n \t\t\t}\n \t\t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285101","messageId":"1462101297-8610-30-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 29/41] ident.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:45Z","receivedAt":"2016-05-01T11:14:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n ident.c | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/ident.c b/ident.c\nindex 4fd82d1..139c528 100644\n--- a/ident.c\n+++ b/ident.c\n@@ -75,14 +75,12 @@ static int add_mailname_host(struct strbuf *buf)\n \tmailname = fopen(\"/etc/mailname\", \"r\");\n \tif (!mailname) {\n \t\tif (errno != ENOENT)\n-\t\t\twarning(\"cannot open /etc/mailname: %s\",\n-\t\t\t\tstrerror(errno));\n+\t\t\twarning_errno(\"cannot open /etc/mailname\");\n \t\treturn -1;\n \t}\n \tif (strbuf_getline(&mailnamebuf, mailname) == EOF) {\n \t\tif (ferror(mailname))\n-\t\t\twarning(\"cannot read /etc/mailname: %s\",\n-\t\t\t\tstrerror(errno));\n+\t\t\twarning_errno(\"cannot read /etc/mailname\");\n \t\tstrbuf_release(&mailnamebuf);\n \t\tfclose(mailname);\n \t\treturn -1;\n@@ -125,7 +123,7 @@ static void add_domainname(struct strbuf *out, int *is_bogus)\n \tchar buf[1024];\n \n \tif (gethostname(buf, sizeof(buf))) {\n-\t\twarning(\"cannot get host name: %s\", strerror(errno));\n+\t\twarning_errno(\"cannot get host name\");\n \t\tstrbuf_addstr(out, \"(none)\");\n \t\t*is_bogus = 1;\n \t\treturn;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285102","messageId":"1462101297-8610-31-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 30/41] mailmap.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:46Z","receivedAt":"2016-05-01T11:14:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n mailmap.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/mailmap.c b/mailmap.c\nindex 9726237..b5c521f 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -189,8 +189,7 @@ static int read_mailmap_file(struct string_list *map, const char *filename,\n \tif (!f) {\n \t\tif (errno == ENOENT)\n \t\t\treturn 0;\n-\t\treturn error(\"unable to open mailmap at %s: %s\",\n-\t\t\t     filename, strerror(errno));\n+\t\treturn error_errno(\"unable to open mailmap at %s\", filename);\n \t}\n \n \twhile (fgets(buffer, sizeof(buffer), f) != NULL)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285103","messageId":"1462101297-8610-32-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 31/41] reachable.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:47Z","receivedAt":"2016-05-01T11:14:47Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n reachable.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/reachable.c b/reachable.c\nindex ed35201..d0199ca 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -119,8 +119,7 @@ static int add_recent_loose(const unsigned char *sha1,\n \t\t */\n \t\tif (errno == ENOENT)\n \t\t\treturn 0;\n-\t\treturn error(\"unable to stat %s: %s\",\n-\t\t\t     sha1_to_hex(sha1), strerror(errno));\n+\t\treturn error_errno(\"unable to stat %s\", sha1_to_hex(sha1));\n \t}\n \n \tadd_recent_object(sha1, st.st_mtime, data);\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285104","messageId":"1462101297-8610-33-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 32/41] rerere.c: use error_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:48Z","receivedAt":"2016-05-01T11:14:48Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n rerere.c | 18 +++++++-----------\n 1 file changed, 7 insertions(+), 11 deletions(-)\n\ndiff --git a/rerere.c b/rerere.c\nindex c8b9f40..1810c04 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -501,8 +501,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output\n \t\terror(\"There were errors while writing %s (%s)\",\n \t\t      path, strerror(io.io.wrerror));\n \tif (io.io.output && fclose(io.io.output))\n-\t\tio.io.wrerror = error(\"Failed to flush %s: %s\",\n-\t\t\t\t      path, strerror(errno));\n+\t\tio.io.wrerror = error_errno(\"Failed to flush %s\", path);\n \n \tif (hunk_no < 0) {\n \t\tif (output)\n@@ -684,20 +683,17 @@ static int merge(const struct rerere_id *id, const char *path)\n \t * Mark that \"postimage\" was used to help gc.\n \t */\n \tif (utime(rerere_path(id, \"postimage\"), NULL) < 0)\n-\t\twarning(\"failed utime() on %s: %s\",\n-\t\t\trerere_path(id, \"postimage\"),\n-\t\t\tstrerror(errno));\n+\t\twarning_errno(\"failed utime() on %s\",\n+\t\t\t      rerere_path(id, \"postimage\"));\n \n \t/* Update \"path\" with the resolution */\n \tf = fopen(path, \"w\");\n \tif (!f)\n-\t\treturn error(\"Could not open %s: %s\", path,\n-\t\t\t     strerror(errno));\n+\t\treturn error_errno(\"Could not open %s\", path);\n \tif (fwrite(result.ptr, result.size, 1, f) != 1)\n-\t\terror(\"Could not write %s: %s\", path, strerror(errno));\n+\t\terror_errno(\"Could not write %s\", path);\n \tif (fclose(f))\n-\t\treturn error(\"Writing %s failed: %s\", path,\n-\t\t\t     strerror(errno));\n+\t\treturn error_errno(\"Writing %s failed\", path);\n \n out:\n \tfree(cur.ptr);\n@@ -1071,7 +1067,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)\n \tif (unlink(filename))\n \t\treturn (errno == ENOENT\n \t\t\t? error(\"no remembered resolution for %s\", path)\n-\t\t\t: error(\"cannot unlink %s: %s\", filename, strerror(errno)));\n+\t\t\t: error_errno(\"cannot unlink %s\", filename));\n \n \t/*\n \t * Update the preimage so that the user can resolve the\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285105","messageId":"1462101297-8610-34-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 33/41] run-command.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:49Z","receivedAt":"2016-05-01T11:14:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n run-command.c | 15 +++++++--------\n 1 file changed, 7 insertions(+), 8 deletions(-)\n\ndiff --git a/run-command.c b/run-command.c\nindex e4593cd..842c8d1 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -233,7 +233,7 @@ static int wait_or_whine(pid_t pid, const char *argv0, int in_signal)\n \n \tif (waiting < 0) {\n \t\tfailed_errno = errno;\n-\t\terror(\"waitpid for %s failed: %s\", argv0, strerror(errno));\n+\t\terror_errno(\"waitpid for %s failed\", argv0);\n \t} else if (waiting != pid) {\n \t\terror(\"waitpid is confused (%s)\", argv0);\n \t} else if (WIFSIGNALED(status)) {\n@@ -420,8 +420,7 @@ fail_pipe:\n \t\t}\n \t}\n \tif (cmd->pid < 0)\n-\t\terror(\"cannot fork() for %s: %s\", cmd->argv[0],\n-\t\t\tstrerror(errno));\n+\t\terror_errno(\"cannot fork() for %s\", cmd->argv[0]);\n \telse if (cmd->clean_on_exit)\n \t\tmark_child_for_cleanup(cmd->pid);\n \n@@ -482,7 +481,7 @@ fail_pipe:\n \t\t\tcmd->dir, fhin, fhout, fherr);\n \tfailed_errno = errno;\n \tif (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))\n-\t\terror(\"cannot spawn %s: %s\", cmd->argv[0], strerror(errno));\n+\t\terror_errno(\"cannot spawn %s\", cmd->argv[0]);\n \tif (cmd->clean_on_exit && cmd->pid >= 0)\n \t\tmark_child_for_cleanup(cmd->pid);\n \n@@ -703,7 +702,7 @@ int start_async(struct async *async)\n \t\tif (pipe(fdin) < 0) {\n \t\t\tif (async->out > 0)\n \t\t\t\tclose(async->out);\n-\t\t\treturn error(\"cannot create pipe: %s\", strerror(errno));\n+\t\t\treturn error_errno(\"cannot create pipe\");\n \t\t}\n \t\tasync->in = fdin[1];\n \t}\n@@ -715,7 +714,7 @@ int start_async(struct async *async)\n \t\t\t\tclose_pair(fdin);\n \t\t\telse if (async->in)\n \t\t\t\tclose(async->in);\n-\t\t\treturn error(\"cannot create pipe: %s\", strerror(errno));\n+\t\t\treturn error_errno(\"cannot create pipe\");\n \t\t}\n \t\tasync->out = fdout[0];\n \t}\n@@ -740,7 +739,7 @@ int start_async(struct async *async)\n \n \tasync->pid = fork();\n \tif (async->pid < 0) {\n-\t\terror(\"fork (async) failed: %s\", strerror(errno));\n+\t\terror_errno(\"fork (async) failed\");\n \t\tgoto error;\n \t}\n \tif (!async->pid) {\n@@ -787,7 +786,7 @@ int start_async(struct async *async)\n \t{\n \t\tint err = pthread_create(&async->tid, NULL, run_thread, async);\n \t\tif (err) {\n-\t\t\terror(\"cannot create thread: %s\", strerror(err));\n+\t\t\terror_errno(\"cannot create thread\");\n \t\t\tgoto error;\n \t\t}\n \t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285106","messageId":"1462101297-8610-35-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 34/41] sequencer.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:50Z","receivedAt":"2016-05-01T11:14:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n sequencer.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex e66f2fe..4687ad4 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -875,8 +875,7 @@ static int sequencer_rollback(struct replay_opts *opts)\n \t\treturn rollback_single_pick();\n \t}\n \tif (!f)\n-\t\treturn error(_(\"cannot open %s: %s\"), git_path_head_file(),\n-\t\t\t\t\t\tstrerror(errno));\n+\t\treturn error_errno(_(\"cannot open %s\"), git_path_head_file());\n \tif (strbuf_getline_lf(&buf, f)) {\n \t\terror(_(\"cannot read %s: %s\"), git_path_head_file(),\n \t\t      ferror(f) ?  strerror(errno) : _(\"unexpected end of file\"));\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285107","messageId":"1462101297-8610-36-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 35/41] server-info.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:51Z","receivedAt":"2016-05-01T11:14:51Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n server-info.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/server-info.c b/server-info.c\nindex 5a86e29..75dd677 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -36,7 +36,7 @@ static int update_info_file(char *path, int (*generate)(FILE *))\n \n out:\n \tif (ret) {\n-\t\terror(\"unable to update %s: %s\", path, strerror(errno));\n+\t\terror_errno(\"unable to update %s\", path);\n \t\tif (fp)\n \t\t\tfclose(fp);\n \t\telse if (fd >= 0)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285108","messageId":"1462101297-8610-37-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 36/41] sha1_file.c: use {error,die,warning}_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:52Z","receivedAt":"2016-05-01T11:14:52Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n sha1_file.c | 32 +++++++++++++-------------------\n 1 file changed, 13 insertions(+), 19 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex d0f2aa0..a7f45b3 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1107,9 +1107,8 @@ unsigned char *use_pack(struct packed_git *p,\n \t\t\t\tPROT_READ, MAP_PRIVATE,\n \t\t\t\tp->pack_fd, win->offset);\n \t\t\tif (win->base == MAP_FAILED)\n-\t\t\t\tdie(\"packfile %s cannot be mapped: %s\",\n-\t\t\t\t\tp->pack_name,\n-\t\t\t\t\tstrerror(errno));\n+\t\t\t\tdie_errno(\"packfile %s cannot be mapped\",\n+\t\t\t\t\t  p->pack_name);\n \t\t\tif (!win->offset && win->len == p->pack_size\n \t\t\t\t&& !p->do_not_close)\n \t\t\t\tclose_pack_fd(p);\n@@ -1279,8 +1278,8 @@ static void prepare_packed_git_one(char *objdir, int local)\n \tdir = opendir(path.buf);\n \tif (!dir) {\n \t\tif (errno != ENOENT)\n-\t\t\terror(\"unable to open object pack directory: %s: %s\",\n-\t\t\t      path.buf, strerror(errno));\n+\t\t\terror_errno(\"unable to open object pack directory: %s\",\n+\t\t\t\t    path.buf);\n \t\tstrbuf_release(&path);\n \t\treturn;\n \t}\n@@ -2984,7 +2983,7 @@ int finalize_object_file(const char *tmpfile, const char *filename)\n \tunlink_or_warn(tmpfile);\n \tif (ret) {\n \t\tif (ret != EEXIST) {\n-\t\t\treturn error(\"unable to write sha1 filename %s: %s\", filename, strerror(ret));\n+\t\t\treturn error_errno(\"unable to write sha1 filename %s\", filename);\n \t\t}\n \t\t/* FIXME!!! Collision check here ? */\n \t}\n@@ -2998,7 +2997,7 @@ out:\n static int write_buffer(int fd, const void *buf, size_t len)\n {\n \tif (write_in_full(fd, buf, len) < 0)\n-\t\treturn error(\"file write error (%s)\", strerror(errno));\n+\t\treturn error_errno(\"file write error\");\n \treturn 0;\n }\n \n@@ -3081,7 +3080,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,\n \t\tif (errno == EACCES)\n \t\t\treturn error(\"insufficient permission for adding an object to repository database %s\", get_object_directory());\n \t\telse\n-\t\t\treturn error(\"unable to create temporary file: %s\", strerror(errno));\n+\t\t\treturn error_errno(\"unable to create temporary file\");\n \t}\n \n \t/* Set it up */\n@@ -3126,8 +3125,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,\n \t\tutb.actime = mtime;\n \t\tutb.modtime = mtime;\n \t\tif (utime(tmp_file.buf, &utb) < 0)\n-\t\t\twarning(\"failed utime() on %s: %s\",\n-\t\t\t\ttmp_file.buf, strerror(errno));\n+\t\t\twarning_errno(\"failed utime() on %s\", tmp_file.buf);\n \t}\n \n \treturn finalize_object_file(tmp_file.buf, filename);\n@@ -3360,7 +3358,7 @@ static int index_core(unsigned char *sha1, int fd, size_t size,\n \t\tif (size == read_in_full(fd, buf, size))\n \t\t\tret = index_mem(sha1, buf, size, type, path, flags);\n \t\telse\n-\t\t\tret = error(\"short read %s\", strerror(errno));\n+\t\t\tret = error_errno(\"short read\");\n \t\tfree(buf);\n \t} else {\n \t\tvoid *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);\n@@ -3425,18 +3423,14 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned\n \tcase S_IFREG:\n \t\tfd = open(path, O_RDONLY);\n \t\tif (fd < 0)\n-\t\t\treturn error(\"open(\\\"%s\\\"): %s\", path,\n-\t\t\t\t     strerror(errno));\n+\t\t\treturn error_errno(\"open(\\\"%s\\\")\", path);\n \t\tif (index_fd(sha1, fd, st, OBJ_BLOB, path, flags) < 0)\n \t\t\treturn error(\"%s: failed to insert into database\",\n \t\t\t\t     path);\n \t\tbreak;\n \tcase S_IFLNK:\n-\t\tif (strbuf_readlink(&sb, path, st->st_size)) {\n-\t\t\tchar *errstr = strerror(errno);\n-\t\t\treturn error(\"readlink(\\\"%s\\\"): %s\", path,\n-\t\t\t             errstr);\n-\t\t}\n+\t\tif (strbuf_readlink(&sb, path, st->st_size))\n+\t\t\treturn error_errno(\"readlink(\\\"%s\\\")\", path);\n \t\tif (!(flags & HASH_WRITE_OBJECT))\n \t\t\thash_sha1_file(sb.buf, sb.len, blob_type, sha1);\n \t\telse if (write_sha1_file(sb.buf, sb.len, blob_type, sha1))\n@@ -3492,7 +3486,7 @@ static int for_each_file_in_obj_subdir(int subdir_nr,\n \tif (!dir) {\n \t\tif (errno == ENOENT)\n \t\t\treturn 0;\n-\t\treturn error(\"unable to open %s: %s\", path->buf, strerror(errno));\n+\t\treturn error_errno(\"unable to open %s\", path->buf);\n \t}\n \n \twhile ((de = readdir(dir))) {\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285109","messageId":"1462101297-8610-38-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 37/41] transport-helper.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:53Z","receivedAt":"2016-05-01T11:14:53Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n transport-helper.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/transport-helper.c b/transport-helper.c\nindex b934183..f09fadc 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -1166,7 +1166,7 @@ static int udt_do_read(struct unidirectional_transfer *t)\n \tbytes = read(t->src, t->buf + t->bufuse, BUFFERSIZE - t->bufuse);\n \tif (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN &&\n \t\terrno != EINTR) {\n-\t\terror(\"read(%s) failed: %s\", t->src_name, strerror(errno));\n+\t\terror_errno(\"read(%s) failed\", t->src_name);\n \t\treturn -1;\n \t} else if (bytes == 0) {\n \t\ttransfer_debug(\"%s EOF (with %i bytes in buffer)\",\n@@ -1193,7 +1193,7 @@ static int udt_do_write(struct unidirectional_transfer *t)\n \ttransfer_debug(\"%s is writable\", t->dest_name);\n \tbytes = xwrite(t->dest, t->buf, t->bufuse);\n \tif (bytes < 0 && errno != EWOULDBLOCK) {\n-\t\terror(\"write(%s) failed: %s\", t->dest_name, strerror(errno));\n+\t\terror_errno(\"write(%s) failed\", t->dest_name);\n \t\treturn -1;\n \t} else if (bytes > 0) {\n \t\tt->bufuse -= bytes;\n@@ -1306,7 +1306,7 @@ static int tloop_join(pid_t pid, const char *name)\n {\n \tint tret;\n \tif (waitpid(pid, &tret, 0) < 0) {\n-\t\terror(\"%s process failed to wait: %s\", name, strerror(errno));\n+\t\terror_errno(\"%s process failed to wait\", name);\n \t\treturn 1;\n \t}\n \tif (!WIFEXITED(tret) || WEXITSTATUS(tret)) {\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285110","messageId":"1462101297-8610-39-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 38/41] unpack-trees.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:54Z","receivedAt":"2016-05-01T11:14:54Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n unpack-trees.c | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 9f55cc2..bb0d142 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -1499,8 +1499,7 @@ static int verify_absent_1(const struct cache_entry *ce,\n \n \t\tpath = xmemdupz(ce->name, len);\n \t\tif (lstat(path, &st))\n-\t\t\tret = error(\"cannot stat '%s': %s\", path,\n-\t\t\t\t\tstrerror(errno));\n+\t\t\tret = error_errno(\"cannot stat '%s'\", path);\n \t\telse\n \t\t\tret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,\n \t\t\t\t\t\t &st, error_type, o);\n@@ -1508,8 +1507,7 @@ static int verify_absent_1(const struct cache_entry *ce,\n \t\treturn ret;\n \t} else if (lstat(ce->name, &st)) {\n \t\tif (errno != ENOENT)\n-\t\t\treturn error(\"cannot stat '%s': %s\", ce->name,\n-\t\t\t\t     strerror(errno));\n+\t\t\treturn error_errno(\"cannot stat '%s'\", ce->name);\n \t\treturn 0;\n \t} else {\n \t\treturn check_ok_to_remove(ce->name, ce_namelen(ce),\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285111","messageId":"1462101297-8610-40-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 39/41] upload-pack.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:55Z","receivedAt":"2016-05-01T11:14:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n upload-pack.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/upload-pack.c b/upload-pack.c\nindex dc802a0..f19444d 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -174,8 +174,7 @@ static void create_pack_file(void)\n \n \t\tif (ret < 0) {\n \t\t\tif (errno != EINTR) {\n-\t\t\t\terror(\"poll failed, resuming: %s\",\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(\"poll failed, resuming\");\n \t\t\t\tsleep(1);\n \t\t\t}\n \t\t\tcontinue;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285112","messageId":"1462101297-8610-41-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 40/41] vcs-svn: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:56Z","receivedAt":"2016-05-01T11:14:56Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n vcs-svn/line_buffer.c    | 4 ++--\n vcs-svn/sliding_window.c | 2 +-\n vcs-svn/svndiff.c        | 4 ++--\n vcs-svn/svndump.c        | 4 ++--\n 4 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/vcs-svn/line_buffer.c b/vcs-svn/line_buffer.c\nindex 57cc1ce..e416caf 100644\n--- a/vcs-svn/line_buffer.c\n+++ b/vcs-svn/line_buffer.c\n@@ -53,9 +53,9 @@ long buffer_tmpfile_prepare_to_read(struct line_buffer *buf)\n {\n \tlong pos = ftell(buf->infile);\n \tif (pos < 0)\n-\t\treturn error(\"ftell error: %s\", strerror(errno));\n+\t\treturn error_errno(\"ftell error\");\n \tif (fseek(buf->infile, 0, SEEK_SET))\n-\t\treturn error(\"seek error: %s\", strerror(errno));\n+\t\treturn error_errno(\"seek error\");\n \treturn pos;\n }\n \ndiff --git a/vcs-svn/sliding_window.c b/vcs-svn/sliding_window.c\nindex f11d490..06d273c 100644\n--- a/vcs-svn/sliding_window.c\n+++ b/vcs-svn/sliding_window.c\n@@ -12,7 +12,7 @@ static int input_error(struct line_buffer *file)\n {\n \tif (!buffer_ferror(file))\n \t\treturn error(\"delta preimage ends early\");\n-\treturn error(\"cannot read delta preimage: %s\", strerror(errno));\n+\treturn error_errno(\"cannot read delta preimage\");\n }\n \n static int skip_or_whine(struct line_buffer *file, off_t gap)\ndiff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c\nindex 74c97c4..75c7531 100644\n--- a/vcs-svn/svndiff.c\n+++ b/vcs-svn/svndiff.c\n@@ -64,13 +64,13 @@ static int write_strbuf(struct strbuf *sb, FILE *out)\n {\n \tif (fwrite(sb->buf, 1, sb->len, out) == sb->len)\t/* Success. */\n \t\treturn 0;\n-\treturn error(\"cannot write delta postimage: %s\", strerror(errno));\n+\treturn error_errno(\"cannot write delta postimage\");\n }\n \n static int error_short_read(struct line_buffer *input)\n {\n \tif (buffer_ferror(input))\n-\t\treturn error(\"error reading delta: %s\", strerror(errno));\n+\t\treturn error_errno(\"error reading delta\");\n \treturn error(\"invalid delta: unexpected end of file\");\n }\n \ndiff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c\nindex 31d1d83..e4b3959 100644\n--- a/vcs-svn/svndump.c\n+++ b/vcs-svn/svndump.c\n@@ -501,7 +501,7 @@ static void init(int report_fd)\n int svndump_init(const char *filename)\n {\n \tif (buffer_init(&input, filename))\n-\t\treturn error(\"cannot open %s: %s\", filename ? filename : \"NULL\", strerror(errno));\n+\t\treturn error_errno(\"cannot open %s\", filename ? filename : \"NULL\");\n \tinit(REPORT_FILENO);\n \treturn 0;\n }\n@@ -509,7 +509,7 @@ int svndump_init(const char *filename)\n int svndump_init_fd(int in_fd, int back_fd)\n {\n \tif(buffer_fdinit(&input, xdup(in_fd)))\n-\t\treturn error(\"cannot open fd %d: %s\", in_fd, strerror(errno));\n+\t\treturn error_errno(\"cannot open fd %d\", in_fd);\n \tinit(xdup(back_fd));\n \treturn 0;\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285113","messageId":"1462101297-8610-42-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH 41/41] wrapper.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:14:57Z","receivedAt":"2016-05-01T11:14:57Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n wrapper.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/wrapper.c b/wrapper.c\nindex 9afc1a0..3df2fe0 100644\n--- a/wrapper.c\n+++ b/wrapper.c\n@@ -572,7 +572,7 @@ static int warn_if_unremovable(const char *op, const char *file, int rc)\n \tif (!rc || errno == ENOENT)\n \t\treturn 0;\n \terr = errno;\n-\twarning(\"unable to %s %s: %s\", op, file, strerror(errno));\n+\twarning_errno(\"unable to %s %s\", op, file);\n \terrno = err;\n \treturn rc;\n }\n@@ -608,7 +608,7 @@ int remove_or_warn(unsigned int mode, const char *file)\n \n void warn_on_inaccessible(const char *path)\n {\n-\twarning(_(\"unable to access '%s': %s\"), path, strerror(errno));\n+\twarning_errno(_(\"unable to access '%s'\"), path);\n }\n \n static int access_error_is_ok(int err, unsigned flag)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285114","messageId":"20160501112124.GA8748@lanh","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 00/41] Add and use error_errno() and warning_errno()","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-01T11:21:24Z","receivedAt":"2016-05-01T11:21:24Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sun, May 01, 2016 at 06:14:16PM +0700, Nguyễn Thái Ngọc Duy wrote:\n> This is a spinoff from my worktree-move topic. This series adds\n> die_errno() companions, error_errno() and warning_errno(), and use them\n> where applicable to reduce the amount of typing (in future).\n\nI had this patch in the series but excluded it before sending because\nthere is something wrong about it.\n\nThe patch shows two code blocks that follow the same pattern:\nclosesocket() then print an error with strerror(). The second block\nsuggests that closesocket() can change errno. But if that's true, the\nfirst block should do the same.\n\nWhich is right? Fix the first block to save errno, or drop the saving\nin the second block?\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 0413d5c..b6de02c 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -1555,8 +1555,7 @@ int mingw_socket(int domain, int type, int protocol)\n \t/* convert into a file descriptor */\n \tif ((sockfd = _open_osfhandle(s, O_RDWR|O_BINARY)) < 0) {\n \t\tclosesocket(s);\n-\t\treturn error(\"unable to make a socket file descriptor: %s\",\n-\t\t\tstrerror(errno));\n+\t\treturn error_errno(\"unable to make a socket file descriptor\");\n \t}\n \treturn sockfd;\n }\n@@ -1606,10 +1605,8 @@ int mingw_accept(int sockfd1, struct sockaddr *sa, socklen_t *sz)\n \n \t/* convert into a file descriptor */\n \tif ((sockfd2 = _open_osfhandle(s2, O_RDWR|O_BINARY)) < 0) {\n-\t\tint err = errno;\n \t\tclosesocket(s2);\n-\t\treturn error(\"unable to make a socket file descriptor: %s\",\n-\t\t\tstrerror(err));\n+\t\treturn error_errno(\"unable to make a socket file descriptor\");\n \t}\n \treturn sockfd2;\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285123","messageId":"CAPig+cQhQ2C-gOuQwJ9RBXM7HBBJkWORfRkq-t-PY=vvxgAonA@mail.gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-2-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 01/41] usage.c: move format processing out of die_errno()","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-01T18:23:34Z","receivedAt":"2016-05-01T18:23:34Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> fmt_with_err() will be shared with the coming error_errno() and\n> warning_errno().\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n> diff --git a/usage.c b/usage.c\n> @@ -109,19 +109,12 @@ void NORETURN die(const char *err, ...)\n> -void NORETURN die_errno(const char *fmt, ...)\n> +static const char *fmt_with_err(const char *fmt)\n>  {\n> -       va_list params;\n> -       char fmt_with_err[1024];\n> +       static char fmt_with_err[1024];\n\nRather than this static buffer, did you consider having the caller\npass in the buffer?\n\n    static const char *fmt_with_err(char *buf, size_t n, const char *fmt)\n    {\n        ...\n        snprintf(buf, n, \"%s: %s\", fmt, str_error);\n        return buf;\n    }\n\n    void die_errno(const char *fmt, ...)\n    {\n        char fmtbuf[1024];\n        ...\n        die_routine(fmt_with_err(fmtbuf, sizeof(fmtbuf), fmt),\n            params);\n        ...\n    }\n\nBetter? Worse? Indifferent?\n\n>         char str_error[256], *err;\n>         int i, j;\n>\n> -       if (die_is_recursing()) {\n> -               fputs(\"fatal: recursion detected in die_errno handler\\n\",\n> -                       stderr);\n> -               exit(128);\n> -       }\n> -\n>         err = strerror(errno);\n>         for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {\n>                 if ((str_error[j++] = err[i++]) != '%')\n> @@ -137,9 +130,21 @@ void NORETURN die_errno(const char *fmt, ...)\n>         }\n>         str_error[j] = 0;\n>         snprintf(fmt_with_err, sizeof(fmt_with_err), \"%s: %s\", fmt, str_error);\n> +       return fmt_with_err;\n> +}\n> +\n> +void NORETURN die_errno(const char *fmt, ...)\n> +{\n> +       va_list params;\n> +\n> +       if (die_is_recursing()) {\n> +               fputs(\"fatal: recursion detected in die_errno handler\\n\",\n> +                       stderr);\n> +               exit(128);\n> +       }\n>\n>         va_start(params, fmt);\n> -       die_routine(fmt_with_err, params);\n> +       die_routine(fmt_with_err(fmt), params);\n>         va_end(params);\n>  }\n"},{"id":"285124","messageId":"CAPig+cSVQMpA6kp5hH0aeMTBfTRW1m3VY-U8t2qjjSk_TnGV=A@mail.gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-9-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 08/41] builtin/mailsplit.c: use error_errno()","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-01T18:31:43Z","receivedAt":"2016-05-01T18:31:43Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n> diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c\n> @@ -109,7 +109,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)\n>                 if ((dir = opendir(name)) == NULL) {\n>                         if (errno == ENOENT)\n>                                 continue;\n> -                       error(\"cannot opendir %s (%s)\", name, strerror(errno));\n> +                       error_errno(\"cannot opendir %s\", name);\n>                         goto out;\n>                 }\n> @@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,\n>         int file_done = 0;\n>\n>         if (!f) {\n> -               error(\"cannot open mbox %s\", file);\n> +               error_errno(\"cannot open mbox %s\", file);\n\nUnlike other cases in this patch which already printed\nstrerror(errno), this one didn't, and the patch upgrades it to do so,\nwhich is valid since errno will not be clobbered between the preceding\nfopen() and this error_errno(). I see other patches in the series do\nlikewise.\n\nThe error(\"cannot read mbox %s\"\" just below this code doesn't deserve\nthe same treatment because strbuf_getwholeline() doesn't promise a\nmeaningful errno. Okay.\n"},{"id":"285127","messageId":"CAPig+cQmjXcsDsCO0A7dgeDg2ho_eFFf9wCouz528kBk_W=b9w@mail.gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-13-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 12/41] builtin/update-index.c: use error_errno()","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-01T18:40:17Z","receivedAt":"2016-05-01T18:40:17Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> \"err\" is deleted because it just causes confusion when \"errno\" is also\n> used directly in process_lstat_error().\n\nDespite the function name which may imply that it is consulting errno,\nthis change makes me feel slightly uncomfortable since it increases\ncoupling. Whereas consulting of errno had been explicit, with this\nchange, it becomes implicit, and someone changing the code needs to be\nextra careful about ensuring that errno does not get clobbered.\n\nNot a big objection, but a nagging doubt...\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n> diff --git a/builtin/update-index.c b/builtin/update-index.c\n> @@ -251,11 +251,11 @@ static int remove_one_path(const char *path)\n> -static int process_lstat_error(const char *path, int err)\n> +static int process_lstat_error(const char *path)\n>  {\n> -       if (err == ENOENT || err == ENOTDIR)\n> +       if (errno == ENOENT || errno == ENOTDIR)\n>                 return remove_one_path(path);\n> -       return error(\"lstat(\\\"%s\\\"): %s\", path, strerror(errno));\n> +       return error_errno(\"lstat(\\\"%s\\\")\", path);\n>  }\n>\n>  static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)\n> @@ -382,7 +382,7 @@ static int process_path(const char *path)\n>          * what to do about the pathname!\n>          */\n>         if (lstat(path, &st) < 0)\n> -               return process_lstat_error(path, errno);\n> +               return process_lstat_error(path);\n>\n>         if (S_ISDIR(st.st_mode))\n>                 return process_directory(path, len, &st);\n"},{"id":"285126","messageId":"CAPig+cT9+xAXEM19LYVS_cpmjSaN-nyAXN8DH0GsbeZxxxdB6g@mail.gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-18-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 17/41] compat/win32/syslog.c: use warning_errno()","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-01T18:40:50Z","receivedAt":"2016-05-01T18:40:50Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n> diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c\n> @@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...)\n>         va_end(ap);\n>\n>         if (str_len < 0) {\n> -               warning(\"vsnprintf failed: '%s'\", strerror(errno));\n> +               warning_errno(\"vsnprintf failed:\");\n\ns/failed:/failed/\n\n>                 return;\n>         }\n"},{"id":"285128","messageId":"CAPig+cQ4hGKSG6aMkGTUPNs5+i3TOA66QmD97sSnMsR7DYsgbg@mail.gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-28-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 27/41] grep.c: use error_errno()","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-01T18:46:14Z","receivedAt":"2016-05-01T18:46:14Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n> diff --git a/grep.c b/grep.c\n> @@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)\n>         if (lstat(filename, &st) < 0) {\n>         err_ret:\n>                 if (errno != ENOENT)\n> -                       error(_(\"'%s': %s\"), filename, strerror(errno));\n> +                       error_errno(_(\"'%s'\"), filename);\n\nDoes this still need to be wrapped in _(...)? (Did it ever?)\n\n>                 return -1;\n>         }\n>         if (!S_ISREG(st.st_mode))\n> @@ -1743,7 +1743,7 @@ static int grep_source_load_file(struct grep_source *gs)\n>                 goto err_ret;\n>         data = xmallocz(size);\n>         if (st.st_size != read_in_full(i, data, size)) {\n> -               error(_(\"'%s': short read %s\"), filename, strerror(errno));\n> +               error_errno(_(\"'%s': short read\"), filename);\n>                 close(i);\n>                 free(data);\n>                 return -1;\n"},{"id":"285154","messageId":"CACsJy8CZ_AH30oa=wB4OVPW2kpykmc---R2f461hK0CJnAVMWw@mail.gmail.com","threadId":"42194","inReplyTo":"CAPig+cQmjXcsDsCO0A7dgeDg2ho_eFFf9wCouz528kBk_W=b9w@mail.gmail.com","subject":"Re: [PATCH 12/41] builtin/update-index.c: use error_errno()","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-02T08:47:47Z","receivedAt":"2016-05-02T08:47:47Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Mon, May 2, 2016 at 1:40 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n>> \"err\" is deleted because it just causes confusion when \"errno\" is also\n>> used directly in process_lstat_error().\n>\n> Despite the function name which may imply that it is consulting errno,\n> this change makes me feel slightly uncomfortable since it increases\n> coupling. Whereas consulting of errno had been explicit, with this\n> change, it becomes implicit, and someone changing the code needs to be\n> extra careful about ensuring that errno does not get clobbered.\n>\n> Not a big objection, but a nagging doubt...\n\nWe could s/errno/err/ in this function and not convert to\nerror_errno(). Or we could delete this function and move the code back\nto its only call site in process_path()?\n\n>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>> ---\n>> diff --git a/builtin/update-index.c b/builtin/update-index.c\n>> @@ -251,11 +251,11 @@ static int remove_one_path(const char *path)\n>> -static int process_lstat_error(const char *path, int err)\n>> +static int process_lstat_error(const char *path)\n>>  {\n>> -       if (err == ENOENT || err == ENOTDIR)\n>> +       if (errno == ENOENT || errno == ENOTDIR)\n>>                 return remove_one_path(path);\n>> -       return error(\"lstat(\\\"%s\\\"): %s\", path, strerror(errno));\n>> +       return error_errno(\"lstat(\\\"%s\\\")\", path);\n>>  }\n>>\n>>  static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)\n>> @@ -382,7 +382,7 @@ static int process_path(const char *path)\n>>          * what to do about the pathname!\n>>          */\n>>         if (lstat(path, &st) < 0)\n>> -               return process_lstat_error(path, errno);\n>> +               return process_lstat_error(path);\n>>\n>>         if (S_ISDIR(st.st_mode))\n>>                 return process_directory(path, len, &st);\n-- \nDuy\n"},{"id":"285185","messageId":"xmqqlh3stiyt.fsf@gitster.mtv.corp.google.com","threadId":"42194","inReplyTo":"CAPig+cQhQ2C-gOuQwJ9RBXM7HBBJkWORfRkq-t-PY=vvxgAonA@mail.gmail.com","subject":"Re: [PATCH 01/41] usage.c: move format processing out of die_errno()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-02T18:26:02Z","receivedAt":"2016-05-02T18:26:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On Sun, May 1, 2016 at 7:14 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n>> fmt_with_err() will be shared with the coming error_errno() and\n>> warning_errno().\n>>\n>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>> ---\n>> diff --git a/usage.c b/usage.c\n>> @@ -109,19 +109,12 @@ void NORETURN die(const char *err, ...)\n>> -void NORETURN die_errno(const char *fmt, ...)\n>> +static const char *fmt_with_err(const char *fmt)\n>>  {\n>> -       va_list params;\n>> -       char fmt_with_err[1024];\n>> +       static char fmt_with_err[1024];\n>\n> Rather than this static buffer, did you consider having the caller\n> pass in the buffer?\n>\n>     static const char *fmt_with_err(char *buf, size_t n, const char *fmt)\n>     {\n>         ...\n>         snprintf(buf, n, \"%s: %s\", fmt, str_error);\n>         return buf;\n>     }\n>\n>     void die_errno(const char *fmt, ...)\n>     {\n>         char fmtbuf[1024];\n>         ...\n>         die_routine(fmt_with_err(fmtbuf, sizeof(fmtbuf), fmt),\n>             params);\n>         ...\n>     }\n>\n> Better? Worse? Indifferent?\n\nCaller supplied buffer would be the way to go when multiple threads\ncould be showing errors and warnings, right?\n\nIt would not make too much of a difference for die(), though.\n"},{"id":"285244","messageId":"20160503044528.GA32259@sigill.intra.peff.net","threadId":"42194","inReplyTo":"xmqqlh3stiyt.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 01/41] usage.c: move format processing out of die_errno()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-05-03T04:45:28Z","receivedAt":"2016-05-03T04:45:28Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, May 02, 2016 at 11:26:02AM -0700, Junio C Hamano wrote:\n\n> Caller supplied buffer would be the way to go when multiple threads\n> could be showing errors and warnings, right?\n> \n> It would not make too much of a difference for die(), though.\n\nI think it can matter for die(). This is happening above the pluggable\ndie_routine() layer, so it's possible for an async task to call die()\nwhich will end in pthread_exit(), while the main program is calling\ndie() to end in regular exit().\n\nI imagine it's exceedingly unlikely, and of course both threads are\ndying anyway, but it could result in some pretty weird memory errors.\nIt's probably worth taking precautions against, especially because it's\nto easy to do so.\n\n-Peff\n"},{"id":"285272","messageId":"CACsJy8DS5-dL8p8iMQs5B1++GaXNQWwdxUeaMCeZ12OoQcPO7Q@mail.gmail.com","threadId":"42194","inReplyTo":"20160503044528.GA32259@sigill.intra.peff.net","subject":"Re: [PATCH 01/41] usage.c: move format processing out of die_errno()","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T09:39:45Z","receivedAt":"2016-05-03T09:39:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, May 3, 2016 at 11:45 AM, Jeff King <peff@peff.net> wrote:\n> On Mon, May 02, 2016 at 11:26:02AM -0700, Junio C Hamano wrote:\n>\n>> Caller supplied buffer would be the way to go when multiple threads\n>> could be showing errors and warnings, right?\n>>\n>> It would not make too much of a difference for die(), though.\n>\n> I think it can matter for die(). This is happening above the pluggable\n> die_routine() layer, so it's possible for an async task to call die()\n> which will end in pthread_exit(), while the main program is calling\n> die() to end in regular exit().\n>\n> I imagine it's exceedingly unlikely, and of course both threads are\n> dying anyway, but it could result in some pretty weird memory errors.\n> It's probably worth taking precautions against, especially because it's\n> to easy to do so.\n\nSo, sum it up, the new fmt_with_err() will take a buffer and size.\ndie_errno() sticks to its static buffer as before. error_errno() and\nwarning_errno() can allocate 1k on stack to be more\nmultithread-friendly. Let me know if some other change is needed.\n-- \nDuy\n"},{"id":"285273","messageId":"20160503101533.GA27522@sigill.intra.peff.net","threadId":"42194","inReplyTo":"CACsJy8DS5-dL8p8iMQs5B1++GaXNQWwdxUeaMCeZ12OoQcPO7Q@mail.gmail.com","subject":"Re: [PATCH 01/41] usage.c: move format processing out of die_errno()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-05-03T10:15:34Z","receivedAt":"2016-05-03T10:15:34Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, May 03, 2016 at 04:39:45PM +0700, Duy Nguyen wrote:\n\n> On Tue, May 3, 2016 at 11:45 AM, Jeff King <peff@peff.net> wrote:\n> > On Mon, May 02, 2016 at 11:26:02AM -0700, Junio C Hamano wrote:\n> >\n> >> Caller supplied buffer would be the way to go when multiple threads\n> >> could be showing errors and warnings, right?\n> >>\n> >> It would not make too much of a difference for die(), though.\n> >\n> > I think it can matter for die(). This is happening above the pluggable\n> > die_routine() layer, so it's possible for an async task to call die()\n> > which will end in pthread_exit(), while the main program is calling\n> > die() to end in regular exit().\n> >\n> > I imagine it's exceedingly unlikely, and of course both threads are\n> > dying anyway, but it could result in some pretty weird memory errors.\n> > It's probably worth taking precautions against, especially because it's\n> > to easy to do so.\n> \n> So, sum it up, the new fmt_with_err() will take a buffer and size.\n> die_errno() sticks to its static buffer as before. error_errno() and\n> warning_errno() can allocate 1k on stack to be more\n> multithread-friendly. Let me know if some other change is needed.\n\nYes, though note that die_errno() currently has a stack buffer, not a\nstatic one. It should remain that way (and error_errno and warning_errno\nshould follow suit) to be friendly to multi-threading.\n\n-Peff\n"},{"id":"285275","messageId":"1462277054-5943-1-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462101297-8610-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 00/41] Add and use error_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:33Z","receivedAt":"2016-05-03T12:03:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Changes are in\n\n  [01/41] usage.c: move format processing out of die_errno()\n  [02/41] usage.c: add warning_errno() and error_errno()\n  [12/41] builtin/update-index.c: prefer \"err\" to \"errno\" in process_lstat_error\n  [17/41] compat/win32/syslog.c: use warning_errno()\n  [27/41] grep.c: use error_errno()\n\n12/41 is basically a revert with s/strerror(errno)/strerror(err)/.\nInterdiff from v1\n\n-- 8< --\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 0c539ed..b8b8522 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -251,11 +251,11 @@ static int remove_one_path(const char *path)\n  *    succeeds.\n  *  - permission error. That's never ok.\n  */\n-static int process_lstat_error(const char *path)\n+static int process_lstat_error(const char *path, int err)\n {\n-\tif (errno == ENOENT || errno == ENOTDIR)\n+\tif (err == ENOENT || err == ENOTDIR)\n \t\treturn remove_one_path(path);\n-\treturn error_errno(\"lstat(\\\"%s\\\")\", path);\n+\treturn error(\"lstat(\\\"%s\\\"): %s\", path, strerror(err));\n }\n \n static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)\n@@ -382,7 +382,7 @@ static int process_path(const char *path)\n \t * what to do about the pathname!\n \t */\n \tif (lstat(path, &st) < 0)\n-\t\treturn process_lstat_error(path);\n+\t\treturn process_lstat_error(path, errno);\n \n \tif (S_ISDIR(st.st_mode))\n \t\treturn process_directory(path, len, &st);\ndiff --git a/compat/win32/syslog.c b/compat/win32/syslog.c\nindex 1c2ae18..6c7c9b6 100644\n--- a/compat/win32/syslog.c\n+++ b/compat/win32/syslog.c\n@@ -28,7 +28,7 @@ void syslog(int priority, const char *fmt, ...)\n \tva_end(ap);\n \n \tif (str_len < 0) {\n-\t\twarning_errno(\"vsnprintf failed:\");\n+\t\twarning_errno(\"vsnprintf failed\");\n \t\treturn;\n \t}\n \ndiff --git a/grep.c b/grep.c\nindex 87c1890..4f3779a 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)\n \tif (lstat(filename, &st) < 0) {\n \terr_ret:\n \t\tif (errno != ENOENT)\n-\t\t\terror_errno(_(\"'%s'\"), filename);\n+\t\t\terror_errno(\"'%s'\", filename);\n \t\treturn -1;\n \t}\n \tif (!S_ISREG(st.st_mode))\ndiff --git a/usage.c b/usage.c\nindex af1b7d1..1dad03f 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -109,9 +109,8 @@ void NORETURN die(const char *err, ...)\n \tva_end(params);\n }\n \n-static const char *fmt_with_err(const char *fmt)\n+static const char *fmt_with_err(char *buf, int n, const char *fmt)\n {\n-\tstatic char fmt_with_err[1024];\n \tchar str_error[256], *err;\n \tint i, j;\n \n@@ -129,12 +128,13 @@ static const char *fmt_with_err(const char *fmt)\n \t\t}\n \t}\n \tstr_error[j] = 0;\n-\tsnprintf(fmt_with_err, sizeof(fmt_with_err), \"%s: %s\", fmt, str_error);\n-\treturn fmt_with_err;\n+\tsnprintf(buf, n, \"%s: %s\", fmt, str_error);\n+\treturn buf;\n }\n \n void NORETURN die_errno(const char *fmt, ...)\n {\n+\tchar buf[1024];\n \tva_list params;\n \n \tif (die_is_recursing()) {\n@@ -144,16 +144,17 @@ void NORETURN die_errno(const char *fmt, ...)\n \t}\n \n \tva_start(params, fmt);\n-\tdie_routine(fmt_with_err(fmt), params);\n+\tdie_routine(fmt_with_err(buf, sizeof(buf), fmt), params);\n \tva_end(params);\n }\n \n int error_errno(const char *fmt, ...)\n {\n+\tchar buf[1024];\n \tva_list params;\n \n \tva_start(params, fmt);\n-\terror_routine(fmt_with_err(fmt), params);\n+\terror_routine(fmt_with_err(buf, sizeof(buf), fmt), params);\n \tva_end(params);\n \treturn -1;\n }\n@@ -171,10 +172,11 @@ int error(const char *err, ...)\n \n void warning_errno(const char *warn, ...)\n {\n+\tchar buf[1024];\n \tva_list params;\n \n \tva_start(params, warn);\n-\twarn_routine(fmt_with_err(warn), params);\n+\twarn_routine(fmt_with_err(buf, sizeof(buf), warn), params);\n \tva_end(params);\n }\n \n-- 8< --\n--\nDuy\n"},{"id":"285276","messageId":"1462277054-5943-2-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 01/41] usage.c: move format processing out of die_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:34Z","receivedAt":"2016-05-03T12:03:34Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"fmt_with_err() will be shared with the coming error_errno() and\nwarning_errno().\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n usage.c | 27 ++++++++++++++++-----------\n 1 file changed, 16 insertions(+), 11 deletions(-)\n\ndiff --git a/usage.c b/usage.c\nindex 82ff131..8675d72 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -109,19 +109,11 @@ void NORETURN die(const char *err, ...)\n \tva_end(params);\n }\n \n-void NORETURN die_errno(const char *fmt, ...)\n+static const char *fmt_with_err(char *buf, int n, const char *fmt)\n {\n-\tva_list params;\n-\tchar fmt_with_err[1024];\n \tchar str_error[256], *err;\n \tint i, j;\n \n-\tif (die_is_recursing()) {\n-\t\tfputs(\"fatal: recursion detected in die_errno handler\\n\",\n-\t\t\tstderr);\n-\t\texit(128);\n-\t}\n-\n \terr = strerror(errno);\n \tfor (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {\n \t\tif ((str_error[j++] = err[i++]) != '%')\n@@ -136,10 +128,23 @@ void NORETURN die_errno(const char *fmt, ...)\n \t\t}\n \t}\n \tstr_error[j] = 0;\n-\tsnprintf(fmt_with_err, sizeof(fmt_with_err), \"%s: %s\", fmt, str_error);\n+\tsnprintf(buf, n, \"%s: %s\", fmt, str_error);\n+\treturn buf;\n+}\n+\n+void NORETURN die_errno(const char *fmt, ...)\n+{\n+\tchar buf[1024];\n+\tva_list params;\n+\n+\tif (die_is_recursing()) {\n+\t\tfputs(\"fatal: recursion detected in die_errno handler\\n\",\n+\t\t\tstderr);\n+\t\texit(128);\n+\t}\n \n \tva_start(params, fmt);\n-\tdie_routine(fmt_with_err, params);\n+\tdie_routine(fmt_with_err(buf, sizeof(buf), fmt), params);\n \tva_end(params);\n }\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285277","messageId":"1462277054-5943-3-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 02/41] usage.c: add warning_errno() and error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:35Z","receivedAt":"2016-05-03T12:03:35Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Similar to die_errno(), these functions will append strerror()\nautomatically.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n git-compat-util.h |  2 ++\n usage.c           | 21 +++++++++++++++++++++\n 2 files changed, 23 insertions(+)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 1f8b5f3..49d4029 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -409,7 +409,9 @@ extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf,\n extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));\n+extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));\n+extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));\n \n #ifndef NO_OPENSSL\n #ifdef APPLE_COMMON_CRYPTO\ndiff --git a/usage.c b/usage.c\nindex 8675d72..1dad03f 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -148,6 +148,17 @@ void NORETURN die_errno(const char *fmt, ...)\n \tva_end(params);\n }\n \n+int error_errno(const char *fmt, ...)\n+{\n+\tchar buf[1024];\n+\tva_list params;\n+\n+\tva_start(params, fmt);\n+\terror_routine(fmt_with_err(buf, sizeof(buf), fmt), params);\n+\tva_end(params);\n+\treturn -1;\n+}\n+\n #undef error\n int error(const char *err, ...)\n {\n@@ -159,6 +170,16 @@ int error(const char *err, ...)\n \treturn -1;\n }\n \n+void warning_errno(const char *warn, ...)\n+{\n+\tchar buf[1024];\n+\tva_list params;\n+\n+\tva_start(params, warn);\n+\twarn_routine(fmt_with_err(buf, sizeof(buf), warn), params);\n+\tva_end(params);\n+}\n+\n void warning(const char *warn, ...)\n {\n \tva_list params;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285278","messageId":"1462277054-5943-4-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 03/41] bisect.c: use die_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:36Z","receivedAt":"2016-05-03T12:03:36Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n bisect.c | 7 +++----\n 1 file changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 7996c29..6d93edb 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -860,8 +860,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)\n \t/* Create file BISECT_ANCESTORS_OK. */\n \tfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);\n \tif (fd < 0)\n-\t\twarning(\"could not create file '%s': %s\",\n-\t\t\tfilename, strerror(errno));\n+\t\twarning_errno(\"could not create file '%s'\",\n+\t\t\t      filename);\n \telse\n \t\tclose(fd);\n  done:\n@@ -910,8 +910,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)\n \t\t\t*read_good = \"good\";\n \t\t\treturn;\n \t\t} else {\n-\t\t\tdie(\"could not read file '%s': %s\", filename,\n-\t\t\t\tstrerror(errno));\n+\t\t\tdie_errno(\"could not read file '%s'\", filename);\n \t\t}\n \t} else {\n \t\tstrbuf_getline_lf(&str, fp);\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285279","messageId":"1462277054-5943-5-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 04/41] builtin/am.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:37Z","receivedAt":"2016-05-03T12:03:37Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/am.c | 11 +++++------\n 1 file changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex d003939..3dfe70b 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -769,15 +769,15 @@ static int split_mail_conv(mail_conv_fn fn, struct am_state *state,\n \t\t\tin = fopen(*paths, \"r\");\n \n \t\tif (!in)\n-\t\t\treturn error(_(\"could not open '%s' for reading: %s\"),\n-\t\t\t\t\t*paths, strerror(errno));\n+\t\t\treturn error_errno(_(\"could not open '%s' for reading\"),\n+\t\t\t\t\t   *paths);\n \n \t\tmail = mkpath(\"%s/%0*d\", state->dir, state->prec, i + 1);\n \n \t\tout = fopen(mail, \"w\");\n \t\tif (!out)\n-\t\t\treturn error(_(\"could not open '%s' for writing: %s\"),\n-\t\t\t\t\tmail, strerror(errno));\n+\t\t\treturn error_errno(_(\"could not open '%s' for writing\"),\n+\t\t\t\t\t   mail);\n \n \t\tret = fn(out, in, keep_cr);\n \n@@ -857,8 +857,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,\n \n \tfp = fopen(*paths, \"r\");\n \tif (!fp)\n-\t\treturn error(_(\"could not open '%s' for reading: %s\"), *paths,\n-\t\t\t\tstrerror(errno));\n+\t\treturn error_errno(_(\"could not open '%s' for reading\"), *paths);\n \n \twhile (!strbuf_getline_lf(&sb, fp)) {\n \t\tif (*sb.buf == '#')\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285281","messageId":"1462277054-5943-6-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 05/41] builtin/branch.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:38Z","receivedAt":"2016-05-03T12:03:38Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/branch.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 0adba62..6f1572d 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -593,8 +593,7 @@ static int edit_branch_description(const char *branch_name)\n \t\t    branch_name, comment_line_char);\n \tif (write_file_gently(git_path(edit_description), \"%s\", buf.buf)) {\n \t\tstrbuf_release(&buf);\n-\t\treturn error(_(\"could not write branch description template: %s\"),\n-\t\t\t     strerror(errno));\n+\t\treturn error_errno(_(\"could not write branch description template\"));\n \t}\n \tstrbuf_reset(&buf);\n \tif (launch_editor(git_path(edit_description), &buf, NULL)) {\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285280","messageId":"1462277054-5943-7-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 06/41] builtin/fetch.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:39Z","receivedAt":"2016-05-03T12:03:39Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/fetch.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex f8455bd..1582ca7 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -607,7 +607,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \n \tfp = fopen(filename, \"a\");\n \tif (!fp)\n-\t\treturn error(_(\"cannot open %s: %s\\n\"), filename, strerror(errno));\n+\t\treturn error_errno(_(\"cannot open %s\"), filename);\n \n \tif (raw_url)\n \t\turl = transport_anonymize_url(raw_url);\n@@ -848,7 +848,7 @@ static int truncate_fetch_head(void)\n \tFILE *fp = fopen_for_writing(filename);\n \n \tif (!fp)\n-\t\treturn error(_(\"cannot open %s: %s\\n\"), filename, strerror(errno));\n+\t\treturn error_errno(_(\"cannot open %s\"), filename);\n \tfclose(fp);\n \treturn 0;\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285283","messageId":"1462277054-5943-8-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 07/41] builtin/help.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:40Z","receivedAt":"2016-05-03T12:03:40Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/help.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 3c55ce4..8848013 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -127,7 +127,7 @@ static void exec_woman_emacs(const char *path, const char *page)\n \t\t\tpath = \"emacsclient\";\n \t\tstrbuf_addf(&man_page, \"(woman \\\"%s\\\")\", page);\n \t\texeclp(path, \"emacsclient\", \"-e\", man_page.buf, (char *)NULL);\n-\t\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n+\t\twarning_errno(_(\"failed to exec '%s'\"), path);\n \t}\n }\n \n@@ -148,7 +148,7 @@ static void exec_man_konqueror(const char *path, const char *page)\n \t\t\tpath = \"kfmclient\";\n \t\tstrbuf_addf(&man_page, \"man:%s(1)\", page);\n \t\texeclp(path, filename, \"newTab\", man_page.buf, (char *)NULL);\n-\t\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n+\t\twarning_errno(_(\"failed to exec '%s'\"), path);\n \t}\n }\n \n@@ -157,7 +157,7 @@ static void exec_man_man(const char *path, const char *page)\n \tif (!path)\n \t\tpath = \"man\";\n \texeclp(path, \"man\", page, (char *)NULL);\n-\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n+\twarning_errno(_(\"failed to exec '%s'\"), path);\n }\n \n static void exec_man_cmd(const char *cmd, const char *page)\n@@ -165,7 +165,7 @@ static void exec_man_cmd(const char *cmd, const char *page)\n \tstruct strbuf shell_cmd = STRBUF_INIT;\n \tstrbuf_addf(&shell_cmd, \"%s %s\", cmd, page);\n \texecl(SHELL_PATH, SHELL_PATH, \"-c\", shell_cmd.buf, (char *)NULL);\n-\twarning(_(\"failed to exec '%s': %s\"), cmd, strerror(errno));\n+\twarning(_(\"failed to exec '%s'\"), cmd);\n }\n \n static void add_man_viewer(const char *name)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285282","messageId":"1462277054-5943-9-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 08/41] builtin/mailsplit.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:41Z","receivedAt":"2016-05-03T12:03:41Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/mailsplit.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/mailsplit.c b/builtin/mailsplit.c\nindex 104277a..4859ede 100644\n--- a/builtin/mailsplit.c\n+++ b/builtin/mailsplit.c\n@@ -109,7 +109,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)\n \t\tif ((dir = opendir(name)) == NULL) {\n \t\t\tif (errno == ENOENT)\n \t\t\t\tcontinue;\n-\t\t\terror(\"cannot opendir %s (%s)\", name, strerror(errno));\n+\t\t\terror_errno(\"cannot opendir %s\", name);\n \t\t\tgoto out;\n \t\t}\n \n@@ -174,12 +174,12 @@ static int split_maildir(const char *maildir, const char *dir,\n \n \t\tf = fopen(file, \"r\");\n \t\tif (!f) {\n-\t\t\terror(\"cannot open mail %s (%s)\", file, strerror(errno));\n+\t\t\terror_errno(\"cannot open mail %s\", file);\n \t\t\tgoto out;\n \t\t}\n \n \t\tif (strbuf_getwholeline(&buf, f, '\\n')) {\n-\t\t\terror(\"cannot read mail %s (%s)\", file, strerror(errno));\n+\t\t\terror_errno(\"cannot read mail %s\", file);\n \t\t\tgoto out;\n \t\t}\n \n@@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,\n \tint file_done = 0;\n \n \tif (!f) {\n-\t\terror(\"cannot open mbox %s\", file);\n+\t\terror_errno(\"cannot open mbox %s\", file);\n \t\tgoto out;\n \t}\n \n@@ -318,7 +318,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)\n \t\t}\n \n \t\tif (stat(arg, &argstat) == -1) {\n-\t\t\terror(\"cannot stat %s (%s)\", arg, strerror(errno));\n+\t\t\terror_errno(\"cannot stat %s\", arg);\n \t\t\treturn 1;\n \t\t}\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285292","messageId":"1462277054-5943-10-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 09/41] builtin/merge-file.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:42Z","receivedAt":"2016-05-03T12:03:42Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/merge-file.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 5544705..13e22a2 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -62,8 +62,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \t\tusage_with_options(merge_file_usage, options);\n \tif (quiet) {\n \t\tif (!freopen(\"/dev/null\", \"w\", stderr))\n-\t\t\treturn error(\"failed to redirect stderr to /dev/null: \"\n-\t\t\t\t     \"%s\", strerror(errno));\n+\t\t\treturn error_errno(\"failed to redirect stderr to /dev/null\");\n \t}\n \n \tif (prefix)\n@@ -95,12 +94,13 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \t\tFILE *f = to_stdout ? stdout : fopen(fpath, \"wb\");\n \n \t\tif (!f)\n-\t\t\tret = error(\"Could not open %s for writing\", filename);\n+\t\t\tret = error_errno(\"Could not open %s for writing\",\n+\t\t\t\t\t  filename);\n \t\telse if (result.size &&\n \t\t\t fwrite(result.ptr, result.size, 1, f) != 1)\n-\t\t\tret = error(\"Could not write to %s\", filename);\n+\t\t\tret = error_errno(\"Could not write to %s\", filename);\n \t\telse if (fclose(f))\n-\t\t\tret = error(\"Could not close %s\", filename);\n+\t\t\tret = error_errno(\"Could not close %s\", filename);\n \t\tfree(result.ptr);\n \t}\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285285","messageId":"1462277054-5943-11-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 10/41] builtin/pack-objects.c: use die_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:43Z","receivedAt":"2016-05-03T12:03:43Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/pack-objects.c | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex a27de5b..e18e190 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -828,8 +828,7 @@ static void write_pack_file(void)\n \t\t\t * to preserve this property.\n \t\t\t */\n \t\t\tif (stat(pack_tmp_name, &st) < 0) {\n-\t\t\t\twarning(\"failed to stat %s: %s\",\n-\t\t\t\t\tpack_tmp_name, strerror(errno));\n+\t\t\t\twarning_errno(\"failed to stat %s\", pack_tmp_name);\n \t\t\t} else if (!last_mtime) {\n \t\t\t\tlast_mtime = st.st_mtime;\n \t\t\t} else {\n@@ -837,8 +836,7 @@ static void write_pack_file(void)\n \t\t\t\tutb.actime = st.st_atime;\n \t\t\t\tutb.modtime = --last_mtime;\n \t\t\t\tif (utime(pack_tmp_name, &utb) < 0)\n-\t\t\t\t\twarning(\"failed utime() on %s: %s\",\n-\t\t\t\t\t\tpack_tmp_name, strerror(errno));\n+\t\t\t\t\twarning_errno(\"failed utime() on %s\", pack_tmp_name);\n \t\t\t}\n \n \t\t\tstrbuf_addf(&tmpname, \"%s-\", base_name);\n@@ -2020,7 +2018,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,\n \t\tret = pthread_create(&p[i].thread, NULL,\n \t\t\t\t     threaded_find_deltas, &p[i]);\n \t\tif (ret)\n-\t\t\tdie(\"unable to create thread: %s\", strerror(ret));\n+\t\t\tdie_errno(\"unable to create thread\");\n \t\tactive_threads++;\n \t}\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285284","messageId":"1462277054-5943-12-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 11/41] builtin/rm.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:44Z","receivedAt":"2016-05-03T12:03:44Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/rm.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 8829b09..13b9639 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only)\n \n \t\tif (lstat(ce->name, &st) < 0) {\n \t\t\tif (errno != ENOENT && errno != ENOTDIR)\n-\t\t\t\twarning(\"'%s': %s\", ce->name, strerror(errno));\n+\t\t\t\twarning_errno(\"'%s'\", ce->name);\n \t\t\t/* It already vanished from the working tree */\n \t\t\tcontinue;\n \t\t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285286","messageId":"1462277054-5943-13-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 12/41] builtin/update-index.c: prefer \"err\" to \"errno\" in process_lstat_error","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:45Z","receivedAt":"2016-05-03T12:03:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\"errno\" is already passed in as \"err\". Here we should use err instead of\nerrno. errno is probably a copy/paste mistake in e011054 (Teach\ngit-update-index about gitlinks - 2007-04-12)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/update-index.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 1c94ca5..b8b8522 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -255,7 +255,7 @@ static int process_lstat_error(const char *path, int err)\n {\n \tif (err == ENOENT || err == ENOTDIR)\n \t\treturn remove_one_path(path);\n-\treturn error(\"lstat(\\\"%s\\\"): %s\", path, strerror(errno));\n+\treturn error(\"lstat(\\\"%s\\\"): %s\", path, strerror(err));\n }\n \n static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285287","messageId":"1462277054-5943-14-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 13/41] builtin/upload-archive.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:46Z","receivedAt":"2016-05-03T12:03:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/upload-archive.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/builtin/upload-archive.c b/builtin/upload-archive.c\nindex dbfe14f..2caedf1 100644\n--- a/builtin/upload-archive.c\n+++ b/builtin/upload-archive.c\n@@ -104,8 +104,7 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)\n \t\tpfd[1].events = POLLIN;\n \t\tif (poll(pfd, 2, -1) < 0) {\n \t\t\tif (errno != EINTR) {\n-\t\t\t\terror(\"poll failed resuming: %s\",\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(\"poll failed resuming\");\n \t\t\t\tsleep(1);\n \t\t\t}\n \t\t\tcontinue;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285290","messageId":"1462277054-5943-15-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 14/41] builtin/worktree.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:47Z","receivedAt":"2016-05-03T12:03:47Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/worktree.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex d8e3795..331ecf6 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -110,7 +110,7 @@ static void prune_worktrees(void)\n \t\tif (ret < 0 && errno == ENOTDIR)\n \t\t\tret = unlink(path.buf);\n \t\tif (ret)\n-\t\t\terror(_(\"failed to remove: %s\"), strerror(errno));\n+\t\t\terror_errno(_(\"failed to remove '%s'\"), path.buf);\n \t}\n \tclosedir(dir);\n \tif (!show_only)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285288","messageId":"1462277054-5943-16-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 15/41] check-racy.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:48Z","receivedAt":"2016-05-03T12:03:48Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n check-racy.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/check-racy.c b/check-racy.c\nindex 00d92a1..24b6542 100644\n--- a/check-racy.c\n+++ b/check-racy.c\n@@ -12,7 +12,7 @@ int main(int ac, char **av)\n \t\tstruct stat st;\n \n \t\tif (lstat(ce->name, &st)) {\n-\t\t\terror(\"lstat(%s): %s\", ce->name, strerror(errno));\n+\t\t\terror_errno(\"lstat(%s)\", ce->name);\n \t\t\tcontinue;\n \t\t}\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285289","messageId":"1462277054-5943-17-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 16/41] combine-diff.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:49Z","receivedAt":"2016-05-03T12:03:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n combine-diff.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 0e1d4b0..8f2313d 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1005,8 +1005,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\tstruct strbuf buf = STRBUF_INIT;\n \n \t\t\tif (strbuf_readlink(&buf, elem->path, st.st_size) < 0) {\n-\t\t\t\terror(\"readlink(%s): %s\", elem->path,\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(\"readlink(%s)\", elem->path);\n \t\t\t\treturn;\n \t\t\t}\n \t\t\tresult_size = buf.len;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285291","messageId":"1462277054-5943-18-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 17/41] compat/win32/syslog.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:50Z","receivedAt":"2016-05-03T12:03:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n compat/win32/syslog.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/compat/win32/syslog.c b/compat/win32/syslog.c\nindex b905aea..6c7c9b6 100644\n--- a/compat/win32/syslog.c\n+++ b/compat/win32/syslog.c\n@@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...)\n \tva_end(ap);\n \n \tif (str_len < 0) {\n-\t\twarning(\"vsnprintf failed: '%s'\", strerror(errno));\n+\t\twarning_errno(\"vsnprintf failed\");\n \t\treturn;\n \t}\n \n \tstr = malloc(st_add(str_len, 1));\n \tif (!str) {\n-\t\twarning(\"malloc failed: '%s'\", strerror(errno));\n+\t\twarning_errno(\"malloc failed\");\n \t\treturn;\n \t}\n \n@@ -45,7 +45,7 @@ void syslog(int priority, const char *fmt, ...)\n \twhile ((pos = strstr(str, \"%1\")) != NULL) {\n \t\tstr = realloc(str, st_add(++str_len, 1));\n \t\tif (!str) {\n-\t\t\twarning(\"realloc failed: '%s'\", strerror(errno));\n+\t\t\twarning_errno(\"realloc failed\");\n \t\t\treturn;\n \t\t}\n \t\tmemmove(pos + 2, pos + 1, strlen(pos));\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285293","messageId":"1462277054-5943-19-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 18/41] config.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:51Z","receivedAt":"2016-05-03T12:03:51Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n config.c | 22 +++++++++-------------\n 1 file changed, 9 insertions(+), 13 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex 10b5c95..80411e4 100644\n--- a/config.c\n+++ b/config.c\n@@ -2012,7 +2012,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \tlock = xcalloc(1, sizeof(struct lock_file));\n \tfd = hold_lock_file_for_update(lock, config_filename, 0);\n \tif (fd < 0) {\n-\t\terror(\"could not lock config file %s: %s\", config_filename, strerror(errno));\n+\t\terror_errno(\"could not lock config file %s\", config_filename);\n \t\tfree(store.key);\n \t\tret = CONFIG_NO_LOCK;\n \t\tgoto out_free;\n@@ -2026,8 +2026,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t\tfree(store.key);\n \n \t\tif ( ENOENT != errno ) {\n-\t\t\terror(\"opening %s: %s\", config_filename,\n-\t\t\t      strerror(errno));\n+\t\t\terror_errno(\"opening %s\", config_filename);\n \t\t\tret = CONFIG_INVALID_FILE; /* same as \"invalid config file\" */\n \t\t\tgoto out_free;\n \t\t}\n@@ -2111,8 +2110,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t\tif (contents == MAP_FAILED) {\n \t\t\tif (errno == ENODEV && S_ISDIR(st.st_mode))\n \t\t\t\terrno = EISDIR;\n-\t\t\terror(\"unable to mmap '%s': %s\",\n-\t\t\t      config_filename, strerror(errno));\n+\t\t\terror_errno(\"unable to mmap '%s'\", config_filename);\n \t\t\tret = CONFIG_INVALID_FILE;\n \t\t\tcontents = NULL;\n \t\t\tgoto out_free;\n@@ -2121,8 +2119,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t\tin_fd = -1;\n \n \t\tif (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {\n-\t\t\terror(\"chmod on %s failed: %s\",\n-\t\t\t      get_lock_file_path(lock), strerror(errno));\n+\t\t\terror_errno(\"chmod on %s failed\", get_lock_file_path(lock));\n \t\t\tret = CONFIG_NO_WRITE;\n \t\t\tgoto out_free;\n \t\t}\n@@ -2178,8 +2175,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t}\n \n \tif (commit_lock_file(lock) < 0) {\n-\t\terror(\"could not write config file %s: %s\", config_filename,\n-\t\t      strerror(errno));\n+\t\terror_errno(\"could not write config file %s\", config_filename);\n \t\tret = CONFIG_NO_WRITE;\n \t\tlock = NULL;\n \t\tgoto out_free;\n@@ -2330,8 +2326,8 @@ int git_config_rename_section_in_file(const char *config_filename,\n \tfstat(fileno(config_file), &st);\n \n \tif (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {\n-\t\tret = error(\"chmod on %s failed: %s\",\n-\t\t\t    get_lock_file_path(lock), strerror(errno));\n+\t\tret = error_errno(\"chmod on %s failed\",\n+\t\t\t\t  get_lock_file_path(lock));\n \t\tgoto out;\n \t}\n \n@@ -2385,8 +2381,8 @@ int git_config_rename_section_in_file(const char *config_filename,\n \tfclose(config_file);\n unlock_and_out:\n \tif (commit_lock_file(lock) < 0)\n-\t\tret = error(\"could not write config file %s: %s\",\n-\t\t\t    config_filename, strerror(errno));\n+\t\tret = error_errno(\"could not write config file %s\",\n+\t\t\t\t  config_filename);\n out:\n \tfree(filename_buf);\n \treturn ret;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285295","messageId":"1462277054-5943-20-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 19/41] connected.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:52Z","receivedAt":"2016-05-03T12:03:52Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n connected.c | 9 +++------\n 1 file changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/connected.c b/connected.c\nindex 299c560..bf1b12e 100644\n--- a/connected.c\n+++ b/connected.c\n@@ -86,17 +86,14 @@ static int check_everything_connected_real(sha1_iterate_fn fn,\n \t\tmemcpy(commit, sha1_to_hex(sha1), 40);\n \t\tif (write_in_full(rev_list.in, commit, 41) < 0) {\n \t\t\tif (errno != EPIPE && errno != EINVAL)\n-\t\t\t\terror(_(\"failed write to rev-list: %s\"),\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(_(\"failed write to rev-list\"));\n \t\t\terr = -1;\n \t\t\tbreak;\n \t\t}\n \t} while (!fn(cb_data, sha1));\n \n-\tif (close(rev_list.in)) {\n-\t\terror(_(\"failed to close rev-list's stdin: %s\"), strerror(errno));\n-\t\terr = -1;\n-\t}\n+\tif (close(rev_list.in))\n+\t\terr = error_errno(_(\"failed to close rev-list's stdin\"));\n \n \tsigchain_pop(SIGPIPE);\n \treturn finish_command(&rev_list) || err;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285294","messageId":"1462277054-5943-21-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 20/41] copy.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:53Z","receivedAt":"2016-05-03T12:03:53Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n copy.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/copy.c b/copy.c\nindex 574fa1f..4de6a11 100644\n--- a/copy.c\n+++ b/copy.c\n@@ -42,15 +42,15 @@ int copy_file(const char *dst, const char *src, int mode)\n \tstatus = copy_fd(fdi, fdo);\n \tswitch (status) {\n \tcase COPY_READ_ERROR:\n-\t\terror(\"copy-fd: read returned %s\", strerror(errno));\n+\t\terror_errno(\"copy-fd: read returned\");\n \t\tbreak;\n \tcase COPY_WRITE_ERROR:\n-\t\terror(\"copy-fd: write returned %s\", strerror(errno));\n+\t\terror_errno(\"copy-fd: write returned\");\n \t\tbreak;\n \t}\n \tclose(fdi);\n \tif (close(fdo) != 0)\n-\t\treturn error(\"%s: close error: %s\", dst, strerror(errno));\n+\t\treturn error_errno(\"%s: close error\", dst);\n \n \tif (!status && adjust_shared_perm(dst))\n \t\treturn -1;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285296","messageId":"1462277054-5943-22-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 21/41] credential-cache--daemon.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:54Z","receivedAt":"2016-05-03T12:03:54Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n credential-cache--daemon.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/credential-cache--daemon.c b/credential-cache--daemon.c\nindex 291c0fd..1f14d56 100644\n--- a/credential-cache--daemon.c\n+++ b/credential-cache--daemon.c\n@@ -179,12 +179,12 @@ static int serve_cache_loop(int fd)\n \n \t\tclient = accept(fd, NULL, NULL);\n \t\tif (client < 0) {\n-\t\t\twarning(\"accept failed: %s\", strerror(errno));\n+\t\t\twarning_errno(\"accept failed\");\n \t\t\treturn 1;\n \t\t}\n \t\tclient2 = dup(client);\n \t\tif (client2 < 0) {\n-\t\t\twarning(\"dup failed: %s\", strerror(errno));\n+\t\t\twarning_errno(\"dup failed\");\n \t\t\tclose(client);\n \t\t\treturn 1;\n \t\t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285297","messageId":"1462277054-5943-23-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 22/41] diff-no-index.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:55Z","receivedAt":"2016-05-03T12:03:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff-no-index.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 03daadb..1f8999b 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -65,8 +65,7 @@ static int populate_from_stdin(struct diff_filespec *s)\n \tsize_t size = 0;\n \n \tif (strbuf_read(&buf, 0, 0) < 0)\n-\t\treturn error(\"error while reading from stdin %s\",\n-\t\t\t\t     strerror(errno));\n+\t\treturn error_errno(\"error while reading from stdin\");\n \n \ts->should_munmap = 0;\n \ts->data = strbuf_detach(&buf, &size);\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285299","messageId":"1462277054-5943-24-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 23/41] editor.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:56Z","receivedAt":"2016-05-03T12:03:56Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n editor.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/editor.c b/editor.c\nindex 01c644c..7519ede 100644\n--- a/editor.c\n+++ b/editor.c\n@@ -63,7 +63,6 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en\n \tif (!buffer)\n \t\treturn 0;\n \tif (strbuf_read_file(buffer, path, 0) < 0)\n-\t\treturn error(\"could not read file '%s': %s\",\n-\t\t\t\tpath, strerror(errno));\n+\t\treturn error_errno(\"could not read file '%s'\", path);\n \treturn 0;\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285298","messageId":"1462277054-5943-25-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 24/41] entry.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:57Z","receivedAt":"2016-05-03T12:03:57Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n entry.c | 10 ++++------\n 1 file changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/entry.c b/entry.c\nindex a410957..519e042 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -168,8 +168,8 @@ static int write_entry(struct cache_entry *ce,\n \t\t\tret = symlink(new, path);\n \t\t\tfree(new);\n \t\t\tif (ret)\n-\t\t\t\treturn error(\"unable to create symlink %s (%s)\",\n-\t\t\t\t\t     path, strerror(errno));\n+\t\t\t\treturn error_errno(\"unable to create symlink %s\",\n+\t\t\t\t\t\t   path);\n \t\t\tbreak;\n \t\t}\n \n@@ -186,8 +186,7 @@ static int write_entry(struct cache_entry *ce,\n \t\tfd = open_output_fd(path, ce, to_tempfile);\n \t\tif (fd < 0) {\n \t\t\tfree(new);\n-\t\t\treturn error(\"unable to create file %s (%s)\",\n-\t\t\t\tpath, strerror(errno));\n+\t\t\treturn error_errno(\"unable to create file %s\", path);\n \t\t}\n \n \t\twrote = write_in_full(fd, new, size);\n@@ -284,8 +283,7 @@ int checkout_entry(struct cache_entry *ce,\n \t\t\t\treturn error(\"%s is a directory\", path.buf);\n \t\t\tremove_subtree(&path);\n \t\t} else if (unlink(path.buf))\n-\t\t\treturn error(\"unable to unlink old '%s' (%s)\",\n-\t\t\t\t     path.buf, strerror(errno));\n+\t\t\treturn error_errno(\"unable to unlink old '%s'\", path.buf);\n \t} else if (state->not_new)\n \t\treturn 0;\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285300","messageId":"1462277054-5943-26-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 25/41] fast-import.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:58Z","receivedAt":"2016-05-03T12:03:58Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n fast-import.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 9fc7093..21881d1 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -414,7 +414,7 @@ static void write_crash_report(const char *err)\n \tstruct recent_command *rc;\n \n \tif (!rpt) {\n-\t\terror(\"can't write crash report %s: %s\", loc, strerror(errno));\n+\t\terror_errno(\"can't write crash report %s\", loc);\n \t\tfree(loc);\n \t\treturn;\n \t}\n@@ -1806,8 +1806,8 @@ static void dump_marks(void)\n \t\treturn;\n \n \tif (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) {\n-\t\tfailure |= error(\"Unable to write marks file %s: %s\",\n-\t\t\texport_marks_file, strerror(errno));\n+\t\tfailure |= error_errno(\"Unable to write marks file %s\",\n+\t\t\t\t       export_marks_file);\n \t\treturn;\n \t}\n \n@@ -1822,8 +1822,8 @@ static void dump_marks(void)\n \n \tdump_marks_helper(f, 0, marks);\n \tif (commit_lock_file(&mark_lock)) {\n-\t\tfailure |= error(\"Unable to write file %s: %s\",\n-\t\t\texport_marks_file, strerror(errno));\n+\t\tfailure |= error_errno(\"Unable to write file %s\",\n+\t\t\t\t       export_marks_file);\n \t\treturn;\n \t}\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285301","messageId":"1462277054-5943-27-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 26/41] gpg-interface.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:03:59Z","receivedAt":"2016-05-03T12:03:59Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n gpg-interface.c | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/gpg-interface.c b/gpg-interface.c\nindex 2259938..c4b1e8c 100644\n--- a/gpg-interface.c\n+++ b/gpg-interface.c\n@@ -219,11 +219,9 @@ int verify_signed_buffer(const char *payload, size_t payload_size,\n \targs_gpg[0] = gpg_program;\n \tfd = git_mkstemp(path, PATH_MAX, \".git_vtag_tmpXXXXXX\");\n \tif (fd < 0)\n-\t\treturn error(_(\"could not create temporary file '%s': %s\"),\n-\t\t\t     path, strerror(errno));\n+\t\treturn error_errno(_(\"could not create temporary file '%s'\"), path);\n \tif (write_in_full(fd, signature, signature_size) < 0)\n-\t\treturn error(_(\"failed writing detached signature to '%s': %s\"),\n-\t\t\t     path, strerror(errno));\n+\t\treturn error_errno(_(\"failed writing detached signature to '%s'\"), path);\n \tclose(fd);\n \n \tgpg.argv = args_gpg;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285302","messageId":"1462277054-5943-28-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 27/41] grep.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:00Z","receivedAt":"2016-05-03T12:04:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n grep.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 528b652..4f3779a 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)\n \tif (lstat(filename, &st) < 0) {\n \terr_ret:\n \t\tif (errno != ENOENT)\n-\t\t\terror(_(\"'%s': %s\"), filename, strerror(errno));\n+\t\t\terror_errno(\"'%s'\", filename);\n \t\treturn -1;\n \t}\n \tif (!S_ISREG(st.st_mode))\n@@ -1743,7 +1743,7 @@ static int grep_source_load_file(struct grep_source *gs)\n \t\tgoto err_ret;\n \tdata = xmallocz(size);\n \tif (st.st_size != read_in_full(i, data, size)) {\n-\t\terror(_(\"'%s': short read %s\"), filename, strerror(errno));\n+\t\terror_errno(_(\"'%s': short read\"), filename);\n \t\tclose(i);\n \t\tfree(data);\n \t\treturn -1;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285303","messageId":"1462277054-5943-29-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 28/41] http.c: use error_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:01Z","receivedAt":"2016-05-03T12:04:01Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n http.c | 10 ++++------\n 1 file changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 4304b80..7565c93 100644\n--- a/http.c\n+++ b/http.c\n@@ -446,8 +446,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)\n \n \trc = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&ka, len);\n \tif (rc < 0)\n-\t\twarning(\"unable to set SO_KEEPALIVE on socket %s\",\n-\t\t\tstrerror(errno));\n+\t\twarning_errno(\"unable to set SO_KEEPALIVE on socket\");\n \n \treturn 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */\n }\n@@ -1894,8 +1893,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \t}\n \n \tif (freq->localfile < 0) {\n-\t\terror(\"Couldn't create temporary file %s: %s\",\n-\t\t      freq->tmpfile, strerror(errno));\n+\t\terror_errno(\"Couldn't create temporary file %s\", freq->tmpfile);\n \t\tgoto abort;\n \t}\n \n@@ -1940,8 +1938,8 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \t\t\tprev_posn = 0;\n \t\t\tlseek(freq->localfile, 0, SEEK_SET);\n \t\t\tif (ftruncate(freq->localfile, 0) < 0) {\n-\t\t\t\terror(\"Couldn't truncate temporary file %s: %s\",\n-\t\t\t\t\t  freq->tmpfile, strerror(errno));\n+\t\t\t\terror_errno(\"Couldn't truncate temporary file %s\",\n+\t\t\t\t\t    freq->tmpfile);\n \t\t\t\tgoto abort;\n \t\t\t}\n \t\t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285304","messageId":"1462277054-5943-30-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 29/41] ident.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:02Z","receivedAt":"2016-05-03T12:04:02Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n ident.c | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/ident.c b/ident.c\nindex 4fd82d1..139c528 100644\n--- a/ident.c\n+++ b/ident.c\n@@ -75,14 +75,12 @@ static int add_mailname_host(struct strbuf *buf)\n \tmailname = fopen(\"/etc/mailname\", \"r\");\n \tif (!mailname) {\n \t\tif (errno != ENOENT)\n-\t\t\twarning(\"cannot open /etc/mailname: %s\",\n-\t\t\t\tstrerror(errno));\n+\t\t\twarning_errno(\"cannot open /etc/mailname\");\n \t\treturn -1;\n \t}\n \tif (strbuf_getline(&mailnamebuf, mailname) == EOF) {\n \t\tif (ferror(mailname))\n-\t\t\twarning(\"cannot read /etc/mailname: %s\",\n-\t\t\t\tstrerror(errno));\n+\t\t\twarning_errno(\"cannot read /etc/mailname\");\n \t\tstrbuf_release(&mailnamebuf);\n \t\tfclose(mailname);\n \t\treturn -1;\n@@ -125,7 +123,7 @@ static void add_domainname(struct strbuf *out, int *is_bogus)\n \tchar buf[1024];\n \n \tif (gethostname(buf, sizeof(buf))) {\n-\t\twarning(\"cannot get host name: %s\", strerror(errno));\n+\t\twarning_errno(\"cannot get host name\");\n \t\tstrbuf_addstr(out, \"(none)\");\n \t\t*is_bogus = 1;\n \t\treturn;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285305","messageId":"1462277054-5943-31-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 30/41] mailmap.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:03Z","receivedAt":"2016-05-03T12:04:03Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n mailmap.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/mailmap.c b/mailmap.c\nindex 9726237..b5c521f 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -189,8 +189,7 @@ static int read_mailmap_file(struct string_list *map, const char *filename,\n \tif (!f) {\n \t\tif (errno == ENOENT)\n \t\t\treturn 0;\n-\t\treturn error(\"unable to open mailmap at %s: %s\",\n-\t\t\t     filename, strerror(errno));\n+\t\treturn error_errno(\"unable to open mailmap at %s\", filename);\n \t}\n \n \twhile (fgets(buffer, sizeof(buffer), f) != NULL)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285306","messageId":"1462277054-5943-32-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 31/41] reachable.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:04Z","receivedAt":"2016-05-03T12:04:04Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n reachable.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/reachable.c b/reachable.c\nindex ed35201..d0199ca 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -119,8 +119,7 @@ static int add_recent_loose(const unsigned char *sha1,\n \t\t */\n \t\tif (errno == ENOENT)\n \t\t\treturn 0;\n-\t\treturn error(\"unable to stat %s: %s\",\n-\t\t\t     sha1_to_hex(sha1), strerror(errno));\n+\t\treturn error_errno(\"unable to stat %s\", sha1_to_hex(sha1));\n \t}\n \n \tadd_recent_object(sha1, st.st_mtime, data);\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285307","messageId":"1462277054-5943-33-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 32/41] rerere.c: use error_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:05Z","receivedAt":"2016-05-03T12:04:05Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n rerere.c | 18 +++++++-----------\n 1 file changed, 7 insertions(+), 11 deletions(-)\n\ndiff --git a/rerere.c b/rerere.c\nindex c8b9f40..1810c04 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -501,8 +501,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output\n \t\terror(\"There were errors while writing %s (%s)\",\n \t\t      path, strerror(io.io.wrerror));\n \tif (io.io.output && fclose(io.io.output))\n-\t\tio.io.wrerror = error(\"Failed to flush %s: %s\",\n-\t\t\t\t      path, strerror(errno));\n+\t\tio.io.wrerror = error_errno(\"Failed to flush %s\", path);\n \n \tif (hunk_no < 0) {\n \t\tif (output)\n@@ -684,20 +683,17 @@ static int merge(const struct rerere_id *id, const char *path)\n \t * Mark that \"postimage\" was used to help gc.\n \t */\n \tif (utime(rerere_path(id, \"postimage\"), NULL) < 0)\n-\t\twarning(\"failed utime() on %s: %s\",\n-\t\t\trerere_path(id, \"postimage\"),\n-\t\t\tstrerror(errno));\n+\t\twarning_errno(\"failed utime() on %s\",\n+\t\t\t      rerere_path(id, \"postimage\"));\n \n \t/* Update \"path\" with the resolution */\n \tf = fopen(path, \"w\");\n \tif (!f)\n-\t\treturn error(\"Could not open %s: %s\", path,\n-\t\t\t     strerror(errno));\n+\t\treturn error_errno(\"Could not open %s\", path);\n \tif (fwrite(result.ptr, result.size, 1, f) != 1)\n-\t\terror(\"Could not write %s: %s\", path, strerror(errno));\n+\t\terror_errno(\"Could not write %s\", path);\n \tif (fclose(f))\n-\t\treturn error(\"Writing %s failed: %s\", path,\n-\t\t\t     strerror(errno));\n+\t\treturn error_errno(\"Writing %s failed\", path);\n \n out:\n \tfree(cur.ptr);\n@@ -1071,7 +1067,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)\n \tif (unlink(filename))\n \t\treturn (errno == ENOENT\n \t\t\t? error(\"no remembered resolution for %s\", path)\n-\t\t\t: error(\"cannot unlink %s: %s\", filename, strerror(errno)));\n+\t\t\t: error_errno(\"cannot unlink %s\", filename));\n \n \t/*\n \t * Update the preimage so that the user can resolve the\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285308","messageId":"1462277054-5943-34-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 33/41] run-command.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:06Z","receivedAt":"2016-05-03T12:04:06Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n run-command.c | 15 +++++++--------\n 1 file changed, 7 insertions(+), 8 deletions(-)\n\ndiff --git a/run-command.c b/run-command.c\nindex e4593cd..842c8d1 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -233,7 +233,7 @@ static int wait_or_whine(pid_t pid, const char *argv0, int in_signal)\n \n \tif (waiting < 0) {\n \t\tfailed_errno = errno;\n-\t\terror(\"waitpid for %s failed: %s\", argv0, strerror(errno));\n+\t\terror_errno(\"waitpid for %s failed\", argv0);\n \t} else if (waiting != pid) {\n \t\terror(\"waitpid is confused (%s)\", argv0);\n \t} else if (WIFSIGNALED(status)) {\n@@ -420,8 +420,7 @@ fail_pipe:\n \t\t}\n \t}\n \tif (cmd->pid < 0)\n-\t\terror(\"cannot fork() for %s: %s\", cmd->argv[0],\n-\t\t\tstrerror(errno));\n+\t\terror_errno(\"cannot fork() for %s\", cmd->argv[0]);\n \telse if (cmd->clean_on_exit)\n \t\tmark_child_for_cleanup(cmd->pid);\n \n@@ -482,7 +481,7 @@ fail_pipe:\n \t\t\tcmd->dir, fhin, fhout, fherr);\n \tfailed_errno = errno;\n \tif (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))\n-\t\terror(\"cannot spawn %s: %s\", cmd->argv[0], strerror(errno));\n+\t\terror_errno(\"cannot spawn %s\", cmd->argv[0]);\n \tif (cmd->clean_on_exit && cmd->pid >= 0)\n \t\tmark_child_for_cleanup(cmd->pid);\n \n@@ -703,7 +702,7 @@ int start_async(struct async *async)\n \t\tif (pipe(fdin) < 0) {\n \t\t\tif (async->out > 0)\n \t\t\t\tclose(async->out);\n-\t\t\treturn error(\"cannot create pipe: %s\", strerror(errno));\n+\t\t\treturn error_errno(\"cannot create pipe\");\n \t\t}\n \t\tasync->in = fdin[1];\n \t}\n@@ -715,7 +714,7 @@ int start_async(struct async *async)\n \t\t\t\tclose_pair(fdin);\n \t\t\telse if (async->in)\n \t\t\t\tclose(async->in);\n-\t\t\treturn error(\"cannot create pipe: %s\", strerror(errno));\n+\t\t\treturn error_errno(\"cannot create pipe\");\n \t\t}\n \t\tasync->out = fdout[0];\n \t}\n@@ -740,7 +739,7 @@ int start_async(struct async *async)\n \n \tasync->pid = fork();\n \tif (async->pid < 0) {\n-\t\terror(\"fork (async) failed: %s\", strerror(errno));\n+\t\terror_errno(\"fork (async) failed\");\n \t\tgoto error;\n \t}\n \tif (!async->pid) {\n@@ -787,7 +786,7 @@ int start_async(struct async *async)\n \t{\n \t\tint err = pthread_create(&async->tid, NULL, run_thread, async);\n \t\tif (err) {\n-\t\t\terror(\"cannot create thread: %s\", strerror(err));\n+\t\t\terror_errno(\"cannot create thread\");\n \t\t\tgoto error;\n \t\t}\n \t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285309","messageId":"1462277054-5943-35-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 34/41] sequencer.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:07Z","receivedAt":"2016-05-03T12:04:07Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n sequencer.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex e66f2fe..4687ad4 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -875,8 +875,7 @@ static int sequencer_rollback(struct replay_opts *opts)\n \t\treturn rollback_single_pick();\n \t}\n \tif (!f)\n-\t\treturn error(_(\"cannot open %s: %s\"), git_path_head_file(),\n-\t\t\t\t\t\tstrerror(errno));\n+\t\treturn error_errno(_(\"cannot open %s\"), git_path_head_file());\n \tif (strbuf_getline_lf(&buf, f)) {\n \t\terror(_(\"cannot read %s: %s\"), git_path_head_file(),\n \t\t      ferror(f) ?  strerror(errno) : _(\"unexpected end of file\"));\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285310","messageId":"1462277054-5943-36-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 35/41] server-info.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:08Z","receivedAt":"2016-05-03T12:04:08Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n server-info.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/server-info.c b/server-info.c\nindex 5a86e29..75dd677 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -36,7 +36,7 @@ static int update_info_file(char *path, int (*generate)(FILE *))\n \n out:\n \tif (ret) {\n-\t\terror(\"unable to update %s: %s\", path, strerror(errno));\n+\t\terror_errno(\"unable to update %s\", path);\n \t\tif (fp)\n \t\t\tfclose(fp);\n \t\telse if (fd >= 0)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285311","messageId":"1462277054-5943-37-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 36/41] sha1_file.c: use {error,die,warning}_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:09Z","receivedAt":"2016-05-03T12:04:09Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n sha1_file.c | 32 +++++++++++++-------------------\n 1 file changed, 13 insertions(+), 19 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex d0f2aa0..a7f45b3 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1107,9 +1107,8 @@ unsigned char *use_pack(struct packed_git *p,\n \t\t\t\tPROT_READ, MAP_PRIVATE,\n \t\t\t\tp->pack_fd, win->offset);\n \t\t\tif (win->base == MAP_FAILED)\n-\t\t\t\tdie(\"packfile %s cannot be mapped: %s\",\n-\t\t\t\t\tp->pack_name,\n-\t\t\t\t\tstrerror(errno));\n+\t\t\t\tdie_errno(\"packfile %s cannot be mapped\",\n+\t\t\t\t\t  p->pack_name);\n \t\t\tif (!win->offset && win->len == p->pack_size\n \t\t\t\t&& !p->do_not_close)\n \t\t\t\tclose_pack_fd(p);\n@@ -1279,8 +1278,8 @@ static void prepare_packed_git_one(char *objdir, int local)\n \tdir = opendir(path.buf);\n \tif (!dir) {\n \t\tif (errno != ENOENT)\n-\t\t\terror(\"unable to open object pack directory: %s: %s\",\n-\t\t\t      path.buf, strerror(errno));\n+\t\t\terror_errno(\"unable to open object pack directory: %s\",\n+\t\t\t\t    path.buf);\n \t\tstrbuf_release(&path);\n \t\treturn;\n \t}\n@@ -2984,7 +2983,7 @@ int finalize_object_file(const char *tmpfile, const char *filename)\n \tunlink_or_warn(tmpfile);\n \tif (ret) {\n \t\tif (ret != EEXIST) {\n-\t\t\treturn error(\"unable to write sha1 filename %s: %s\", filename, strerror(ret));\n+\t\t\treturn error_errno(\"unable to write sha1 filename %s\", filename);\n \t\t}\n \t\t/* FIXME!!! Collision check here ? */\n \t}\n@@ -2998,7 +2997,7 @@ out:\n static int write_buffer(int fd, const void *buf, size_t len)\n {\n \tif (write_in_full(fd, buf, len) < 0)\n-\t\treturn error(\"file write error (%s)\", strerror(errno));\n+\t\treturn error_errno(\"file write error\");\n \treturn 0;\n }\n \n@@ -3081,7 +3080,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,\n \t\tif (errno == EACCES)\n \t\t\treturn error(\"insufficient permission for adding an object to repository database %s\", get_object_directory());\n \t\telse\n-\t\t\treturn error(\"unable to create temporary file: %s\", strerror(errno));\n+\t\t\treturn error_errno(\"unable to create temporary file\");\n \t}\n \n \t/* Set it up */\n@@ -3126,8 +3125,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,\n \t\tutb.actime = mtime;\n \t\tutb.modtime = mtime;\n \t\tif (utime(tmp_file.buf, &utb) < 0)\n-\t\t\twarning(\"failed utime() on %s: %s\",\n-\t\t\t\ttmp_file.buf, strerror(errno));\n+\t\t\twarning_errno(\"failed utime() on %s\", tmp_file.buf);\n \t}\n \n \treturn finalize_object_file(tmp_file.buf, filename);\n@@ -3360,7 +3358,7 @@ static int index_core(unsigned char *sha1, int fd, size_t size,\n \t\tif (size == read_in_full(fd, buf, size))\n \t\t\tret = index_mem(sha1, buf, size, type, path, flags);\n \t\telse\n-\t\t\tret = error(\"short read %s\", strerror(errno));\n+\t\t\tret = error_errno(\"short read\");\n \t\tfree(buf);\n \t} else {\n \t\tvoid *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);\n@@ -3425,18 +3423,14 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned\n \tcase S_IFREG:\n \t\tfd = open(path, O_RDONLY);\n \t\tif (fd < 0)\n-\t\t\treturn error(\"open(\\\"%s\\\"): %s\", path,\n-\t\t\t\t     strerror(errno));\n+\t\t\treturn error_errno(\"open(\\\"%s\\\")\", path);\n \t\tif (index_fd(sha1, fd, st, OBJ_BLOB, path, flags) < 0)\n \t\t\treturn error(\"%s: failed to insert into database\",\n \t\t\t\t     path);\n \t\tbreak;\n \tcase S_IFLNK:\n-\t\tif (strbuf_readlink(&sb, path, st->st_size)) {\n-\t\t\tchar *errstr = strerror(errno);\n-\t\t\treturn error(\"readlink(\\\"%s\\\"): %s\", path,\n-\t\t\t             errstr);\n-\t\t}\n+\t\tif (strbuf_readlink(&sb, path, st->st_size))\n+\t\t\treturn error_errno(\"readlink(\\\"%s\\\")\", path);\n \t\tif (!(flags & HASH_WRITE_OBJECT))\n \t\t\thash_sha1_file(sb.buf, sb.len, blob_type, sha1);\n \t\telse if (write_sha1_file(sb.buf, sb.len, blob_type, sha1))\n@@ -3492,7 +3486,7 @@ static int for_each_file_in_obj_subdir(int subdir_nr,\n \tif (!dir) {\n \t\tif (errno == ENOENT)\n \t\t\treturn 0;\n-\t\treturn error(\"unable to open %s: %s\", path->buf, strerror(errno));\n+\t\treturn error_errno(\"unable to open %s\", path->buf);\n \t}\n \n \twhile ((de = readdir(dir))) {\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285313","messageId":"1462277054-5943-38-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 37/41] transport-helper.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:10Z","receivedAt":"2016-05-03T12:04:10Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n transport-helper.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/transport-helper.c b/transport-helper.c\nindex b934183..f09fadc 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -1166,7 +1166,7 @@ static int udt_do_read(struct unidirectional_transfer *t)\n \tbytes = read(t->src, t->buf + t->bufuse, BUFFERSIZE - t->bufuse);\n \tif (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN &&\n \t\terrno != EINTR) {\n-\t\terror(\"read(%s) failed: %s\", t->src_name, strerror(errno));\n+\t\terror_errno(\"read(%s) failed\", t->src_name);\n \t\treturn -1;\n \t} else if (bytes == 0) {\n \t\ttransfer_debug(\"%s EOF (with %i bytes in buffer)\",\n@@ -1193,7 +1193,7 @@ static int udt_do_write(struct unidirectional_transfer *t)\n \ttransfer_debug(\"%s is writable\", t->dest_name);\n \tbytes = xwrite(t->dest, t->buf, t->bufuse);\n \tif (bytes < 0 && errno != EWOULDBLOCK) {\n-\t\terror(\"write(%s) failed: %s\", t->dest_name, strerror(errno));\n+\t\terror_errno(\"write(%s) failed\", t->dest_name);\n \t\treturn -1;\n \t} else if (bytes > 0) {\n \t\tt->bufuse -= bytes;\n@@ -1306,7 +1306,7 @@ static int tloop_join(pid_t pid, const char *name)\n {\n \tint tret;\n \tif (waitpid(pid, &tret, 0) < 0) {\n-\t\terror(\"%s process failed to wait: %s\", name, strerror(errno));\n+\t\terror_errno(\"%s process failed to wait\", name);\n \t\treturn 1;\n \t}\n \tif (!WIFEXITED(tret) || WEXITSTATUS(tret)) {\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285314","messageId":"1462277054-5943-39-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 38/41] unpack-trees.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:11Z","receivedAt":"2016-05-03T12:04:11Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n unpack-trees.c | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 9f55cc2..bb0d142 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -1499,8 +1499,7 @@ static int verify_absent_1(const struct cache_entry *ce,\n \n \t\tpath = xmemdupz(ce->name, len);\n \t\tif (lstat(path, &st))\n-\t\t\tret = error(\"cannot stat '%s': %s\", path,\n-\t\t\t\t\tstrerror(errno));\n+\t\t\tret = error_errno(\"cannot stat '%s'\", path);\n \t\telse\n \t\t\tret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,\n \t\t\t\t\t\t &st, error_type, o);\n@@ -1508,8 +1507,7 @@ static int verify_absent_1(const struct cache_entry *ce,\n \t\treturn ret;\n \t} else if (lstat(ce->name, &st)) {\n \t\tif (errno != ENOENT)\n-\t\t\treturn error(\"cannot stat '%s': %s\", ce->name,\n-\t\t\t\t     strerror(errno));\n+\t\t\treturn error_errno(\"cannot stat '%s'\", ce->name);\n \t\treturn 0;\n \t} else {\n \t\treturn check_ok_to_remove(ce->name, ce_namelen(ce),\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285312","messageId":"1462277054-5943-40-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 39/41] upload-pack.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:12Z","receivedAt":"2016-05-03T12:04:12Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n upload-pack.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/upload-pack.c b/upload-pack.c\nindex dc802a0..f19444d 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -174,8 +174,7 @@ static void create_pack_file(void)\n \n \t\tif (ret < 0) {\n \t\t\tif (errno != EINTR) {\n-\t\t\t\terror(\"poll failed, resuming: %s\",\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(\"poll failed, resuming\");\n \t\t\t\tsleep(1);\n \t\t\t}\n \t\t\tcontinue;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285315","messageId":"1462277054-5943-41-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 40/41] vcs-svn: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:13Z","receivedAt":"2016-05-03T12:04:13Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n vcs-svn/line_buffer.c    | 4 ++--\n vcs-svn/sliding_window.c | 2 +-\n vcs-svn/svndiff.c        | 4 ++--\n vcs-svn/svndump.c        | 4 ++--\n 4 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/vcs-svn/line_buffer.c b/vcs-svn/line_buffer.c\nindex 57cc1ce..e416caf 100644\n--- a/vcs-svn/line_buffer.c\n+++ b/vcs-svn/line_buffer.c\n@@ -53,9 +53,9 @@ long buffer_tmpfile_prepare_to_read(struct line_buffer *buf)\n {\n \tlong pos = ftell(buf->infile);\n \tif (pos < 0)\n-\t\treturn error(\"ftell error: %s\", strerror(errno));\n+\t\treturn error_errno(\"ftell error\");\n \tif (fseek(buf->infile, 0, SEEK_SET))\n-\t\treturn error(\"seek error: %s\", strerror(errno));\n+\t\treturn error_errno(\"seek error\");\n \treturn pos;\n }\n \ndiff --git a/vcs-svn/sliding_window.c b/vcs-svn/sliding_window.c\nindex f11d490..06d273c 100644\n--- a/vcs-svn/sliding_window.c\n+++ b/vcs-svn/sliding_window.c\n@@ -12,7 +12,7 @@ static int input_error(struct line_buffer *file)\n {\n \tif (!buffer_ferror(file))\n \t\treturn error(\"delta preimage ends early\");\n-\treturn error(\"cannot read delta preimage: %s\", strerror(errno));\n+\treturn error_errno(\"cannot read delta preimage\");\n }\n \n static int skip_or_whine(struct line_buffer *file, off_t gap)\ndiff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c\nindex 74c97c4..75c7531 100644\n--- a/vcs-svn/svndiff.c\n+++ b/vcs-svn/svndiff.c\n@@ -64,13 +64,13 @@ static int write_strbuf(struct strbuf *sb, FILE *out)\n {\n \tif (fwrite(sb->buf, 1, sb->len, out) == sb->len)\t/* Success. */\n \t\treturn 0;\n-\treturn error(\"cannot write delta postimage: %s\", strerror(errno));\n+\treturn error_errno(\"cannot write delta postimage\");\n }\n \n static int error_short_read(struct line_buffer *input)\n {\n \tif (buffer_ferror(input))\n-\t\treturn error(\"error reading delta: %s\", strerror(errno));\n+\t\treturn error_errno(\"error reading delta\");\n \treturn error(\"invalid delta: unexpected end of file\");\n }\n \ndiff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c\nindex 31d1d83..e4b3959 100644\n--- a/vcs-svn/svndump.c\n+++ b/vcs-svn/svndump.c\n@@ -501,7 +501,7 @@ static void init(int report_fd)\n int svndump_init(const char *filename)\n {\n \tif (buffer_init(&input, filename))\n-\t\treturn error(\"cannot open %s: %s\", filename ? filename : \"NULL\", strerror(errno));\n+\t\treturn error_errno(\"cannot open %s\", filename ? filename : \"NULL\");\n \tinit(REPORT_FILENO);\n \treturn 0;\n }\n@@ -509,7 +509,7 @@ int svndump_init(const char *filename)\n int svndump_init_fd(int in_fd, int back_fd)\n {\n \tif(buffer_fdinit(&input, xdup(in_fd)))\n-\t\treturn error(\"cannot open fd %d: %s\", in_fd, strerror(errno));\n+\t\treturn error_errno(\"cannot open fd %d\", in_fd);\n \tinit(xdup(back_fd));\n \treturn 0;\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285316","messageId":"1462277054-5943-42-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 41/41] wrapper.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-03T12:04:14Z","receivedAt":"2016-05-03T12:04:14Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n wrapper.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/wrapper.c b/wrapper.c\nindex 9afc1a0..3df2fe0 100644\n--- a/wrapper.c\n+++ b/wrapper.c\n@@ -572,7 +572,7 @@ static int warn_if_unremovable(const char *op, const char *file, int rc)\n \tif (!rc || errno == ENOENT)\n \t\treturn 0;\n \terr = errno;\n-\twarning(\"unable to %s %s: %s\", op, file, strerror(errno));\n+\twarning_errno(\"unable to %s %s\", op, file);\n \terrno = err;\n \treturn rc;\n }\n@@ -608,7 +608,7 @@ int remove_or_warn(unsigned int mode, const char *file)\n \n void warn_on_inaccessible(const char *path)\n {\n-\twarning(_(\"unable to access '%s': %s\"), path, strerror(errno));\n+\twarning_errno(_(\"unable to access '%s'\"), path);\n }\n \n static int access_error_is_ok(int err, unsigned flag)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285339","messageId":"CAPig+cRASxkmgRt_gK89-qtqVPuWzq5TynaXzBY4iqcCdo2Cqg@mail.gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-13-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 12/41] builtin/update-index.c: prefer \"err\" to \"errno\" in process_lstat_error","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-03T16:52:01Z","receivedAt":"2016-05-03T16:52:01Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, May 3, 2016 at 8:03 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> \"errno\" is already passed in as \"err\". Here we should use err instead of\n> errno. errno is probably a copy/paste mistake in e011054 (Teach\n> git-update-index about gitlinks - 2007-04-12)\n\nThanks, this version is quite sensible and doesn't trigger any\nfeelings of discomfort[1].\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/293150/focus=293205\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  builtin/update-index.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/builtin/update-index.c b/builtin/update-index.c\n> index 1c94ca5..b8b8522 100644\n> --- a/builtin/update-index.c\n> +++ b/builtin/update-index.c\n> @@ -255,7 +255,7 @@ static int process_lstat_error(const char *path, int err)\n>  {\n>         if (err == ENOENT || err == ENOTDIR)\n>                 return remove_one_path(path);\n> -       return error(\"lstat(\\\"%s\\\"): %s\", path, strerror(errno));\n> +       return error(\"lstat(\\\"%s\\\"): %s\", path, strerror(err));\n>  }\n>\n>  static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)\n> --\n> 2.8.0.rc0.210.gd302cd2\n"},{"id":"285340","messageId":"CAPig+cRb6w944VrniU-Wq9ET5kvPtYXyTqkUDrNzKS=JY-Qg-g@mail.gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 00/41] Add and use error_errno() and warning_errno()","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-05-03T16:55:21Z","receivedAt":"2016-05-03T16:55:21Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, May 3, 2016 at 8:03 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:\n> Changes are in\n>\n>   [01/41] usage.c: move format processing out of die_errno()\n>   [02/41] usage.c: add warning_errno() and error_errno()\n>   [12/41] builtin/update-index.c: prefer \"err\" to \"errno\" in process_lstat_error\n>   [17/41] compat/win32/syslog.c: use warning_errno()\n>   [27/41] grep.c: use error_errno()\n>\n> 12/41 is basically a revert with s/strerror(errno)/strerror(err)/.\n> Interdiff from v1\n\nThe interdiff looks quite sensible. Thanks.\n\n\n> -- 8< --\n> diff --git a/builtin/update-index.c b/builtin/update-index.c\n> index 0c539ed..b8b8522 100644\n> --- a/builtin/update-index.c\n> +++ b/builtin/update-index.c\n> @@ -251,11 +251,11 @@ static int remove_one_path(const char *path)\n>   *    succeeds.\n>   *  - permission error. That's never ok.\n>   */\n> -static int process_lstat_error(const char *path)\n> +static int process_lstat_error(const char *path, int err)\n>  {\n> -       if (errno == ENOENT || errno == ENOTDIR)\n> +       if (err == ENOENT || err == ENOTDIR)\n>                 return remove_one_path(path);\n> -       return error_errno(\"lstat(\\\"%s\\\")\", path);\n> +       return error(\"lstat(\\\"%s\\\"): %s\", path, strerror(err));\n>  }\n>\n>  static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)\n> @@ -382,7 +382,7 @@ static int process_path(const char *path)\n>          * what to do about the pathname!\n>          */\n>         if (lstat(path, &st) < 0)\n> -               return process_lstat_error(path);\n> +               return process_lstat_error(path, errno);\n>\n>         if (S_ISDIR(st.st_mode))\n>                 return process_directory(path, len, &st);\n> diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c\n> index 1c2ae18..6c7c9b6 100644\n> --- a/compat/win32/syslog.c\n> +++ b/compat/win32/syslog.c\n> @@ -28,7 +28,7 @@ void syslog(int priority, const char *fmt, ...)\n>         va_end(ap);\n>\n>         if (str_len < 0) {\n> -               warning_errno(\"vsnprintf failed:\");\n> +               warning_errno(\"vsnprintf failed\");\n>                 return;\n>         }\n>\n> diff --git a/grep.c b/grep.c\n> index 87c1890..4f3779a 100644\n> --- a/grep.c\n> +++ b/grep.c\n> @@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)\n>         if (lstat(filename, &st) < 0) {\n>         err_ret:\n>                 if (errno != ENOENT)\n> -                       error_errno(_(\"'%s'\"), filename);\n> +                       error_errno(\"'%s'\", filename);\n>                 return -1;\n>         }\n>         if (!S_ISREG(st.st_mode))\n> diff --git a/usage.c b/usage.c\n> index af1b7d1..1dad03f 100644\n> --- a/usage.c\n> +++ b/usage.c\n> @@ -109,9 +109,8 @@ void NORETURN die(const char *err, ...)\n>         va_end(params);\n>  }\n>\n> -static const char *fmt_with_err(const char *fmt)\n> +static const char *fmt_with_err(char *buf, int n, const char *fmt)\n>  {\n> -       static char fmt_with_err[1024];\n>         char str_error[256], *err;\n>         int i, j;\n>\n> @@ -129,12 +128,13 @@ static const char *fmt_with_err(const char *fmt)\n>                 }\n>         }\n>         str_error[j] = 0;\n> -       snprintf(fmt_with_err, sizeof(fmt_with_err), \"%s: %s\", fmt, str_error);\n> -       return fmt_with_err;\n> +       snprintf(buf, n, \"%s: %s\", fmt, str_error);\n> +       return buf;\n>  }\n>\n>  void NORETURN die_errno(const char *fmt, ...)\n>  {\n> +       char buf[1024];\n>         va_list params;\n>\n>         if (die_is_recursing()) {\n> @@ -144,16 +144,17 @@ void NORETURN die_errno(const char *fmt, ...)\n>         }\n>\n>         va_start(params, fmt);\n> -       die_routine(fmt_with_err(fmt), params);\n> +       die_routine(fmt_with_err(buf, sizeof(buf), fmt), params);\n>         va_end(params);\n>  }\n>\n>  int error_errno(const char *fmt, ...)\n>  {\n> +       char buf[1024];\n>         va_list params;\n>\n>         va_start(params, fmt);\n> -       error_routine(fmt_with_err(fmt), params);\n> +       error_routine(fmt_with_err(buf, sizeof(buf), fmt), params);\n>         va_end(params);\n>         return -1;\n>  }\n> @@ -171,10 +172,11 @@ int error(const char *err, ...)\n>\n>  void warning_errno(const char *warn, ...)\n>  {\n> +       char buf[1024];\n>         va_list params;\n>\n>         va_start(params, warn);\n> -       warn_routine(fmt_with_err(warn), params);\n> +       warn_routine(fmt_with_err(buf, sizeof(buf), warn), params);\n>         va_end(params);\n>  }\n>\n> -- 8< --\n"},{"id":"285364","messageId":"xmqqr3djlzfc.fsf@gitster.mtv.corp.google.com","threadId":"42194","inReplyTo":"1462277054-5943-7-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 06/41] builtin/fetch.c: use error_errno()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-03T19:22:15Z","receivedAt":"2016-05-03T19:22:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> diff --git a/builtin/fetch.c b/builtin/fetch.c\n> index f8455bd..1582ca7 100644\n> --- a/builtin/fetch.c\n> +++ b/builtin/fetch.c\n> @@ -607,7 +607,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n>  \n>  \tfp = fopen(filename, \"a\");\n>  \tif (!fp)\n> -\t\treturn error(_(\"cannot open %s: %s\\n\"), filename, strerror(errno));\n> +\t\treturn error_errno(_(\"cannot open %s\"), filename);\n>  \n>  \tif (raw_url)\n>  \t\turl = transport_anonymize_url(raw_url);\n> @@ -848,7 +848,7 @@ static int truncate_fetch_head(void)\n>  \tFILE *fp = fopen_for_writing(filename);\n>  \n>  \tif (!fp)\n> -\t\treturn error(_(\"cannot open %s: %s\\n\"), filename, strerror(errno));\n> +\t\treturn error_errno(_(\"cannot open %s\"), filename);\n>  \tfclose(fp);\n>  \treturn 0;\n>  }\n\nBoth of these original had unwanted \\n at the end, and the updated\none loses them, which is good.\n"},{"id":"285367","messageId":"xmqqinyuncro.fsf@gitster.mtv.corp.google.com","threadId":"42194","inReplyTo":"1462277054-5943-9-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 08/41] builtin/mailsplit.c: use error_errno()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-03T19:48:43Z","receivedAt":"2016-05-03T19:48:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c\n> -\t\t\terror(\"cannot opendir %s (%s)\", name, strerror(errno));\n> +\t\t\terror_errno(\"cannot opendir %s\", name);\n> -\t\t\terror(\"cannot open mail %s (%s)\", file, strerror(errno));\n> +\t\t\terror_errno(\"cannot open mail %s\", file);\n> -\t\t\terror(\"cannot read mail %s (%s)\", file, strerror(errno));\n> +\t\t\terror_errno(\"cannot read mail %s\", file);\n> -\t\t\terror(\"cannot stat %s (%s)\", arg, strerror(errno));\n> +\t\t\terror_errno(\"cannot stat %s\", arg);\n\nThese all used to use its own formatting, but will use \"<message>: <errno>\"\nformat like everybody else, which is good.\n\n> @@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,\n>  \tint file_done = 0;\n>  \n>  \tif (!f) {\n> -\t\terror(\"cannot open mbox %s\", file);\n> +\t\terror_errno(\"cannot open mbox %s\", file);\n>  \t\tgoto out;\n>  \t}\n\nIt may be a bit unclear from the context, but it uses errno that was\nset when fopen() returned a NULL.\n\nThe changes in this patch are not faithful conversion like other\npatches, but they are all good, I would say.\n\nThanks.\n"},{"id":"285368","messageId":"xmqqeg9incih.fsf@gitster.mtv.corp.google.com","threadId":"42194","inReplyTo":"1462277054-5943-11-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 10/41] builtin/pack-objects.c: use die_errno() and warning_errno()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-03T19:54:14Z","receivedAt":"2016-05-03T19:54:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n\n> @@ -2020,7 +2018,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,\n>  \t\tret = pthread_create(&p[i].thread, NULL,\n>  \t\t\t\t     threaded_find_deltas, &p[i]);\n>  \t\tif (ret)\n> -\t\t\tdie(\"unable to create thread: %s\", strerror(ret));\n> +\t\t\tdie_errno(\"unable to create thread\");\n\nThis deserves a mention in the log message.  pthread_create()\nreturns 0 on success and it returns \"an error number\" on error.  We\nused to format that returned value with strerror().\n\nI do not see anywhere in the updated code that copies ret back to\nerrno, which would mean die_errno() would use whatever happens to be\nin errno, and the relationship between the returned value 'ret' and\nthe value that is in 'errno' at this point in the code is unclear to\nme.\n"},{"id":"285369","messageId":"xmqqa8k6ncb1.fsf@gitster.mtv.corp.google.com","threadId":"42194","inReplyTo":"1462277054-5943-12-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 11/41] builtin/rm.c: use warning_errno()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-03T19:58:42Z","receivedAt":"2016-05-03T19:58:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  builtin/rm.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/builtin/rm.c b/builtin/rm.c\n> index 8829b09..13b9639 100644\n> --- a/builtin/rm.c\n> +++ b/builtin/rm.c\n> @@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only)\n>  \n>  \t\tif (lstat(ce->name, &st) < 0) {\n>  \t\t\tif (errno != ENOENT && errno != ENOTDIR)\n> -\t\t\t\twarning(\"'%s': %s\", ce->name, strerror(errno));\n> +\t\t\t\twarning_errno(\"'%s'\", ce->name);\n>  \t\t\t/* It already vanished from the working tree */\n>  \t\t\tcontinue;\n\nNot a new problem with this patch, but this would say\n\n    warning: 'Makefile': Permission denied.\n\nor whatever error we may happen to have hit.\n\nI think we show strerror(errno) as an additional explanation and\nthere must be something _else_ that is the primary thing we would\nwant to say, e.g.\n\n    warning: cannot remove 'Makefile': Permission denied.\n\nWithout that primary message from us, it looks somewhat wrong.\n"},{"id":"285370","messageId":"xmqq60uunc5b.fsf@gitster.mtv.corp.google.com","threadId":"42194","inReplyTo":"1462277054-5943-15-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 14/41] builtin/worktree.c: use error_errno()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-03T20:02:08Z","receivedAt":"2016-05-03T20:02:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  builtin/worktree.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/builtin/worktree.c b/builtin/worktree.c\n> index d8e3795..331ecf6 100644\n> --- a/builtin/worktree.c\n> +++ b/builtin/worktree.c\n> @@ -110,7 +110,7 @@ static void prune_worktrees(void)\n>  \t\tif (ret < 0 && errno == ENOTDIR)\n>  \t\t\tret = unlink(path.buf);\n>  \t\tif (ret)\n> -\t\t\terror(_(\"failed to remove: %s\"), strerror(errno));\n> +\t\t\terror_errno(_(\"failed to remove '%s'\"), path.buf);\n\nThis also deserves a mention in the log message.  We didn't say what\nwe failed to remove, now we do, which is an improvement.\n"},{"id":"285371","messageId":"xmqq1t5inbqh.fsf@gitster.mtv.corp.google.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 00/41] Add and use error_errno() and warning_errno()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-03T20:11:02Z","receivedAt":"2016-05-03T20:11:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> Changes are in\n>\n>   [01/41] usage.c: move format processing out of die_errno()\n>   [02/41] usage.c: add warning_errno() and error_errno()\n>   [12/41] builtin/update-index.c: prefer \"err\" to \"errno\" in process_lstat_error\n>   [17/41] compat/win32/syslog.c: use warning_errno()\n>   [27/41] grep.c: use error_errno()\n>\n> 12/41 is basically a revert with s/strerror(errno)/strerror(err)/.\n> Interdiff from v1\n\nThanks.  The earlier parts that lay the foundation looked good, and\nmost of the conversion of the callers were, too (I think there was\nonly one whose validity I wasn't sure about, though).\n\nSome of the changes that are more than a straight and faithful\nconversion, i.e. fixes to places that used to show an extra newline,\nused to lack errno in the output, etc., deserve to be mentioned in\nthe log message of respective patches.\n\nThanks.\n"},{"id":"285841","messageId":"1462700881-25108-1-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462277054-5943-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 00/41] Add and use error_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:20Z","receivedAt":"2016-05-08T09:47:20Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Code changes compared to v2 is below (one incorrect conversion\nreverted, two error message improvements). Other changes are text in\nthese commits, not shown as diff in this mail:\n\n  [06/41] builtin/fetch.c: use error_errno()\n  [08/41] builtin/mailsplit.c: use error_errno()\n  [09/41] builtin/merge-file.c: use error_errno()\n  [11/41] builtin/rm.c: use warning_errno()\n  [14/41] builtin/worktree.c: use error_errno()\n  [27/41] grep.c: use error_errno()\n\nI didn't mention string format changes (e.g. from \"abc (error)\" to\n\"abc: error\") in the commit messages though.\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex e18e190..1145747 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2018,7 +2018,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,\n \t\tret = pthread_create(&p[i].thread, NULL,\n \t\t\t\t     threaded_find_deltas, &p[i]);\n \t\tif (ret)\n-\t\t\tdie_errno(\"unable to create thread\");\n+\t\t\tdie(\"unable to create thread: %s\", strerror(ret));\n \t\tactive_threads++;\n \t}\n \ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 13b9639..fd47d20 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only)\n \n \t\tif (lstat(ce->name, &st) < 0) {\n \t\t\tif (errno != ENOENT && errno != ENOTDIR)\n-\t\t\t\twarning_errno(\"'%s'\", ce->name);\n+\t\t\t\twarning_errno(_(\"failed to stat '%s'\"), ce->name);\n \t\t\t/* It already vanished from the working tree */\n \t\t\tcontinue;\n \t\t}\ndiff --git a/grep.c b/grep.c\nindex 4f3779a..ec6f7ff 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)\n \tif (lstat(filename, &st) < 0) {\n \terr_ret:\n \t\tif (errno != ENOENT)\n-\t\t\terror_errno(\"'%s'\", filename);\n+\t\t\terror_errno(_(\"failed to stat '%s'\"), filename);\n \t\treturn -1;\n \t}\n \tif (!S_ISREG(st.st_mode))\n"},{"id":"285847","messageId":"1462700881-25108-2-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 01/41] usage.c: move format processing out of die_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:21Z","receivedAt":"2016-05-08T09:47:21Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"fmt_with_err() will be shared with the coming error_errno() and\nwarning_errno().\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n usage.c | 27 ++++++++++++++++-----------\n 1 file changed, 16 insertions(+), 11 deletions(-)\n\ndiff --git a/usage.c b/usage.c\nindex 82ff131..8675d72 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -109,19 +109,11 @@ void NORETURN die(const char *err, ...)\n \tva_end(params);\n }\n \n-void NORETURN die_errno(const char *fmt, ...)\n+static const char *fmt_with_err(char *buf, int n, const char *fmt)\n {\n-\tva_list params;\n-\tchar fmt_with_err[1024];\n \tchar str_error[256], *err;\n \tint i, j;\n \n-\tif (die_is_recursing()) {\n-\t\tfputs(\"fatal: recursion detected in die_errno handler\\n\",\n-\t\t\tstderr);\n-\t\texit(128);\n-\t}\n-\n \terr = strerror(errno);\n \tfor (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {\n \t\tif ((str_error[j++] = err[i++]) != '%')\n@@ -136,10 +128,23 @@ void NORETURN die_errno(const char *fmt, ...)\n \t\t}\n \t}\n \tstr_error[j] = 0;\n-\tsnprintf(fmt_with_err, sizeof(fmt_with_err), \"%s: %s\", fmt, str_error);\n+\tsnprintf(buf, n, \"%s: %s\", fmt, str_error);\n+\treturn buf;\n+}\n+\n+void NORETURN die_errno(const char *fmt, ...)\n+{\n+\tchar buf[1024];\n+\tva_list params;\n+\n+\tif (die_is_recursing()) {\n+\t\tfputs(\"fatal: recursion detected in die_errno handler\\n\",\n+\t\t\tstderr);\n+\t\texit(128);\n+\t}\n \n \tva_start(params, fmt);\n-\tdie_routine(fmt_with_err, params);\n+\tdie_routine(fmt_with_err(buf, sizeof(buf), fmt), params);\n \tva_end(params);\n }\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285837","messageId":"1462700881-25108-3-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 02/41] usage.c: add warning_errno() and error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:22Z","receivedAt":"2016-05-08T09:47:22Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Similar to die_errno(), these functions will append strerror()\nautomatically.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n git-compat-util.h |  2 ++\n usage.c           | 21 +++++++++++++++++++++\n 2 files changed, 23 insertions(+)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 1f8b5f3..49d4029 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -409,7 +409,9 @@ extern NORETURN void usagef(const char *err, ...) __attribute__((format (printf,\n extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));\n+extern int error_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));\n extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));\n+extern void warning_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));\n \n #ifndef NO_OPENSSL\n #ifdef APPLE_COMMON_CRYPTO\ndiff --git a/usage.c b/usage.c\nindex 8675d72..1dad03f 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -148,6 +148,17 @@ void NORETURN die_errno(const char *fmt, ...)\n \tva_end(params);\n }\n \n+int error_errno(const char *fmt, ...)\n+{\n+\tchar buf[1024];\n+\tva_list params;\n+\n+\tva_start(params, fmt);\n+\terror_routine(fmt_with_err(buf, sizeof(buf), fmt), params);\n+\tva_end(params);\n+\treturn -1;\n+}\n+\n #undef error\n int error(const char *err, ...)\n {\n@@ -159,6 +170,16 @@ int error(const char *err, ...)\n \treturn -1;\n }\n \n+void warning_errno(const char *warn, ...)\n+{\n+\tchar buf[1024];\n+\tva_list params;\n+\n+\tva_start(params, warn);\n+\twarn_routine(fmt_with_err(buf, sizeof(buf), warn), params);\n+\tva_end(params);\n+}\n+\n void warning(const char *warn, ...)\n {\n \tva_list params;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285840","messageId":"1462700881-25108-4-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 03/41] bisect.c: use die_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:23Z","receivedAt":"2016-05-08T09:47:23Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n bisect.c | 7 +++----\n 1 file changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 7996c29..6d93edb 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -860,8 +860,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)\n \t/* Create file BISECT_ANCESTORS_OK. */\n \tfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);\n \tif (fd < 0)\n-\t\twarning(\"could not create file '%s': %s\",\n-\t\t\tfilename, strerror(errno));\n+\t\twarning_errno(\"could not create file '%s'\",\n+\t\t\t      filename);\n \telse\n \t\tclose(fd);\n  done:\n@@ -910,8 +910,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)\n \t\t\t*read_good = \"good\";\n \t\t\treturn;\n \t\t} else {\n-\t\t\tdie(\"could not read file '%s': %s\", filename,\n-\t\t\t\tstrerror(errno));\n+\t\t\tdie_errno(\"could not read file '%s'\", filename);\n \t\t}\n \t} else {\n \t\tstrbuf_getline_lf(&str, fp);\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285843","messageId":"1462700881-25108-5-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 04/41] builtin/am.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:24Z","receivedAt":"2016-05-08T09:47:24Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/am.c | 11 +++++------\n 1 file changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex d003939..3dfe70b 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -769,15 +769,15 @@ static int split_mail_conv(mail_conv_fn fn, struct am_state *state,\n \t\t\tin = fopen(*paths, \"r\");\n \n \t\tif (!in)\n-\t\t\treturn error(_(\"could not open '%s' for reading: %s\"),\n-\t\t\t\t\t*paths, strerror(errno));\n+\t\t\treturn error_errno(_(\"could not open '%s' for reading\"),\n+\t\t\t\t\t   *paths);\n \n \t\tmail = mkpath(\"%s/%0*d\", state->dir, state->prec, i + 1);\n \n \t\tout = fopen(mail, \"w\");\n \t\tif (!out)\n-\t\t\treturn error(_(\"could not open '%s' for writing: %s\"),\n-\t\t\t\t\tmail, strerror(errno));\n+\t\t\treturn error_errno(_(\"could not open '%s' for writing\"),\n+\t\t\t\t\t   mail);\n \n \t\tret = fn(out, in, keep_cr);\n \n@@ -857,8 +857,7 @@ static int split_mail_stgit_series(struct am_state *state, const char **paths,\n \n \tfp = fopen(*paths, \"r\");\n \tif (!fp)\n-\t\treturn error(_(\"could not open '%s' for reading: %s\"), *paths,\n-\t\t\t\tstrerror(errno));\n+\t\treturn error_errno(_(\"could not open '%s' for reading\"), *paths);\n \n \twhile (!strbuf_getline_lf(&sb, fp)) {\n \t\tif (*sb.buf == '#')\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285838","messageId":"1462700881-25108-6-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 05/41] builtin/branch.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:25Z","receivedAt":"2016-05-08T09:47:25Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/branch.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 0adba62..6f1572d 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -593,8 +593,7 @@ static int edit_branch_description(const char *branch_name)\n \t\t    branch_name, comment_line_char);\n \tif (write_file_gently(git_path(edit_description), \"%s\", buf.buf)) {\n \t\tstrbuf_release(&buf);\n-\t\treturn error(_(\"could not write branch description template: %s\"),\n-\t\t\t     strerror(errno));\n+\t\treturn error_errno(_(\"could not write branch description template\"));\n \t}\n \tstrbuf_reset(&buf);\n \tif (launch_editor(git_path(edit_description), &buf, NULL)) {\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285844","messageId":"1462700881-25108-7-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 06/41] builtin/fetch.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:26Z","receivedAt":"2016-05-08T09:47:26Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"A couple of newlines are also removed, because both error() and\nerror_errno() automatically append a newline.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/fetch.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex f8455bd..1582ca7 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -607,7 +607,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,\n \n \tfp = fopen(filename, \"a\");\n \tif (!fp)\n-\t\treturn error(_(\"cannot open %s: %s\\n\"), filename, strerror(errno));\n+\t\treturn error_errno(_(\"cannot open %s\"), filename);\n \n \tif (raw_url)\n \t\turl = transport_anonymize_url(raw_url);\n@@ -848,7 +848,7 @@ static int truncate_fetch_head(void)\n \tFILE *fp = fopen_for_writing(filename);\n \n \tif (!fp)\n-\t\treturn error(_(\"cannot open %s: %s\\n\"), filename, strerror(errno));\n+\t\treturn error_errno(_(\"cannot open %s\"), filename);\n \tfclose(fp);\n \treturn 0;\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285845","messageId":"1462700881-25108-8-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 07/41] builtin/help.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:27Z","receivedAt":"2016-05-08T09:47:27Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/help.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 3c55ce4..8848013 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -127,7 +127,7 @@ static void exec_woman_emacs(const char *path, const char *page)\n \t\t\tpath = \"emacsclient\";\n \t\tstrbuf_addf(&man_page, \"(woman \\\"%s\\\")\", page);\n \t\texeclp(path, \"emacsclient\", \"-e\", man_page.buf, (char *)NULL);\n-\t\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n+\t\twarning_errno(_(\"failed to exec '%s'\"), path);\n \t}\n }\n \n@@ -148,7 +148,7 @@ static void exec_man_konqueror(const char *path, const char *page)\n \t\t\tpath = \"kfmclient\";\n \t\tstrbuf_addf(&man_page, \"man:%s(1)\", page);\n \t\texeclp(path, filename, \"newTab\", man_page.buf, (char *)NULL);\n-\t\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n+\t\twarning_errno(_(\"failed to exec '%s'\"), path);\n \t}\n }\n \n@@ -157,7 +157,7 @@ static void exec_man_man(const char *path, const char *page)\n \tif (!path)\n \t\tpath = \"man\";\n \texeclp(path, \"man\", page, (char *)NULL);\n-\twarning(_(\"failed to exec '%s': %s\"), path, strerror(errno));\n+\twarning_errno(_(\"failed to exec '%s'\"), path);\n }\n \n static void exec_man_cmd(const char *cmd, const char *page)\n@@ -165,7 +165,7 @@ static void exec_man_cmd(const char *cmd, const char *page)\n \tstruct strbuf shell_cmd = STRBUF_INIT;\n \tstrbuf_addf(&shell_cmd, \"%s %s\", cmd, page);\n \texecl(SHELL_PATH, SHELL_PATH, \"-c\", shell_cmd.buf, (char *)NULL);\n-\twarning(_(\"failed to exec '%s': %s\"), cmd, strerror(errno));\n+\twarning(_(\"failed to exec '%s'\"), cmd);\n }\n \n static void add_man_viewer(const char *name)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285842","messageId":"1462700881-25108-9-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 08/41] builtin/mailsplit.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:28Z","receivedAt":"2016-05-08T09:47:28Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"There's one change, in split_mbox(), where an error() without strerror()\nas argument is converted to error_errno(). This is correct because the\nprevious call is fopen (not shown in the context lines), which should\nset errno if it returns NULL.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/mailsplit.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/mailsplit.c b/builtin/mailsplit.c\nindex 104277a..4859ede 100644\n--- a/builtin/mailsplit.c\n+++ b/builtin/mailsplit.c\n@@ -109,7 +109,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)\n \t\tif ((dir = opendir(name)) == NULL) {\n \t\t\tif (errno == ENOENT)\n \t\t\t\tcontinue;\n-\t\t\terror(\"cannot opendir %s (%s)\", name, strerror(errno));\n+\t\t\terror_errno(\"cannot opendir %s\", name);\n \t\t\tgoto out;\n \t\t}\n \n@@ -174,12 +174,12 @@ static int split_maildir(const char *maildir, const char *dir,\n \n \t\tf = fopen(file, \"r\");\n \t\tif (!f) {\n-\t\t\terror(\"cannot open mail %s (%s)\", file, strerror(errno));\n+\t\t\terror_errno(\"cannot open mail %s\", file);\n \t\t\tgoto out;\n \t\t}\n \n \t\tif (strbuf_getwholeline(&buf, f, '\\n')) {\n-\t\t\terror(\"cannot read mail %s (%s)\", file, strerror(errno));\n+\t\t\terror_errno(\"cannot read mail %s\", file);\n \t\t\tgoto out;\n \t\t}\n \n@@ -210,7 +210,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,\n \tint file_done = 0;\n \n \tif (!f) {\n-\t\terror(\"cannot open mbox %s\", file);\n+\t\terror_errno(\"cannot open mbox %s\", file);\n \t\tgoto out;\n \t}\n \n@@ -318,7 +318,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)\n \t\t}\n \n \t\tif (stat(arg, &argstat) == -1) {\n-\t\t\terror(\"cannot stat %s (%s)\", arg, strerror(errno));\n+\t\t\terror_errno(\"cannot stat %s\", arg);\n \t\t\treturn 1;\n \t\t}\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285846","messageId":"1462700881-25108-10-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 09/41] builtin/merge-file.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:29Z","receivedAt":"2016-05-08T09:47:29Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"All these error() calls do not print error message previously, but\nbecause when they are called, errno should be set. Use error_errno()\ninstead to give more information.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/merge-file.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex 5544705..13e22a2 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -62,8 +62,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \t\tusage_with_options(merge_file_usage, options);\n \tif (quiet) {\n \t\tif (!freopen(\"/dev/null\", \"w\", stderr))\n-\t\t\treturn error(\"failed to redirect stderr to /dev/null: \"\n-\t\t\t\t     \"%s\", strerror(errno));\n+\t\t\treturn error_errno(\"failed to redirect stderr to /dev/null\");\n \t}\n \n \tif (prefix)\n@@ -95,12 +94,13 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \t\tFILE *f = to_stdout ? stdout : fopen(fpath, \"wb\");\n \n \t\tif (!f)\n-\t\t\tret = error(\"Could not open %s for writing\", filename);\n+\t\t\tret = error_errno(\"Could not open %s for writing\",\n+\t\t\t\t\t  filename);\n \t\telse if (result.size &&\n \t\t\t fwrite(result.ptr, result.size, 1, f) != 1)\n-\t\t\tret = error(\"Could not write to %s\", filename);\n+\t\t\tret = error_errno(\"Could not write to %s\", filename);\n \t\telse if (fclose(f))\n-\t\t\tret = error(\"Could not close %s\", filename);\n+\t\t\tret = error_errno(\"Could not close %s\", filename);\n \t\tfree(result.ptr);\n \t}\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285839","messageId":"1462700881-25108-11-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 10/41] builtin/pack-objects.c: use die_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:30Z","receivedAt":"2016-05-08T09:47:30Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/pack-objects.c | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex a27de5b..1145747 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -828,8 +828,7 @@ static void write_pack_file(void)\n \t\t\t * to preserve this property.\n \t\t\t */\n \t\t\tif (stat(pack_tmp_name, &st) < 0) {\n-\t\t\t\twarning(\"failed to stat %s: %s\",\n-\t\t\t\t\tpack_tmp_name, strerror(errno));\n+\t\t\t\twarning_errno(\"failed to stat %s\", pack_tmp_name);\n \t\t\t} else if (!last_mtime) {\n \t\t\t\tlast_mtime = st.st_mtime;\n \t\t\t} else {\n@@ -837,8 +836,7 @@ static void write_pack_file(void)\n \t\t\t\tutb.actime = st.st_atime;\n \t\t\t\tutb.modtime = --last_mtime;\n \t\t\t\tif (utime(pack_tmp_name, &utb) < 0)\n-\t\t\t\t\twarning(\"failed utime() on %s: %s\",\n-\t\t\t\t\t\tpack_tmp_name, strerror(errno));\n+\t\t\t\t\twarning_errno(\"failed utime() on %s\", pack_tmp_name);\n \t\t\t}\n \n \t\t\tstrbuf_addf(&tmpname, \"%s-\", base_name);\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285865","messageId":"1462700881-25108-12-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 11/41] builtin/rm.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:31Z","receivedAt":"2016-05-08T09:47:31Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"While at there, improve the message a bit (what operation failed?) and\nmark it for translation since the format string is now a sentence.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/rm.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/rm.c b/builtin/rm.c\nindex 8829b09..fd47d20 100644\n--- a/builtin/rm.c\n+++ b/builtin/rm.c\n@@ -152,7 +152,7 @@ static int check_local_mod(unsigned char *head, int index_only)\n \n \t\tif (lstat(ce->name, &st) < 0) {\n \t\t\tif (errno != ENOENT && errno != ENOTDIR)\n-\t\t\t\twarning(\"'%s': %s\", ce->name, strerror(errno));\n+\t\t\t\twarning_errno(_(\"failed to stat '%s'\"), ce->name);\n \t\t\t/* It already vanished from the working tree */\n \t\t\tcontinue;\n \t\t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285850","messageId":"1462700881-25108-13-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 12/41] builtin/update-index.c: prefer \"err\" to \"errno\" in process_lstat_error","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:32Z","receivedAt":"2016-05-08T09:47:32Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\"errno\" is already passed in as \"err\". Here we should use err instead of\nerrno. errno is probably a copy/paste mistake in e011054 (Teach\ngit-update-index about gitlinks - 2007-04-12)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/update-index.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 1c94ca5..b8b8522 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -255,7 +255,7 @@ static int process_lstat_error(const char *path, int err)\n {\n \tif (err == ENOENT || err == ENOTDIR)\n \t\treturn remove_one_path(path);\n-\treturn error(\"lstat(\\\"%s\\\"): %s\", path, strerror(errno));\n+\treturn error(\"lstat(\\\"%s\\\"): %s\", path, strerror(err));\n }\n \n static int add_one_path(const struct cache_entry *old, const char *path, int len, struct stat *st)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285849","messageId":"1462700881-25108-14-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 13/41] builtin/upload-archive.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:33Z","receivedAt":"2016-05-08T09:47:33Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/upload-archive.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/builtin/upload-archive.c b/builtin/upload-archive.c\nindex dbfe14f..2caedf1 100644\n--- a/builtin/upload-archive.c\n+++ b/builtin/upload-archive.c\n@@ -104,8 +104,7 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)\n \t\tpfd[1].events = POLLIN;\n \t\tif (poll(pfd, 2, -1) < 0) {\n \t\t\tif (errno != EINTR) {\n-\t\t\t\terror(\"poll failed resuming: %s\",\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(\"poll failed resuming\");\n \t\t\t\tsleep(1);\n \t\t\t}\n \t\t\tcontinue;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285864","messageId":"1462700881-25108-15-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 14/41] builtin/worktree.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:34Z","receivedAt":"2016-05-08T09:47:34Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"While at there, improve the error message to say _what_ failed to\nremove.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/worktree.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex d8e3795..331ecf6 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -110,7 +110,7 @@ static void prune_worktrees(void)\n \t\tif (ret < 0 && errno == ENOTDIR)\n \t\t\tret = unlink(path.buf);\n \t\tif (ret)\n-\t\t\terror(_(\"failed to remove: %s\"), strerror(errno));\n+\t\t\terror_errno(_(\"failed to remove '%s'\"), path.buf);\n \t}\n \tclosedir(dir);\n \tif (!show_only)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285851","messageId":"1462700881-25108-16-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 15/41] check-racy.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:35Z","receivedAt":"2016-05-08T09:47:35Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n check-racy.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/check-racy.c b/check-racy.c\nindex 00d92a1..24b6542 100644\n--- a/check-racy.c\n+++ b/check-racy.c\n@@ -12,7 +12,7 @@ int main(int ac, char **av)\n \t\tstruct stat st;\n \n \t\tif (lstat(ce->name, &st)) {\n-\t\t\terror(\"lstat(%s): %s\", ce->name, strerror(errno));\n+\t\t\terror_errno(\"lstat(%s)\", ce->name);\n \t\t\tcontinue;\n \t\t}\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285848","messageId":"1462700881-25108-17-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 16/41] combine-diff.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:36Z","receivedAt":"2016-05-08T09:47:36Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n combine-diff.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 0e1d4b0..8f2313d 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -1005,8 +1005,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\tstruct strbuf buf = STRBUF_INIT;\n \n \t\t\tif (strbuf_readlink(&buf, elem->path, st.st_size) < 0) {\n-\t\t\t\terror(\"readlink(%s): %s\", elem->path,\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(\"readlink(%s)\", elem->path);\n \t\t\t\treturn;\n \t\t\t}\n \t\t\tresult_size = buf.len;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285857","messageId":"1462700881-25108-18-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 17/41] compat/win32/syslog.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:37Z","receivedAt":"2016-05-08T09:47:37Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n compat/win32/syslog.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/compat/win32/syslog.c b/compat/win32/syslog.c\nindex b905aea..6c7c9b6 100644\n--- a/compat/win32/syslog.c\n+++ b/compat/win32/syslog.c\n@@ -28,13 +28,13 @@ void syslog(int priority, const char *fmt, ...)\n \tva_end(ap);\n \n \tif (str_len < 0) {\n-\t\twarning(\"vsnprintf failed: '%s'\", strerror(errno));\n+\t\twarning_errno(\"vsnprintf failed\");\n \t\treturn;\n \t}\n \n \tstr = malloc(st_add(str_len, 1));\n \tif (!str) {\n-\t\twarning(\"malloc failed: '%s'\", strerror(errno));\n+\t\twarning_errno(\"malloc failed\");\n \t\treturn;\n \t}\n \n@@ -45,7 +45,7 @@ void syslog(int priority, const char *fmt, ...)\n \twhile ((pos = strstr(str, \"%1\")) != NULL) {\n \t\tstr = realloc(str, st_add(++str_len, 1));\n \t\tif (!str) {\n-\t\t\twarning(\"realloc failed: '%s'\", strerror(errno));\n+\t\t\twarning_errno(\"realloc failed\");\n \t\t\treturn;\n \t\t}\n \t\tmemmove(pos + 2, pos + 1, strlen(pos));\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285858","messageId":"1462700881-25108-19-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 18/41] config.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:38Z","receivedAt":"2016-05-08T09:47:38Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n config.c | 22 +++++++++-------------\n 1 file changed, 9 insertions(+), 13 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex 10b5c95..80411e4 100644\n--- a/config.c\n+++ b/config.c\n@@ -2012,7 +2012,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \tlock = xcalloc(1, sizeof(struct lock_file));\n \tfd = hold_lock_file_for_update(lock, config_filename, 0);\n \tif (fd < 0) {\n-\t\terror(\"could not lock config file %s: %s\", config_filename, strerror(errno));\n+\t\terror_errno(\"could not lock config file %s\", config_filename);\n \t\tfree(store.key);\n \t\tret = CONFIG_NO_LOCK;\n \t\tgoto out_free;\n@@ -2026,8 +2026,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t\tfree(store.key);\n \n \t\tif ( ENOENT != errno ) {\n-\t\t\terror(\"opening %s: %s\", config_filename,\n-\t\t\t      strerror(errno));\n+\t\t\terror_errno(\"opening %s\", config_filename);\n \t\t\tret = CONFIG_INVALID_FILE; /* same as \"invalid config file\" */\n \t\t\tgoto out_free;\n \t\t}\n@@ -2111,8 +2110,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t\tif (contents == MAP_FAILED) {\n \t\t\tif (errno == ENODEV && S_ISDIR(st.st_mode))\n \t\t\t\terrno = EISDIR;\n-\t\t\terror(\"unable to mmap '%s': %s\",\n-\t\t\t      config_filename, strerror(errno));\n+\t\t\terror_errno(\"unable to mmap '%s'\", config_filename);\n \t\t\tret = CONFIG_INVALID_FILE;\n \t\t\tcontents = NULL;\n \t\t\tgoto out_free;\n@@ -2121,8 +2119,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t\tin_fd = -1;\n \n \t\tif (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {\n-\t\t\terror(\"chmod on %s failed: %s\",\n-\t\t\t      get_lock_file_path(lock), strerror(errno));\n+\t\t\terror_errno(\"chmod on %s failed\", get_lock_file_path(lock));\n \t\t\tret = CONFIG_NO_WRITE;\n \t\t\tgoto out_free;\n \t\t}\n@@ -2178,8 +2175,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,\n \t}\n \n \tif (commit_lock_file(lock) < 0) {\n-\t\terror(\"could not write config file %s: %s\", config_filename,\n-\t\t      strerror(errno));\n+\t\terror_errno(\"could not write config file %s\", config_filename);\n \t\tret = CONFIG_NO_WRITE;\n \t\tlock = NULL;\n \t\tgoto out_free;\n@@ -2330,8 +2326,8 @@ int git_config_rename_section_in_file(const char *config_filename,\n \tfstat(fileno(config_file), &st);\n \n \tif (chmod(get_lock_file_path(lock), st.st_mode & 07777) < 0) {\n-\t\tret = error(\"chmod on %s failed: %s\",\n-\t\t\t    get_lock_file_path(lock), strerror(errno));\n+\t\tret = error_errno(\"chmod on %s failed\",\n+\t\t\t\t  get_lock_file_path(lock));\n \t\tgoto out;\n \t}\n \n@@ -2385,8 +2381,8 @@ int git_config_rename_section_in_file(const char *config_filename,\n \tfclose(config_file);\n unlock_and_out:\n \tif (commit_lock_file(lock) < 0)\n-\t\tret = error(\"could not write config file %s: %s\",\n-\t\t\t    config_filename, strerror(errno));\n+\t\tret = error_errno(\"could not write config file %s\",\n+\t\t\t\t  config_filename);\n out:\n \tfree(filename_buf);\n \treturn ret;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285861","messageId":"1462700881-25108-20-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 19/41] connected.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:39Z","receivedAt":"2016-05-08T09:47:39Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n connected.c | 9 +++------\n 1 file changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/connected.c b/connected.c\nindex 299c560..bf1b12e 100644\n--- a/connected.c\n+++ b/connected.c\n@@ -86,17 +86,14 @@ static int check_everything_connected_real(sha1_iterate_fn fn,\n \t\tmemcpy(commit, sha1_to_hex(sha1), 40);\n \t\tif (write_in_full(rev_list.in, commit, 41) < 0) {\n \t\t\tif (errno != EPIPE && errno != EINVAL)\n-\t\t\t\terror(_(\"failed write to rev-list: %s\"),\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(_(\"failed write to rev-list\"));\n \t\t\terr = -1;\n \t\t\tbreak;\n \t\t}\n \t} while (!fn(cb_data, sha1));\n \n-\tif (close(rev_list.in)) {\n-\t\terror(_(\"failed to close rev-list's stdin: %s\"), strerror(errno));\n-\t\terr = -1;\n-\t}\n+\tif (close(rev_list.in))\n+\t\terr = error_errno(_(\"failed to close rev-list's stdin\"));\n \n \tsigchain_pop(SIGPIPE);\n \treturn finish_command(&rev_list) || err;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285855","messageId":"1462700881-25108-21-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 20/41] copy.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:40Z","receivedAt":"2016-05-08T09:47:40Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n copy.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/copy.c b/copy.c\nindex 574fa1f..4de6a11 100644\n--- a/copy.c\n+++ b/copy.c\n@@ -42,15 +42,15 @@ int copy_file(const char *dst, const char *src, int mode)\n \tstatus = copy_fd(fdi, fdo);\n \tswitch (status) {\n \tcase COPY_READ_ERROR:\n-\t\terror(\"copy-fd: read returned %s\", strerror(errno));\n+\t\terror_errno(\"copy-fd: read returned\");\n \t\tbreak;\n \tcase COPY_WRITE_ERROR:\n-\t\terror(\"copy-fd: write returned %s\", strerror(errno));\n+\t\terror_errno(\"copy-fd: write returned\");\n \t\tbreak;\n \t}\n \tclose(fdi);\n \tif (close(fdo) != 0)\n-\t\treturn error(\"%s: close error: %s\", dst, strerror(errno));\n+\t\treturn error_errno(\"%s: close error\", dst);\n \n \tif (!status && adjust_shared_perm(dst))\n \t\treturn -1;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285856","messageId":"1462700881-25108-22-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 21/41] credential-cache--daemon.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:41Z","receivedAt":"2016-05-08T09:47:41Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n credential-cache--daemon.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/credential-cache--daemon.c b/credential-cache--daemon.c\nindex 291c0fd..1f14d56 100644\n--- a/credential-cache--daemon.c\n+++ b/credential-cache--daemon.c\n@@ -179,12 +179,12 @@ static int serve_cache_loop(int fd)\n \n \t\tclient = accept(fd, NULL, NULL);\n \t\tif (client < 0) {\n-\t\t\twarning(\"accept failed: %s\", strerror(errno));\n+\t\t\twarning_errno(\"accept failed\");\n \t\t\treturn 1;\n \t\t}\n \t\tclient2 = dup(client);\n \t\tif (client2 < 0) {\n-\t\t\twarning(\"dup failed: %s\", strerror(errno));\n+\t\t\twarning_errno(\"dup failed\");\n \t\t\tclose(client);\n \t\t\treturn 1;\n \t\t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285859","messageId":"1462700881-25108-23-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 22/41] diff-no-index.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:42Z","receivedAt":"2016-05-08T09:47:42Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n diff-no-index.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/diff-no-index.c b/diff-no-index.c\nindex 03daadb..1f8999b 100644\n--- a/diff-no-index.c\n+++ b/diff-no-index.c\n@@ -65,8 +65,7 @@ static int populate_from_stdin(struct diff_filespec *s)\n \tsize_t size = 0;\n \n \tif (strbuf_read(&buf, 0, 0) < 0)\n-\t\treturn error(\"error while reading from stdin %s\",\n-\t\t\t\t     strerror(errno));\n+\t\treturn error_errno(\"error while reading from stdin\");\n \n \ts->should_munmap = 0;\n \ts->data = strbuf_detach(&buf, &size);\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285852","messageId":"1462700881-25108-24-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 23/41] editor.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:43Z","receivedAt":"2016-05-08T09:47:43Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n editor.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/editor.c b/editor.c\nindex 01c644c..7519ede 100644\n--- a/editor.c\n+++ b/editor.c\n@@ -63,7 +63,6 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en\n \tif (!buffer)\n \t\treturn 0;\n \tif (strbuf_read_file(buffer, path, 0) < 0)\n-\t\treturn error(\"could not read file '%s': %s\",\n-\t\t\t\tpath, strerror(errno));\n+\t\treturn error_errno(\"could not read file '%s'\", path);\n \treturn 0;\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285862","messageId":"1462700881-25108-25-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 24/41] entry.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:44Z","receivedAt":"2016-05-08T09:47:44Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n entry.c | 10 ++++------\n 1 file changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/entry.c b/entry.c\nindex a410957..519e042 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -168,8 +168,8 @@ static int write_entry(struct cache_entry *ce,\n \t\t\tret = symlink(new, path);\n \t\t\tfree(new);\n \t\t\tif (ret)\n-\t\t\t\treturn error(\"unable to create symlink %s (%s)\",\n-\t\t\t\t\t     path, strerror(errno));\n+\t\t\t\treturn error_errno(\"unable to create symlink %s\",\n+\t\t\t\t\t\t   path);\n \t\t\tbreak;\n \t\t}\n \n@@ -186,8 +186,7 @@ static int write_entry(struct cache_entry *ce,\n \t\tfd = open_output_fd(path, ce, to_tempfile);\n \t\tif (fd < 0) {\n \t\t\tfree(new);\n-\t\t\treturn error(\"unable to create file %s (%s)\",\n-\t\t\t\tpath, strerror(errno));\n+\t\t\treturn error_errno(\"unable to create file %s\", path);\n \t\t}\n \n \t\twrote = write_in_full(fd, new, size);\n@@ -284,8 +283,7 @@ int checkout_entry(struct cache_entry *ce,\n \t\t\t\treturn error(\"%s is a directory\", path.buf);\n \t\t\tremove_subtree(&path);\n \t\t} else if (unlink(path.buf))\n-\t\t\treturn error(\"unable to unlink old '%s' (%s)\",\n-\t\t\t\t     path.buf, strerror(errno));\n+\t\t\treturn error_errno(\"unable to unlink old '%s'\", path.buf);\n \t} else if (state->not_new)\n \t\treturn 0;\n \n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285863","messageId":"1462700881-25108-26-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 25/41] fast-import.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:45Z","receivedAt":"2016-05-08T09:47:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n fast-import.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 9fc7093..21881d1 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -414,7 +414,7 @@ static void write_crash_report(const char *err)\n \tstruct recent_command *rc;\n \n \tif (!rpt) {\n-\t\terror(\"can't write crash report %s: %s\", loc, strerror(errno));\n+\t\terror_errno(\"can't write crash report %s\", loc);\n \t\tfree(loc);\n \t\treturn;\n \t}\n@@ -1806,8 +1806,8 @@ static void dump_marks(void)\n \t\treturn;\n \n \tif (hold_lock_file_for_update(&mark_lock, export_marks_file, 0) < 0) {\n-\t\tfailure |= error(\"Unable to write marks file %s: %s\",\n-\t\t\texport_marks_file, strerror(errno));\n+\t\tfailure |= error_errno(\"Unable to write marks file %s\",\n+\t\t\t\t       export_marks_file);\n \t\treturn;\n \t}\n \n@@ -1822,8 +1822,8 @@ static void dump_marks(void)\n \n \tdump_marks_helper(f, 0, marks);\n \tif (commit_lock_file(&mark_lock)) {\n-\t\tfailure |= error(\"Unable to write file %s: %s\",\n-\t\t\texport_marks_file, strerror(errno));\n+\t\tfailure |= error_errno(\"Unable to write file %s\",\n+\t\t\t\t       export_marks_file);\n \t\treturn;\n \t}\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285860","messageId":"1462700881-25108-27-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 26/41] gpg-interface.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:46Z","receivedAt":"2016-05-08T09:47:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n gpg-interface.c | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/gpg-interface.c b/gpg-interface.c\nindex 2259938..c4b1e8c 100644\n--- a/gpg-interface.c\n+++ b/gpg-interface.c\n@@ -219,11 +219,9 @@ int verify_signed_buffer(const char *payload, size_t payload_size,\n \targs_gpg[0] = gpg_program;\n \tfd = git_mkstemp(path, PATH_MAX, \".git_vtag_tmpXXXXXX\");\n \tif (fd < 0)\n-\t\treturn error(_(\"could not create temporary file '%s': %s\"),\n-\t\t\t     path, strerror(errno));\n+\t\treturn error_errno(_(\"could not create temporary file '%s'\"), path);\n \tif (write_in_full(fd, signature, signature_size) < 0)\n-\t\treturn error(_(\"failed writing detached signature to '%s': %s\"),\n-\t\t\t     path, strerror(errno));\n+\t\treturn error_errno(_(\"failed writing detached signature to '%s'\"), path);\n \tclose(fd);\n \n \tgpg.argv = args_gpg;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285853","messageId":"1462700881-25108-28-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 27/41] grep.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:47Z","receivedAt":"2016-05-08T09:47:47Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"While at there, improve the error message a bit (what operation failed?)\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n grep.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 528b652..ec6f7ff 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -1732,7 +1732,7 @@ static int grep_source_load_file(struct grep_source *gs)\n \tif (lstat(filename, &st) < 0) {\n \terr_ret:\n \t\tif (errno != ENOENT)\n-\t\t\terror(_(\"'%s': %s\"), filename, strerror(errno));\n+\t\t\terror_errno(_(\"failed to stat '%s'\"), filename);\n \t\treturn -1;\n \t}\n \tif (!S_ISREG(st.st_mode))\n@@ -1743,7 +1743,7 @@ static int grep_source_load_file(struct grep_source *gs)\n \t\tgoto err_ret;\n \tdata = xmallocz(size);\n \tif (st.st_size != read_in_full(i, data, size)) {\n-\t\terror(_(\"'%s': short read %s\"), filename, strerror(errno));\n+\t\terror_errno(_(\"'%s': short read\"), filename);\n \t\tclose(i);\n \t\tfree(data);\n \t\treturn -1;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285873","messageId":"1462700881-25108-29-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 28/41] http.c: use error_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:48Z","receivedAt":"2016-05-08T09:47:48Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n http.c | 10 ++++------\n 1 file changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 4304b80..7565c93 100644\n--- a/http.c\n+++ b/http.c\n@@ -446,8 +446,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)\n \n \trc = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&ka, len);\n \tif (rc < 0)\n-\t\twarning(\"unable to set SO_KEEPALIVE on socket %s\",\n-\t\t\tstrerror(errno));\n+\t\twarning_errno(\"unable to set SO_KEEPALIVE on socket\");\n \n \treturn 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */\n }\n@@ -1894,8 +1893,7 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \t}\n \n \tif (freq->localfile < 0) {\n-\t\terror(\"Couldn't create temporary file %s: %s\",\n-\t\t      freq->tmpfile, strerror(errno));\n+\t\terror_errno(\"Couldn't create temporary file %s\", freq->tmpfile);\n \t\tgoto abort;\n \t}\n \n@@ -1940,8 +1938,8 @@ struct http_object_request *new_http_object_request(const char *base_url,\n \t\t\tprev_posn = 0;\n \t\t\tlseek(freq->localfile, 0, SEEK_SET);\n \t\t\tif (ftruncate(freq->localfile, 0) < 0) {\n-\t\t\t\terror(\"Couldn't truncate temporary file %s: %s\",\n-\t\t\t\t\t  freq->tmpfile, strerror(errno));\n+\t\t\t\terror_errno(\"Couldn't truncate temporary file %s\",\n+\t\t\t\t\t    freq->tmpfile);\n \t\t\t\tgoto abort;\n \t\t\t}\n \t\t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285877","messageId":"1462700881-25108-30-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 29/41] ident.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:49Z","receivedAt":"2016-05-08T09:47:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n ident.c | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/ident.c b/ident.c\nindex 4fd82d1..139c528 100644\n--- a/ident.c\n+++ b/ident.c\n@@ -75,14 +75,12 @@ static int add_mailname_host(struct strbuf *buf)\n \tmailname = fopen(\"/etc/mailname\", \"r\");\n \tif (!mailname) {\n \t\tif (errno != ENOENT)\n-\t\t\twarning(\"cannot open /etc/mailname: %s\",\n-\t\t\t\tstrerror(errno));\n+\t\t\twarning_errno(\"cannot open /etc/mailname\");\n \t\treturn -1;\n \t}\n \tif (strbuf_getline(&mailnamebuf, mailname) == EOF) {\n \t\tif (ferror(mailname))\n-\t\t\twarning(\"cannot read /etc/mailname: %s\",\n-\t\t\t\tstrerror(errno));\n+\t\t\twarning_errno(\"cannot read /etc/mailname\");\n \t\tstrbuf_release(&mailnamebuf);\n \t\tfclose(mailname);\n \t\treturn -1;\n@@ -125,7 +123,7 @@ static void add_domainname(struct strbuf *out, int *is_bogus)\n \tchar buf[1024];\n \n \tif (gethostname(buf, sizeof(buf))) {\n-\t\twarning(\"cannot get host name: %s\", strerror(errno));\n+\t\twarning_errno(\"cannot get host name\");\n \t\tstrbuf_addstr(out, \"(none)\");\n \t\t*is_bogus = 1;\n \t\treturn;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285854","messageId":"1462700881-25108-31-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 30/41] mailmap.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:50Z","receivedAt":"2016-05-08T09:47:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n mailmap.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/mailmap.c b/mailmap.c\nindex 9726237..b5c521f 100644\n--- a/mailmap.c\n+++ b/mailmap.c\n@@ -189,8 +189,7 @@ static int read_mailmap_file(struct string_list *map, const char *filename,\n \tif (!f) {\n \t\tif (errno == ENOENT)\n \t\t\treturn 0;\n-\t\treturn error(\"unable to open mailmap at %s: %s\",\n-\t\t\t     filename, strerror(errno));\n+\t\treturn error_errno(\"unable to open mailmap at %s\", filename);\n \t}\n \n \twhile (fgets(buffer, sizeof(buffer), f) != NULL)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285867","messageId":"1462700881-25108-32-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 31/41] reachable.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:51Z","receivedAt":"2016-05-08T09:47:51Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n reachable.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/reachable.c b/reachable.c\nindex ed35201..d0199ca 100644\n--- a/reachable.c\n+++ b/reachable.c\n@@ -119,8 +119,7 @@ static int add_recent_loose(const unsigned char *sha1,\n \t\t */\n \t\tif (errno == ENOENT)\n \t\t\treturn 0;\n-\t\treturn error(\"unable to stat %s: %s\",\n-\t\t\t     sha1_to_hex(sha1), strerror(errno));\n+\t\treturn error_errno(\"unable to stat %s\", sha1_to_hex(sha1));\n \t}\n \n \tadd_recent_object(sha1, st.st_mtime, data);\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285874","messageId":"1462700881-25108-33-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 32/41] rerere.c: use error_errno() and warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:52Z","receivedAt":"2016-05-08T09:47:52Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n rerere.c | 18 +++++++-----------\n 1 file changed, 7 insertions(+), 11 deletions(-)\n\ndiff --git a/rerere.c b/rerere.c\nindex c8b9f40..1810c04 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -501,8 +501,7 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output\n \t\terror(\"There were errors while writing %s (%s)\",\n \t\t      path, strerror(io.io.wrerror));\n \tif (io.io.output && fclose(io.io.output))\n-\t\tio.io.wrerror = error(\"Failed to flush %s: %s\",\n-\t\t\t\t      path, strerror(errno));\n+\t\tio.io.wrerror = error_errno(\"Failed to flush %s\", path);\n \n \tif (hunk_no < 0) {\n \t\tif (output)\n@@ -684,20 +683,17 @@ static int merge(const struct rerere_id *id, const char *path)\n \t * Mark that \"postimage\" was used to help gc.\n \t */\n \tif (utime(rerere_path(id, \"postimage\"), NULL) < 0)\n-\t\twarning(\"failed utime() on %s: %s\",\n-\t\t\trerere_path(id, \"postimage\"),\n-\t\t\tstrerror(errno));\n+\t\twarning_errno(\"failed utime() on %s\",\n+\t\t\t      rerere_path(id, \"postimage\"));\n \n \t/* Update \"path\" with the resolution */\n \tf = fopen(path, \"w\");\n \tif (!f)\n-\t\treturn error(\"Could not open %s: %s\", path,\n-\t\t\t     strerror(errno));\n+\t\treturn error_errno(\"Could not open %s\", path);\n \tif (fwrite(result.ptr, result.size, 1, f) != 1)\n-\t\terror(\"Could not write %s: %s\", path, strerror(errno));\n+\t\terror_errno(\"Could not write %s\", path);\n \tif (fclose(f))\n-\t\treturn error(\"Writing %s failed: %s\", path,\n-\t\t\t     strerror(errno));\n+\t\treturn error_errno(\"Writing %s failed\", path);\n \n out:\n \tfree(cur.ptr);\n@@ -1071,7 +1067,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)\n \tif (unlink(filename))\n \t\treturn (errno == ENOENT\n \t\t\t? error(\"no remembered resolution for %s\", path)\n-\t\t\t: error(\"cannot unlink %s: %s\", filename, strerror(errno)));\n+\t\t\t: error_errno(\"cannot unlink %s\", filename));\n \n \t/*\n \t * Update the preimage so that the user can resolve the\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285875","messageId":"1462700881-25108-34-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 33/41] run-command.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:53Z","receivedAt":"2016-05-08T09:47:53Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n run-command.c | 15 +++++++--------\n 1 file changed, 7 insertions(+), 8 deletions(-)\n\ndiff --git a/run-command.c b/run-command.c\nindex e4593cd..842c8d1 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -233,7 +233,7 @@ static int wait_or_whine(pid_t pid, const char *argv0, int in_signal)\n \n \tif (waiting < 0) {\n \t\tfailed_errno = errno;\n-\t\terror(\"waitpid for %s failed: %s\", argv0, strerror(errno));\n+\t\terror_errno(\"waitpid for %s failed\", argv0);\n \t} else if (waiting != pid) {\n \t\terror(\"waitpid is confused (%s)\", argv0);\n \t} else if (WIFSIGNALED(status)) {\n@@ -420,8 +420,7 @@ fail_pipe:\n \t\t}\n \t}\n \tif (cmd->pid < 0)\n-\t\terror(\"cannot fork() for %s: %s\", cmd->argv[0],\n-\t\t\tstrerror(errno));\n+\t\terror_errno(\"cannot fork() for %s\", cmd->argv[0]);\n \telse if (cmd->clean_on_exit)\n \t\tmark_child_for_cleanup(cmd->pid);\n \n@@ -482,7 +481,7 @@ fail_pipe:\n \t\t\tcmd->dir, fhin, fhout, fherr);\n \tfailed_errno = errno;\n \tif (cmd->pid < 0 && (!cmd->silent_exec_failure || errno != ENOENT))\n-\t\terror(\"cannot spawn %s: %s\", cmd->argv[0], strerror(errno));\n+\t\terror_errno(\"cannot spawn %s\", cmd->argv[0]);\n \tif (cmd->clean_on_exit && cmd->pid >= 0)\n \t\tmark_child_for_cleanup(cmd->pid);\n \n@@ -703,7 +702,7 @@ int start_async(struct async *async)\n \t\tif (pipe(fdin) < 0) {\n \t\t\tif (async->out > 0)\n \t\t\t\tclose(async->out);\n-\t\t\treturn error(\"cannot create pipe: %s\", strerror(errno));\n+\t\t\treturn error_errno(\"cannot create pipe\");\n \t\t}\n \t\tasync->in = fdin[1];\n \t}\n@@ -715,7 +714,7 @@ int start_async(struct async *async)\n \t\t\t\tclose_pair(fdin);\n \t\t\telse if (async->in)\n \t\t\t\tclose(async->in);\n-\t\t\treturn error(\"cannot create pipe: %s\", strerror(errno));\n+\t\t\treturn error_errno(\"cannot create pipe\");\n \t\t}\n \t\tasync->out = fdout[0];\n \t}\n@@ -740,7 +739,7 @@ int start_async(struct async *async)\n \n \tasync->pid = fork();\n \tif (async->pid < 0) {\n-\t\terror(\"fork (async) failed: %s\", strerror(errno));\n+\t\terror_errno(\"fork (async) failed\");\n \t\tgoto error;\n \t}\n \tif (!async->pid) {\n@@ -787,7 +786,7 @@ int start_async(struct async *async)\n \t{\n \t\tint err = pthread_create(&async->tid, NULL, run_thread, async);\n \t\tif (err) {\n-\t\t\terror(\"cannot create thread: %s\", strerror(err));\n+\t\t\terror_errno(\"cannot create thread\");\n \t\t\tgoto error;\n \t\t}\n \t}\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285870","messageId":"1462700881-25108-35-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 34/41] sequencer.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:54Z","receivedAt":"2016-05-08T09:47:54Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n sequencer.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex e66f2fe..4687ad4 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -875,8 +875,7 @@ static int sequencer_rollback(struct replay_opts *opts)\n \t\treturn rollback_single_pick();\n \t}\n \tif (!f)\n-\t\treturn error(_(\"cannot open %s: %s\"), git_path_head_file(),\n-\t\t\t\t\t\tstrerror(errno));\n+\t\treturn error_errno(_(\"cannot open %s\"), git_path_head_file());\n \tif (strbuf_getline_lf(&buf, f)) {\n \t\terror(_(\"cannot read %s: %s\"), git_path_head_file(),\n \t\t      ferror(f) ?  strerror(errno) : _(\"unexpected end of file\"));\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285878","messageId":"1462700881-25108-36-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 35/41] server-info.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:55Z","receivedAt":"2016-05-08T09:47:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n server-info.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/server-info.c b/server-info.c\nindex 5a86e29..75dd677 100644\n--- a/server-info.c\n+++ b/server-info.c\n@@ -36,7 +36,7 @@ static int update_info_file(char *path, int (*generate)(FILE *))\n \n out:\n \tif (ret) {\n-\t\terror(\"unable to update %s: %s\", path, strerror(errno));\n+\t\terror_errno(\"unable to update %s\", path);\n \t\tif (fp)\n \t\t\tfclose(fp);\n \t\telse if (fd >= 0)\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285871","messageId":"1462700881-25108-37-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 36/41] sha1_file.c: use {error,die,warning}_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:56Z","receivedAt":"2016-05-08T09:47:56Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n sha1_file.c | 32 +++++++++++++-------------------\n 1 file changed, 13 insertions(+), 19 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex d0f2aa0..a7f45b3 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1107,9 +1107,8 @@ unsigned char *use_pack(struct packed_git *p,\n \t\t\t\tPROT_READ, MAP_PRIVATE,\n \t\t\t\tp->pack_fd, win->offset);\n \t\t\tif (win->base == MAP_FAILED)\n-\t\t\t\tdie(\"packfile %s cannot be mapped: %s\",\n-\t\t\t\t\tp->pack_name,\n-\t\t\t\t\tstrerror(errno));\n+\t\t\t\tdie_errno(\"packfile %s cannot be mapped\",\n+\t\t\t\t\t  p->pack_name);\n \t\t\tif (!win->offset && win->len == p->pack_size\n \t\t\t\t&& !p->do_not_close)\n \t\t\t\tclose_pack_fd(p);\n@@ -1279,8 +1278,8 @@ static void prepare_packed_git_one(char *objdir, int local)\n \tdir = opendir(path.buf);\n \tif (!dir) {\n \t\tif (errno != ENOENT)\n-\t\t\terror(\"unable to open object pack directory: %s: %s\",\n-\t\t\t      path.buf, strerror(errno));\n+\t\t\terror_errno(\"unable to open object pack directory: %s\",\n+\t\t\t\t    path.buf);\n \t\tstrbuf_release(&path);\n \t\treturn;\n \t}\n@@ -2984,7 +2983,7 @@ int finalize_object_file(const char *tmpfile, const char *filename)\n \tunlink_or_warn(tmpfile);\n \tif (ret) {\n \t\tif (ret != EEXIST) {\n-\t\t\treturn error(\"unable to write sha1 filename %s: %s\", filename, strerror(ret));\n+\t\t\treturn error_errno(\"unable to write sha1 filename %s\", filename);\n \t\t}\n \t\t/* FIXME!!! Collision check here ? */\n \t}\n@@ -2998,7 +2997,7 @@ out:\n static int write_buffer(int fd, const void *buf, size_t len)\n {\n \tif (write_in_full(fd, buf, len) < 0)\n-\t\treturn error(\"file write error (%s)\", strerror(errno));\n+\t\treturn error_errno(\"file write error\");\n \treturn 0;\n }\n \n@@ -3081,7 +3080,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,\n \t\tif (errno == EACCES)\n \t\t\treturn error(\"insufficient permission for adding an object to repository database %s\", get_object_directory());\n \t\telse\n-\t\t\treturn error(\"unable to create temporary file: %s\", strerror(errno));\n+\t\t\treturn error_errno(\"unable to create temporary file\");\n \t}\n \n \t/* Set it up */\n@@ -3126,8 +3125,7 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,\n \t\tutb.actime = mtime;\n \t\tutb.modtime = mtime;\n \t\tif (utime(tmp_file.buf, &utb) < 0)\n-\t\t\twarning(\"failed utime() on %s: %s\",\n-\t\t\t\ttmp_file.buf, strerror(errno));\n+\t\t\twarning_errno(\"failed utime() on %s\", tmp_file.buf);\n \t}\n \n \treturn finalize_object_file(tmp_file.buf, filename);\n@@ -3360,7 +3358,7 @@ static int index_core(unsigned char *sha1, int fd, size_t size,\n \t\tif (size == read_in_full(fd, buf, size))\n \t\t\tret = index_mem(sha1, buf, size, type, path, flags);\n \t\telse\n-\t\t\tret = error(\"short read %s\", strerror(errno));\n+\t\t\tret = error_errno(\"short read\");\n \t\tfree(buf);\n \t} else {\n \t\tvoid *buf = xmmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);\n@@ -3425,18 +3423,14 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned\n \tcase S_IFREG:\n \t\tfd = open(path, O_RDONLY);\n \t\tif (fd < 0)\n-\t\t\treturn error(\"open(\\\"%s\\\"): %s\", path,\n-\t\t\t\t     strerror(errno));\n+\t\t\treturn error_errno(\"open(\\\"%s\\\")\", path);\n \t\tif (index_fd(sha1, fd, st, OBJ_BLOB, path, flags) < 0)\n \t\t\treturn error(\"%s: failed to insert into database\",\n \t\t\t\t     path);\n \t\tbreak;\n \tcase S_IFLNK:\n-\t\tif (strbuf_readlink(&sb, path, st->st_size)) {\n-\t\t\tchar *errstr = strerror(errno);\n-\t\t\treturn error(\"readlink(\\\"%s\\\"): %s\", path,\n-\t\t\t             errstr);\n-\t\t}\n+\t\tif (strbuf_readlink(&sb, path, st->st_size))\n+\t\t\treturn error_errno(\"readlink(\\\"%s\\\")\", path);\n \t\tif (!(flags & HASH_WRITE_OBJECT))\n \t\t\thash_sha1_file(sb.buf, sb.len, blob_type, sha1);\n \t\telse if (write_sha1_file(sb.buf, sb.len, blob_type, sha1))\n@@ -3492,7 +3486,7 @@ static int for_each_file_in_obj_subdir(int subdir_nr,\n \tif (!dir) {\n \t\tif (errno == ENOENT)\n \t\t\treturn 0;\n-\t\treturn error(\"unable to open %s: %s\", path->buf, strerror(errno));\n+\t\treturn error_errno(\"unable to open %s\", path->buf);\n \t}\n \n \twhile ((de = readdir(dir))) {\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285869","messageId":"1462700881-25108-38-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 37/41] transport-helper.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:57Z","receivedAt":"2016-05-08T09:47:57Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n transport-helper.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/transport-helper.c b/transport-helper.c\nindex b934183..f09fadc 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -1166,7 +1166,7 @@ static int udt_do_read(struct unidirectional_transfer *t)\n \tbytes = read(t->src, t->buf + t->bufuse, BUFFERSIZE - t->bufuse);\n \tif (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN &&\n \t\terrno != EINTR) {\n-\t\terror(\"read(%s) failed: %s\", t->src_name, strerror(errno));\n+\t\terror_errno(\"read(%s) failed\", t->src_name);\n \t\treturn -1;\n \t} else if (bytes == 0) {\n \t\ttransfer_debug(\"%s EOF (with %i bytes in buffer)\",\n@@ -1193,7 +1193,7 @@ static int udt_do_write(struct unidirectional_transfer *t)\n \ttransfer_debug(\"%s is writable\", t->dest_name);\n \tbytes = xwrite(t->dest, t->buf, t->bufuse);\n \tif (bytes < 0 && errno != EWOULDBLOCK) {\n-\t\terror(\"write(%s) failed: %s\", t->dest_name, strerror(errno));\n+\t\terror_errno(\"write(%s) failed\", t->dest_name);\n \t\treturn -1;\n \t} else if (bytes > 0) {\n \t\tt->bufuse -= bytes;\n@@ -1306,7 +1306,7 @@ static int tloop_join(pid_t pid, const char *name)\n {\n \tint tret;\n \tif (waitpid(pid, &tret, 0) < 0) {\n-\t\terror(\"%s process failed to wait: %s\", name, strerror(errno));\n+\t\terror_errno(\"%s process failed to wait\", name);\n \t\treturn 1;\n \t}\n \tif (!WIFEXITED(tret) || WEXITSTATUS(tret)) {\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285872","messageId":"1462700881-25108-39-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 38/41] unpack-trees.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:58Z","receivedAt":"2016-05-08T09:47:58Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n unpack-trees.c | 6 ++----\n 1 file changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 9f55cc2..bb0d142 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -1499,8 +1499,7 @@ static int verify_absent_1(const struct cache_entry *ce,\n \n \t\tpath = xmemdupz(ce->name, len);\n \t\tif (lstat(path, &st))\n-\t\t\tret = error(\"cannot stat '%s': %s\", path,\n-\t\t\t\t\tstrerror(errno));\n+\t\t\tret = error_errno(\"cannot stat '%s'\", path);\n \t\telse\n \t\t\tret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,\n \t\t\t\t\t\t &st, error_type, o);\n@@ -1508,8 +1507,7 @@ static int verify_absent_1(const struct cache_entry *ce,\n \t\treturn ret;\n \t} else if (lstat(ce->name, &st)) {\n \t\tif (errno != ENOENT)\n-\t\t\treturn error(\"cannot stat '%s': %s\", ce->name,\n-\t\t\t\t     strerror(errno));\n+\t\t\treturn error_errno(\"cannot stat '%s'\", ce->name);\n \t\treturn 0;\n \t} else {\n \t\treturn check_ok_to_remove(ce->name, ce_namelen(ce),\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285879","messageId":"1462700881-25108-40-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 39/41] upload-pack.c: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:47:59Z","receivedAt":"2016-05-08T09:47:59Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n upload-pack.c | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/upload-pack.c b/upload-pack.c\nindex dc802a0..f19444d 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -174,8 +174,7 @@ static void create_pack_file(void)\n \n \t\tif (ret < 0) {\n \t\t\tif (errno != EINTR) {\n-\t\t\t\terror(\"poll failed, resuming: %s\",\n-\t\t\t\t      strerror(errno));\n+\t\t\t\terror_errno(\"poll failed, resuming\");\n \t\t\t\tsleep(1);\n \t\t\t}\n \t\t\tcontinue;\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285876","messageId":"1462700881-25108-41-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 40/41] vcs-svn: use error_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:48:00Z","receivedAt":"2016-05-08T09:48:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n vcs-svn/line_buffer.c    | 4 ++--\n vcs-svn/sliding_window.c | 2 +-\n vcs-svn/svndiff.c        | 4 ++--\n vcs-svn/svndump.c        | 4 ++--\n 4 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/vcs-svn/line_buffer.c b/vcs-svn/line_buffer.c\nindex 57cc1ce..e416caf 100644\n--- a/vcs-svn/line_buffer.c\n+++ b/vcs-svn/line_buffer.c\n@@ -53,9 +53,9 @@ long buffer_tmpfile_prepare_to_read(struct line_buffer *buf)\n {\n \tlong pos = ftell(buf->infile);\n \tif (pos < 0)\n-\t\treturn error(\"ftell error: %s\", strerror(errno));\n+\t\treturn error_errno(\"ftell error\");\n \tif (fseek(buf->infile, 0, SEEK_SET))\n-\t\treturn error(\"seek error: %s\", strerror(errno));\n+\t\treturn error_errno(\"seek error\");\n \treturn pos;\n }\n \ndiff --git a/vcs-svn/sliding_window.c b/vcs-svn/sliding_window.c\nindex f11d490..06d273c 100644\n--- a/vcs-svn/sliding_window.c\n+++ b/vcs-svn/sliding_window.c\n@@ -12,7 +12,7 @@ static int input_error(struct line_buffer *file)\n {\n \tif (!buffer_ferror(file))\n \t\treturn error(\"delta preimage ends early\");\n-\treturn error(\"cannot read delta preimage: %s\", strerror(errno));\n+\treturn error_errno(\"cannot read delta preimage\");\n }\n \n static int skip_or_whine(struct line_buffer *file, off_t gap)\ndiff --git a/vcs-svn/svndiff.c b/vcs-svn/svndiff.c\nindex 74c97c4..75c7531 100644\n--- a/vcs-svn/svndiff.c\n+++ b/vcs-svn/svndiff.c\n@@ -64,13 +64,13 @@ static int write_strbuf(struct strbuf *sb, FILE *out)\n {\n \tif (fwrite(sb->buf, 1, sb->len, out) == sb->len)\t/* Success. */\n \t\treturn 0;\n-\treturn error(\"cannot write delta postimage: %s\", strerror(errno));\n+\treturn error_errno(\"cannot write delta postimage\");\n }\n \n static int error_short_read(struct line_buffer *input)\n {\n \tif (buffer_ferror(input))\n-\t\treturn error(\"error reading delta: %s\", strerror(errno));\n+\t\treturn error_errno(\"error reading delta\");\n \treturn error(\"invalid delta: unexpected end of file\");\n }\n \ndiff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c\nindex 31d1d83..e4b3959 100644\n--- a/vcs-svn/svndump.c\n+++ b/vcs-svn/svndump.c\n@@ -501,7 +501,7 @@ static void init(int report_fd)\n int svndump_init(const char *filename)\n {\n \tif (buffer_init(&input, filename))\n-\t\treturn error(\"cannot open %s: %s\", filename ? filename : \"NULL\", strerror(errno));\n+\t\treturn error_errno(\"cannot open %s\", filename ? filename : \"NULL\");\n \tinit(REPORT_FILENO);\n \treturn 0;\n }\n@@ -509,7 +509,7 @@ int svndump_init(const char *filename)\n int svndump_init_fd(int in_fd, int back_fd)\n {\n \tif(buffer_fdinit(&input, xdup(in_fd)))\n-\t\treturn error(\"cannot open fd %d: %s\", in_fd, strerror(errno));\n+\t\treturn error_errno(\"cannot open fd %d\", in_fd);\n \tinit(xdup(back_fd));\n \treturn 0;\n }\n-- \n2.8.0.rc0.210.gd302cd2\n"},{"id":"285866","messageId":"1462700881-25108-42-git-send-email-pclouds@gmail.com","threadId":"42194","inReplyTo":"1462700881-25108-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v3 41/41] wrapper.c: use warning_errno()","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2016-05-08T09:48:01Z","receivedAt":"2016-05-08T09:48:01Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n wrapper.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/wrapper.c b/wrapper.c\nindex 9afc1a0..3df2fe0 100644\n--- a/wrapper.c\n+++ b/wrapper.c\n@@ -572,7 +572,7 @@ static int warn_if_unremovable(const char *op, const char *file, int rc)\n \tif (!rc || errno == ENOENT)\n \t\treturn 0;\n \terr = errno;\n-\twarning(\"unable to %s %s: %s\", op, file, strerror(errno));\n+\twarning_errno(\"unable to %s %s\", op, file);\n \terrno = err;\n \treturn rc;\n }\n@@ -608,7 +608,7 @@ int remove_or_warn(unsigned int mode, const char *file)\n \n void warn_on_inaccessible(const char *path)\n {\n-\twarning(_(\"unable to access '%s': %s\"), path, strerror(errno));\n+\twarning_errno(_(\"unable to access '%s'\"), path);\n }\n \n static int access_error_is_ok(int err, unsigned flag)\n-- \n2.8.0.rc0.210.gd302cd2\n"}]}