]> git.proxmox.com Git - wasi-libc.git/commitdiff
Fix missing errno assignments.
authorDan Gohman <dev@sunfishcode.online>
Thu, 6 Oct 2022 18:48:54 +0000 (11:48 -0700)
committerDan Gohman <dev@sunfishcode.online>
Thu, 6 Oct 2022 21:19:26 +0000 (14:19 -0700)
In PR #294 I removed a little too much code; we still need to assign to
`errno` in the code in question here.

14 files changed:
libc-bottom-half/cloudlibc/src/libc/dirent/fdopendir.c
libc-bottom-half/cloudlibc/src/libc/fcntl/openat.c
libc-bottom-half/cloudlibc/src/libc/stdio/renameat.c
libc-bottom-half/cloudlibc/src/libc/sys/socket/recv.c
libc-bottom-half/cloudlibc/src/libc/sys/socket/send.c
libc-bottom-half/cloudlibc/src/libc/sys/socket/shutdown.c
libc-bottom-half/cloudlibc/src/libc/sys/stat/fstatat.c
libc-bottom-half/cloudlibc/src/libc/sys/stat/mkdirat.c
libc-bottom-half/cloudlibc/src/libc/sys/stat/utimensat.c
libc-bottom-half/cloudlibc/src/libc/unistd/faccessat.c
libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c
libc-bottom-half/cloudlibc/src/libc/unistd/readlinkat.c
libc-bottom-half/cloudlibc/src/libc/unistd/symlinkat.c
libc-bottom-half/sources/__wasilibc_rmdirat.c

index c7fd4565865c6dc521993a834799e36d3c1089aa..4a2136af520e545b31c43002dfdffc3f5d444c13 100644 (file)
@@ -29,6 +29,7 @@ DIR *fdopendir(int fd) {
   if (error != 0) {
     free(dirp->buffer);
     free(dirp);
+    errno = error;
     return NULL;
   }
 
index 51e10b5f80eb0861c34965c430f09649983c2073..09cbbf8008f1da05c59cbd964b8b58bcac91d789 100644 (file)
@@ -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;
index 86c6a5cbe3fc5b8298b763813ea63ec331b7055f..c1706db48f75731971289a0cf9efd6ed4c8205ab 100644 (file)
@@ -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;
index cf6199e8c860be49ff9f1b75c7231bacfc82c27c..d35f8894fa4597f73accd9a718f04f9d65443eaf 100644 (file)
@@ -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;
index 238270190ce0ca7b61a850619bd3b476537f1bb7..85a298a73155af42b19e975734452d876a702eca 100644 (file)
@@ -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;
index 85ede06d1b72d206f15e8d4ee01016b090ec2299..261fcb81ea9cb8a19ed87509f9d3b4ec49b8695c 100644 (file)
@@ -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;
index ab48f32a747a3540309b62456f1f2d439a878184..25b29ac9821abc490883238a425243b75e5af314 100644 (file)
@@ -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);
index 302650f2e9f04eb426190154939b51113c487261..fd27d5e1732146a874d4d190ca10868c1c3afd3c 100644 (file)
@@ -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;
index d274ef5ce2f40a3ceb6f068ef891d771283eed99..19508a1365109e021d341d7bbdb100b74a2969c8 100644 (file)
@@ -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;
   }
 
@@ -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;
index d28805d18f759816b64e7b7fa9a36a53ce8651b3..ffaef6ed6238dd14cb4e5a58450185731731fa8f 100644 (file)
@@ -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;
   }
 
index eef59849157f916388118c4358bada4196e49e55..d57f5621d62ca829a493b768dde6c94bb9f7b71a 100644 (file)
@@ -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;
index 4c5be305a6cabdb9559d84aa5d646336c018db9a..7a3bce27b7a38a58dbbac2af58c8f3dbd952e4fe 100644 (file)
@@ -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;
index b70fc785bbf611c6d2f7a0a26ba504abb6fb0693..0aa38be2cd49fe0f8f2b6c0c3ed60fffdcd5e384 100644 (file)
@@ -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;
index 3f1d27daa3c881d6097662575a6a7dbde7a917c5..b2b906aa68c802f6769e6bf27e0608371c95dd37 100644 (file)
@@ -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;