git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: 牛旭 <niuxu16@nudt.edu.cn>
To: git@vger.kernel.org
Subject: Patch recommendation for replace invoke of error() to that of error_errno()
Date: Fri, 5 Jan 2018 11:24:02 +0800 (GMT+08:00)	[thread overview]
Message-ID: <950adae.6741.160c458ce64.Coremail.niuxu16@nudt.edu.cn> (raw)

[-- Attachment #1: Type: text/plain, Size: 1481 bytes --]

Our team researches on consistent update of Git during evolution. And we have figured out several spots that may be missed. 


By mining historical patches, we suggest that invokes of error(..., strerror(errno)) should be replaced with that of error_errno(). One example for recommendation and corresponding patch are listed as follows. 

One example of missed spot:

1  int cmd_fetch__tool(int argc, const char **argv, const char 
  *prefix)
2  {
....
31  filename = git_path_fetch_head();
32  fp = fopen(filename, "a");
33  if (!fp)
34  return error("cannot open %s: %s", filename, strerror(errno));
....
  }

One example of historical patch:
1  if (!strcmp(*paths, "-"))
2  in = stdin;
3  else
4  in = fopen(*paths, "r");
5
6  if (!in)
7  -  return error(_("could not open '%s' for reading: %s"),
8  -     *paths, strerror(errno));
9  +  return error_errno(_("could not open '%s' for reading"),
10 +     *paths);
11
12 mail = mkpath("%s/%0*d", state->dir, state->prec, i + 1);
13
14 out = fopen(mail, "w");
15 if (!out)
16 - return error(_("could not open '%s' for writing: %s"),
17 - mail, strerror(errno));
18 + return error_errno(_("could not open '%s' for writing"),
19 + mail);
20
21 ret = fn(out, in, keep_cr);
22
23 fclose(out);
24 fclose(in);
25
More recommendations and supporting patches are saved in attachments. It is so kind of you to reply me about the correctness of our suggestions. And thank you for your reading. 

[-- Attachment #2: Git-recommendation-example-0.doc --]
[-- Type: application/msword, Size: 13312 bytes --]

[-- Attachment #3: Git-patch-example-0.doc --]
[-- Type: application/msword, Size: 27648 bytes --]

             reply	other threads:[~2018-01-05  3:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-05  3:24 牛旭 [this message]
2018-01-05  7:04 ` Patch recommendation for replace invoke of error() to that of error_errno() Jeff King
2018-01-28 15:46 ` recommendations for log enhancement 牛旭
2018-01-30 22:11   ` Stefan Beller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=950adae.6741.160c458ce64.Coremail.niuxu16@nudt.edu.cn \
    --to=niuxu16@nudt.edu.cn \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).