[PATCH] tools/nolibc: handle large return values from syscall()

From: Thomas Weißschuh
Date: Sun Jun 04 2023 - 15:59:06 EST


Syscalls return values long values. Don't truncate to int.

Fixes: 33158bb86d46 ("tools/nolibc/unistd: add syscall()")
Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---

Just noticed this when responding at
https://lore.kernel.org/lkml/ea4e7442-7223-4211-ba29-70821e907888@xxxxxxxx/

Feel free to squash this directly into the broken commit.
---
tools/include/nolibc/unistd.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h
index 6773e83c16a0..c20b2fbf065e 100644
--- a/tools/include/nolibc/unistd.h
+++ b/tools/include/nolibc/unistd.h
@@ -58,7 +58,7 @@ int tcsetpgrp(int fd, pid_t pid)

#define _syscall(N, ...) \
({ \
- int _ret = my_syscall##N(__VA_ARGS__); \
+ long _ret = my_syscall##N(__VA_ARGS__); \
if (_ret < 0) { \
SET_ERRNO(-_ret); \
_ret = -1; \

---
base-commit: a76324560e0f8f916d89452dd6aec1104e97a3c6
change-id: 20230604-nolibc-syscall-ret-520dfe9fb6b0

Best regards,
--
Thomas Weißschuh <linux@xxxxxxxxxxxxxx>