git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: 牛旭 <niuxu16@nudt.edu.cn>
Cc: git@vger.kernel.org
Subject: Re: Patch recommendation for replace invoke of error() to that of error_errno()
Date: Fri, 5 Jan 2018 02:04:10 -0500	[thread overview]
Message-ID: <20180105070409.GA14251@sigill.intra.peff.net> (raw)
In-Reply-To: <950adae.6741.160c458ce64.Coremail.niuxu16@nudt.edu.cn>

On Fri, Jan 05, 2018 at 11:24:02AM +0800, 牛旭 wrote:

> 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. 

Yes, historically we've done cleanups like this across time as we touch
the various pieces of code. More conversions are welcome as long as they
don't conflict with any topics that other people are working on (a good
test is to see if your suggested changes merge cleanly with the "pu"
branch).

In more recent times, we've been using the Coccinelle tool to do
automated conversions across the code base. Look at the contents and
history of the contrib/coccinelle directory. This might be a candidate
for that cleanup.

> 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));
> ....
>   }

This one is actually a bit funny. It's in contrib/examples, which is all
historical code. It's not compiled or used as part of Git (and I'd
suspect most of it would not compile at all these days). It's not really
worth modernizing.

> 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. 

Eek, word documents. We're happy to take patches, but please format them
as plain text in your email (e.g., by using git-send-email). More
details are in Documentation/SubmittingPatches. Thanks.

-Peff

  reply	other threads:[~2018-01-05  7:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-05  3:24 Patch recommendation for replace invoke of error() to that of error_errno() 牛旭
2018-01-05  7:04 ` Jeff King [this message]
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

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

  git send-email \
    --in-reply-to=20180105070409.GA14251@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=niuxu16@nudt.edu.cn \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).