mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Subject: [RFC PATCH 1/2] fs: fix path_check_prereq()
Date: Tue, 18 Oct 2011 13:48:44 +0400	[thread overview]
Message-ID: <1318931325-31138-1-git-send-email-antonynpavlov@gmail.com> (raw)

This patch makes impossible the situations than path_check_prereq() can make
'return 0' without changing errno.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 fs/fs.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 7d65ec8..714fc9b 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -293,9 +293,11 @@ static int path_check_prereq(const char *path, unsigned int flags)
 	struct stat s;
 	unsigned int m;
 
+	errno = 0;
+
 	if (stat(path, &s)) {
 		if (flags & S_UB_DOES_NOT_EXIST)
-			return 0;
+			goto out;
 		errno = -ENOENT;
 		goto out;
 	}
@@ -306,7 +308,7 @@ static int path_check_prereq(const char *path, unsigned int flags)
 	}
 
 	if (flags == S_UB_EXISTS)
-		return 0;
+		goto out;
 
 	m = s.st_mode;
 
@@ -325,7 +327,6 @@ static int path_check_prereq(const char *path, unsigned int flags)
 		goto out;
 	}
 
-	errno = 0;
 out:
 	return errno;
 }
-- 
1.7.6.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2011-10-18  9:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-18  9:48 Antony Pavlov [this message]
2011-10-18  9:48 ` [RFC PATCH 2/2] fs: fix chdir() Antony Pavlov
2011-10-18 10:13 ` [RFC PATCH 1/2] fs: fix path_check_prereq() Sascha Hauer
2011-10-19  9:51 ` Sascha Hauer

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=1318931325-31138-1-git-send-email-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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