From: Jeff King <peff@peff.net>
To: 牛旭 <niuxu16@nudt.edu.cn>
Cc: git <git@vger.kernel.org>
Subject: Re: Recommendations for updating error() to error_errno()
Date: Wed, 17 Oct 2018 04:44:43 -0400 [thread overview]
Message-ID: <20181017084443.GD31932@sigill.intra.peff.net> (raw)
In-Reply-To: <6849fb3c.10199.166802c8ef3.Coremail.niuxu16@nudt.edu.cn>
On Wed, Oct 17, 2018 at 11:58:15AM +0800, 牛旭 wrote:
> Our team works on enhance logging practices by learning from historical log revisions in evolution.
> And we find three patches that update error(..., strerror(errmp)) to error_errno(...).
>
> While applying this rule to git-2.14.2, we find 9 missed spot in file refs/files-backend.c, 1 in apply.c, 2 in trace.c, 4 in dir-iterator.c:.
>
> Here are the missed spots:
> 1) Line 1734 in file git-2.14.2/refs/files-backend.c:
> ret = raceproof_create_file(path.buf, rename_tmp_log_callback, &cb);
> if (ret) {
> if (errno == EISDIR)
> error("directory not empty: %s", path.buf);
> else
> error("unable to move logfile %s to %s: %s",
> tmp.buf, path.buf,
> strerror(cb.true_errno));
This cannot be converted naively. Using error_errno() will always show
the value of "errno", but here we are using a saved value in
cb.true_errno.
It might work to do:
errno = cb.true_errno;
error_errno(...);
but you would first have to check if the function is depending on the
value of errno for other reasons (not to mention that it kind of defeats
the purpose of error_errno() being a shorthand).
> 2) Line 1795 in file git-2.14.2/refs/files-backend.c:
> if (log && rename(sb_oldref.buf, tmp_renamed_log.buf)) {
> ret = error("unable to move logfile logs/%s to logs/"TMP_RENAMED_LOG": %s",
> oldrefname, strerror(errno));
> goto out;
> }
But this one, for example, would be fine.
-Peff
prev parent reply other threads:[~2018-10-17 8:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-17 3:58 Recommendations for updating error() to error_errno() 牛旭
2018-10-17 8:44 ` Jeff King [this message]
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=20181017084443.GD31932@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).