From: Junio C Hamano <gitster@pobox•com>
To: Clemens Buchacher <clemens.buchacher@intel•com>
Cc: git@vger•kernel.org, "Eric Sunshine" <sunshine@sunshineco•com>,
"Linus Torvalds" <torvalds@linux-foundation•org>,
"Martin Schröder" <martin.h.schroeder@intel•com>
Subject: Re: [PATCH] git_open_noatime: return with errno=0 on success
Date: Tue, 04 Aug 2015 14:03:15 -0700 [thread overview]
Message-ID: <xmqqfv3y6a24.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20150804082429.GA22271@musxeris015.imu.intel.com> (Clemens Buchacher's message of "Tue, 4 Aug 2015 10:24:29 +0200")
Clemens Buchacher <clemens.buchacher@intel•com> writes:
> diff --git a/sha1_file.c b/sha1_file.c
> index 77cd81d..62b7ad6 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -1453,6 +1453,7 @@ int git_open_noatime(const char *name)
> static int sha1_file_open_flag = O_NOATIME;
>
> for (;;) {
> + errno = 0;
> int fd = open(name, O_RDONLY | sha1_file_open_flag);
Please avoid decl-after-stmt, which this codebase does not accept.
> if (fd >= 0)
> return fd;
More importantly, is this the right place to clear errno?
I would agree it is a good idea to clear it after seeing the first
open fail due to lack of O_NOATIME before trying open for the second
time, iow, more like this?
sha1_file.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sha1_file.c b/sha1_file.c
index 1cee438..bf2f229 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1467,6 +1467,7 @@ int git_open_noatime(const char *name)
/* Might the failure be due to O_NOATIME? */
if (errno != ENOENT && sha1_file_open_flag) {
+ errno = 0;
sha1_file_open_flag = 0;
continue;
}
next prev parent reply other threads:[~2015-08-04 21:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 12:38 [PATCH] git_open_noatime: return with errno=0 on success Clemens Buchacher
2015-07-08 18:51 ` Eric Sunshine
2015-08-04 8:24 ` Clemens Buchacher
2015-08-04 21:03 ` Junio C Hamano [this message]
2015-08-05 8:59 ` Linus Torvalds
2015-08-05 14:36 ` Clemens Buchacher
2015-08-05 16:27 ` Junio C Hamano
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=xmqqfv3y6a24.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=clemens.buchacher@intel$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=martin.h.schroeder@intel$(echo .)com \
--cc=sunshine@sunshineco$(echo .)com \
--cc=torvalds@linux-foundation$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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