]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/syscall_shim: Adjust the sign of `errno` to be positive
authorSergiu Moga <sergiu.moga@protonmail.com>
Tue, 22 Jun 2021 09:35:05 +0000 (12:35 +0300)
committerUnikraft <monkey@unikraft.io>
Tue, 29 Jun 2021 08:14:51 +0000 (08:14 +0000)
Ensure that `errno` is assigned the positive value of what the raw
system calls return.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #236

lib/syscall_shim/include/uk/syscall.h

index c58bae58c35c3eb533b6ed4094cefa07cf063520..9c4348c1ac91c9f0c5b5052b33f9cd465e5dfb07 100644 (file)
@@ -201,7 +201,7 @@ typedef long uk_syscall_arg_t;
                long ret = rname(                                       \
                        UK_ARG_MAPx(x, UK_S_ARG_CAST_LONG, __VA_ARGS__)); \
                if (ret < 0 && PTRISERR(ret)) {                         \
-                       errno = (int) PTR2ERR(ret);                     \
+                       errno = -(int) PTR2ERR(ret);                    \
                        return -1;                                      \
                }                                                       \
                return ret;                                             \