diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-05-13 12:43:58 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-05-14 08:35:54 +0200 |
commit | 6188685091c58c9772b990cf0ca6ac522f97a9d0 (patch) | |
tree | ff994e79773e3bab5abe1b79129cbb08ddf9f754 /lib/make_directory.c | |
parent | 2f05b6925676e5f3263e0d51ed2f0a92201400d8 (diff) | |
download | barebox-6188685091c58c9772b990cf0ca6ac522f97a9d0.tar.gz barebox-6188685091c58c9772b990cf0ca6ac522f97a9d0.tar.xz |
Make errno a positive value
Normally errno contains a positive error value. A certain unnamed developer
mixed this up while implementing U-Boot-v2. Also, normally errno is never
set to zero by any library function.
This patch fixes this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib/make_directory.c')
-rw-r--r-- | lib/make_directory.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/make_directory.c b/lib/make_directory.c index 274bc146cf..c14c86d45b 100644 --- a/lib/make_directory.c +++ b/lib/make_directory.c @@ -12,6 +12,7 @@ int make_directory(const char *dir) char *s = strdup(dir); char *path = s; char c; + int ret = 0; do { c = 0; @@ -33,12 +34,10 @@ int make_directory(const char *dir) /* If we failed for any other reason than the directory * already exists, output a diagnostic and return -1.*/ -#ifdef __BAREBOX__ - if (errno != -EEXIST) -#else - if (errno != EEXIST) -#endif + if (errno != EEXIST) { + ret = -errno; break; + } } if (!c) goto out; @@ -50,7 +49,9 @@ int make_directory(const char *dir) out: free(path); - return errno; + if (ret) + errno = -ret; + return ret; } #ifdef __BAREBOX__ EXPORT_SYMBOL(make_directory); |