fix: fix faulty syscall result/status code compares

This commit is contained in:
daniel committed 2026-10-13 07:15:05 +02:00
1 parent abfd9de8f6
commit a81298fb24
7 files changed
+19 -14

No files matched your search

+6 -5
View File
@@ -2494,7 +2494,7 @@ char *getcwd(char *buf, size_t size) {
}
int result = (int)_mtk_syscall2(SYS_GETCWD, (long)buf, (long)size);
if (result < 0) {
errno = result == BufferTooSmall ? ERANGE : EIO;
errno = result == -BufferTooSmall ? ERANGE : EIO;
return NULL;
}
return buf;
@@ -3584,10 +3584,11 @@ int utime(const char *path, const struct utimbuf *times) {
times != NULL ? (long)times->modtime : 0,
times == NULL);
if (result == 0) return 0;
if (result == UnsupportedOp) errno = ENOTSUP;
else if (result == InvalidArgument) errno = EOVERFLOW;
else if (result == IoFailure) errno = EIO;
else if (result == SystemIntegrityError) errno = EPERM;
/* The kernel returns StatusCodes negated. */
if (result == -UnsupportedOp) errno = ENOTSUP;
else if (result == -InvalidArgument) errno = EOVERFLOW;
else if (result == -IoFailure) errno = EIO;
else if (result == -SystemIntegrityError) errno = EPERM;
else errno = ENOENT;
return -1;
}