Skip to content

Commit 099caae

Browse files
committed
Fix missing errno assignments.
In PR #294 I removed a little too much code; we still need to assign to `errno` in the code in question here.
1 parent a022980 commit 099caae

File tree

14 files changed

+15
-0
lines changed

14 files changed

+15
-0
lines changed

libc-bottom-half/cloudlibc/src/libc/dirent/fdopendir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ DIR *fdopendir(int fd) {
2929
if (error != 0) {
3030
free(dirp->buffer);
3131
free(dirp);
32+
errno = error;
3233
return NULL;
3334
}
3435

libc-bottom-half/cloudlibc/src/libc/fcntl/openat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ int __wasilibc_nocwd_openat_nomode(int fd, const char *path, int oflag) {
7373
fs_rights_base, fs_rights_inheriting, fs_flags,
7474
&newfd);
7575
if (error != 0) {
76+
errno = error;
7677
return -1;
7778
}
7879
return newfd;

libc-bottom-half/cloudlibc/src/libc/stdio/renameat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
int __wasilibc_nocwd_renameat(int oldfd, const char *old, int newfd, const char *new) {
1111
__wasi_errno_t error = __wasi_path_rename(oldfd, old, newfd, new);
1212
if (error != 0) {
13+
errno = error;
1314
return -1;
1415
}
1516
return 0;

libc-bottom-half/cloudlibc/src/libc/sys/socket/recv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ ssize_t recv(int socket, void *restrict buffer, size_t length, int flags) {
3333
&ro_datalen,
3434
&ro_flags);
3535
if (error != 0) {
36+
errno = error;
3637
return -1;
3738
}
3839
return ro_datalen;

libc-bottom-half/cloudlibc/src/libc/sys/socket/send.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ssize_t send(int socket, const void *buffer, size_t length, int flags) {
2525
size_t so_datalen;
2626
__wasi_errno_t error = __wasi_sock_send(socket, si_data, si_data_len, si_flags, &so_datalen);
2727
if (error != 0) {
28+
errno = error;
2829
return -1;
2930
}
3031
return so_datalen;

libc-bottom-half/cloudlibc/src/libc/sys/socket/shutdown.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ int shutdown(int socket, int how) {
2020

2121
__wasi_errno_t error = __wasi_sock_shutdown(socket, how);
2222
if (error != 0) {
23+
errno = error;
2324
return -1;
2425
}
2526
return error;

libc-bottom-half/cloudlibc/src/libc/sys/stat/fstatat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ int __wasilibc_nocwd_fstatat(int fd, const char *restrict path, struct stat *res
2323
__wasi_errno_t error =
2424
__wasi_path_filestat_get(fd, lookup_flags, path, &internal_stat);
2525
if (error != 0) {
26+
errno = error;
2627
return -1;
2728
}
2829
to_public_stat(&internal_stat, buf);

libc-bottom-half/cloudlibc/src/libc/sys/stat/mkdirat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
int __wasilibc_nocwd_mkdirat_nomode(int fd, const char *path) {
1212
__wasi_errno_t error = __wasi_path_create_directory(fd, path);
1313
if (error != 0) {
14+
errno = error;
1415
return -1;
1516
}
1617
return 0;

libc-bottom-half/cloudlibc/src/libc/sys/stat/utimensat.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ int __wasilibc_nocwd_utimensat(int fd, const char *path, const struct timespec t
1818
__wasi_timestamp_t st_mtim;
1919
__wasi_fstflags_t flags;
2020
if (!utimens_get_timestamps(times, &st_atim, &st_mtim, &flags)) {
21+
errno = EINVAL;
2122
return -1;
2223
}
2324

@@ -30,6 +31,7 @@ int __wasilibc_nocwd_utimensat(int fd, const char *path, const struct timespec t
3031
__wasi_errno_t error =
3132
__wasi_path_filestat_set_times(fd, lookup_flags, path, st_atim, st_mtim, flags);
3233
if (error != 0) {
34+
errno = error;
3335
return -1;
3436
}
3537
return 0;

libc-bottom-half/cloudlibc/src/libc/unistd/faccessat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ int __wasilibc_nocwd_faccessat(int fd, const char *path, int amode, int flag) {
2222
__wasi_errno_t error =
2323
__wasi_path_filestat_get(fd, lookup_flags, path, &file);
2424
if (error != 0) {
25+
errno = error;
2526
return -1;
2627
}
2728

0 commit comments

Comments
 (0)