Skip to content

Commit

Permalink
Fix missing errno assignments.
Browse files Browse the repository at this point in the history
In PR #294 I removed a little too much code; we still need to assign to
`errno` in the code in question here.
  • Loading branch information
sunfishcode committed Oct 6, 2022
1 parent a022980 commit 099caae
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/dirent/fdopendir.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ DIR *fdopendir(int fd) {
if (error != 0) {
free(dirp->buffer);
free(dirp);
errno = error;
return NULL;
}

Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/fcntl/openat.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ int __wasilibc_nocwd_openat_nomode(int fd, const char *path, int oflag) {
fs_rights_base, fs_rights_inheriting, fs_flags,
&newfd);
if (error != 0) {
errno = error;
return -1;
}
return newfd;
Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/stdio/renameat.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
int __wasilibc_nocwd_renameat(int oldfd, const char *old, int newfd, const char *new) {
__wasi_errno_t error = __wasi_path_rename(oldfd, old, newfd, new);
if (error != 0) {
errno = error;
return -1;
}
return 0;
Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/sys/socket/recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ssize_t recv(int socket, void *restrict buffer, size_t length, int flags) {
&ro_datalen,
&ro_flags);
if (error != 0) {
errno = error;
return -1;
}
return ro_datalen;
Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/sys/socket/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ssize_t send(int socket, const void *buffer, size_t length, int flags) {
size_t so_datalen;
__wasi_errno_t error = __wasi_sock_send(socket, si_data, si_data_len, si_flags, &so_datalen);
if (error != 0) {
errno = error;
return -1;
}
return so_datalen;
Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/sys/socket/shutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ int shutdown(int socket, int how) {

__wasi_errno_t error = __wasi_sock_shutdown(socket, how);
if (error != 0) {
errno = error;
return -1;
}
return error;
Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/sys/stat/fstatat.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ int __wasilibc_nocwd_fstatat(int fd, const char *restrict path, struct stat *res
__wasi_errno_t error =
__wasi_path_filestat_get(fd, lookup_flags, path, &internal_stat);
if (error != 0) {
errno = error;
return -1;
}
to_public_stat(&internal_stat, buf);
Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/sys/stat/mkdirat.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
int __wasilibc_nocwd_mkdirat_nomode(int fd, const char *path) {
__wasi_errno_t error = __wasi_path_create_directory(fd, path);
if (error != 0) {
errno = error;
return -1;
}
return 0;
Expand Down
2 changes: 2 additions & 0 deletions libc-bottom-half/cloudlibc/src/libc/sys/stat/utimensat.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ int __wasilibc_nocwd_utimensat(int fd, const char *path, const struct timespec t
__wasi_timestamp_t st_mtim;
__wasi_fstflags_t flags;
if (!utimens_get_timestamps(times, &st_atim, &st_mtim, &flags)) {
errno = EINVAL;
return -1;
}

Expand All @@ -30,6 +31,7 @@ int __wasilibc_nocwd_utimensat(int fd, const char *path, const struct timespec t
__wasi_errno_t error =
__wasi_path_filestat_set_times(fd, lookup_flags, path, st_atim, st_mtim, flags);
if (error != 0) {
errno = error;
return -1;
}
return 0;
Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/unistd/faccessat.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ int __wasilibc_nocwd_faccessat(int fd, const char *path, int amode, int flag) {
__wasi_errno_t error =
__wasi_path_filestat_get(fd, lookup_flags, path, &file);
if (error != 0) {
errno = error;
return -1;
}

Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ int __wasilibc_nocwd_linkat(int fd1, const char *path1, int fd2, const char *pat
// Perform system call.
__wasi_errno_t error = __wasi_path_link(fd1, lookup1_flags, path1, fd2, path2);
if (error != 0) {
errno = error;
return -1;
}
return 0;
Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/unistd/readlinkat.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ssize_t __wasilibc_nocwd_readlinkat(int fd, const char *restrict path, char *res
__wasi_errno_t error = __wasi_path_readlink(fd, path,
(uint8_t*)buf, bufsize, &bufused);
if (error != 0) {
errno = error;
return -1;
}
return bufused;
Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/cloudlibc/src/libc/unistd/symlinkat.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
int __wasilibc_nocwd_symlinkat(const char *path1, int fd, const char *path2) {
__wasi_errno_t error = __wasi_path_symlink(path1, fd, path2);
if (error != 0) {
errno = error;
return -1;
}
return 0;
Expand Down
1 change: 1 addition & 0 deletions libc-bottom-half/sources/__wasilibc_rmdirat.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
int __wasilibc_nocwd___wasilibc_rmdirat(int fd, const char *path) {
__wasi_errno_t error = __wasi_path_remove_directory(fd, path);
if (error != 0) {
errno = error;
return -1;
}
return 0;
Expand Down

0 comments on commit 099caae

Please sign in to comment.