From 7c8a98e957d64eb6e8b63a8219eb7a2a4fdfc45a Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sun, 25 Nov 2018 12:50:42 +0900 Subject: [PATCH] libc: stat/lstat must return -1 on error --- libc/unistd/stat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libc/unistd/stat.c b/libc/unistd/stat.c index a09058d9..b40c6190 100644 --- a/libc/unistd/stat.c +++ b/libc/unistd/stat.c @@ -12,9 +12,9 @@ int stat(const char *file, struct stat *st){ if (ret >= 0) { return ret; } else { - errno = ENOENT; /* meh */ + errno = -ret; memset(st, 0x00, sizeof(struct stat)); - return ret;; + return -1; } } @@ -25,6 +25,6 @@ int lstat(const char *path, struct stat *st) { } else { errno = -ret; memset(st, 0x00, sizeof(struct stat)); - return ret; + return -1; } }