git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] dir.c: print correct errno when opendir() fails
@ 2018-01-18  9:50 Nguyễn Thái Ngọc Duy
  2018-01-19 21:09 ` Junio C Hamano
  2018-01-24  9:30 ` [PATCH 0/5] nd/fix-untracked-cache-invalidation updates Nguyễn Thái Ngọc Duy
  0 siblings, 2 replies; 12+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-01-18  9:50 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy

The call invalidate_directory() between opendir() and warning_errno() in
theory could make some system calls and change errno. Prevent that by
warning immediately after opendir().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 This is on top of nd/fix-untracked-cache-invalidation which is now on
 'next'. Sorry I waited too long to send the replacement and it's now
 too late.

 dir.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/dir.c b/dir.c
index dd1e50c328..55736d3e2a 100644
--- a/dir.c
+++ b/dir.c
@@ -1795,14 +1795,14 @@ static int open_cached_dir(struct cached_dir *cdir,
 		return 0;
 	c_path = path->len ? path->buf : ".";
 	cdir->fdir = opendir(c_path);
+	if (!cdir->fdir)
+		warning_errno(_("could not open directory '%s'"), c_path);
 	if (dir->untracked) {
 		invalidate_directory(dir->untracked, untracked);
 		dir->untracked->dir_opened++;
 	}
-	if (!cdir->fdir) {
-		warning_errno(_("could not open directory '%s'"), c_path);
+	if (!cdir->fdir)
 		return -1;
-	}
 	return 0;
 }
 
-- 
2.15.1.600.g899a5f85c6


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-02-01 23:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-18  9:50 [PATCH] dir.c: print correct errno when opendir() fails Nguyễn Thái Ngọc Duy
2018-01-19 21:09 ` Junio C Hamano
2018-01-21 11:52   ` Duy Nguyen
2018-01-24  9:30 ` [PATCH 0/5] nd/fix-untracked-cache-invalidation updates Nguyễn Thái Ngọc Duy
2018-01-24  9:30   ` [PATCH 1/5] status: add a failing test showing a core.untrackedCache bug Nguyễn Thái Ngọc Duy
2018-01-24  9:30   ` [PATCH 2/5] dir.c: avoid stat() in valid_cached_dir() Nguyễn Thái Ngọc Duy
2018-01-24  9:30   ` [PATCH 3/5] dir.c: fix missing dir invalidation in untracked code Nguyễn Thái Ngọc Duy
2018-01-24  9:30   ` [PATCH 4/5] update-index doc: note a fixed bug in the untracked cache Nguyễn Thái Ngọc Duy
2018-01-24  9:30   ` [PATCH 5/5] dir.c: stop ignoring opendir() error in open_cached_dir() Nguyễn Thái Ngọc Duy
2018-02-01 23:00     ` Ævar Arnfjörð Bjarmason
2018-01-24 11:47   ` [PATCH 0/5] nd/fix-untracked-cache-invalidation updates Ævar Arnfjörð Bjarmason
2018-01-24 20:41     ` Junio C Hamano

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