[RFC PATCH 1/2] fs: fix path_check_prereq()
Antony Pavlov
antonynpavlov at gmail.com
Tue Oct 18 05:48:44 EDT 2011
This patch makes impossible the situations than path_check_prereq() can make
'return 0' without changing errno.
Signed-off-by: Antony Pavlov <antonynpavlov at 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
More information about the barebox
mailing list