git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git_open_noatime: return with errno=0 on success

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 4, 2015, 21:03 UTC
Message-ID
<xmqqfv3y6a24.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150804082429.GA22271@musxeris015.imu.intel.com>
Clemens Buchacher <clemens.buchacher@intel.com> writes:
Show 10 quoted lines
> 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;
 		}
Previous: Clemens BuchacherNext: Linus Torvalds
Message 4 of 7 in “git_open_noatime: return with errno=0 on success”
  1. git_open_noatime: return with errno=0 on successClemens Buchacher, Jul 8, 2015
  2. Eric SunshineJul 8, 2015
  3. git_open_noatime: return with errno=0 on successClemens Buchacher, Aug 4, 2015
  4. Junio C HamanoAug 4, 2015
  5. Linus TorvaldsAug 5, 2015
  6. Clemens BuchacherAug 5, 2015
  7. Junio C HamanoAug 5, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.