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 /common | |
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 'common')
-rw-r--r-- | common/env.c | 2 | ||||
-rw-r--r-- | common/environment.c | 6 | ||||
-rw-r--r-- | common/misc.c | 2 |
3 files changed, 5 insertions, 5 deletions
diff --git a/common/env.c b/common/env.c index e57a520a35..a01a27e24f 100644 --- a/common/env.c +++ b/common/env.c @@ -219,7 +219,7 @@ int setenv(const char *_name, const char *value) else ret = -ENODEV; - errno = ret; + errno = -ret; if (ret < 0) perror("set parameter"); diff --git a/common/environment.c b/common/environment.c index 0fdbd03e00..52ce0de1da 100644 --- a/common/environment.c +++ b/common/environment.c @@ -187,7 +187,7 @@ int envfs_load(char *filename, char *dir) ret = read(envfd, &super, sizeof(struct envfs_super)); if ( ret < sizeof(struct envfs_super)) { perror("read"); - ret = errno; + ret = -errno; goto out; } @@ -210,7 +210,7 @@ int envfs_load(char *filename, char *dir) ret = read(envfd, buf, size); if (ret < size) { perror("read"); - ret = errno; + ret = -errno; goto out; } @@ -256,7 +256,7 @@ int envfs_load(char *filename, char *dir) inode_size); if (ret < inode_size) { perror("write"); - ret = errno; + ret = -errno; close(fd); goto out; } diff --git a/common/misc.c b/common/misc.c index b31a45c1a4..01e1b19e0d 100644 --- a/common/misc.c +++ b/common/misc.c @@ -112,7 +112,7 @@ EXPORT_SYMBOL(strerror); const char *errno_str(void) { - return strerror(-errno); + return strerror(errno); } EXPORT_SYMBOL(errno_str); |