summaryrefslogtreecommitdiffstats
path: root/commands/ls.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-05-13 12:43:58 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-05-14 08:35:54 +0200
commit6188685091c58c9772b990cf0ca6ac522f97a9d0 (patch)
treeff994e79773e3bab5abe1b79129cbb08ddf9f754 /commands/ls.c
parent2f05b6925676e5f3263e0d51ed2f0a92201400d8 (diff)
downloadbarebox-6188685091c58c9772b990cf0ca6ac522f97a9d0.tar.gz
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 'commands/ls.c')
-rw-r--r--commands/ls.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/commands/ls.c b/commands/ls.c
index c98d2da..ad609f3 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -49,7 +49,7 @@ int ls(const char *path, ulong flags)
string_list_init(&sl);
if (stat(path, &s))
- return errno;
+ return -errno;
if (flags & LS_SHOWARG && s.st_mode & S_IFDIR)
printf("%s:\n", path);
@@ -61,7 +61,7 @@ int ls(const char *path, ulong flags)
dir = opendir(path);
if (!dir)
- return errno;
+ return -errno;
while ((d = readdir(dir))) {
sprintf(tmp, "%s/%s", path, d->d_name);
@@ -85,7 +85,7 @@ int ls(const char *path, ulong flags)
dir = opendir(path);
if (!dir) {
- errno = -ENOENT;
+ errno = ENOENT;
return -ENOENT;
}