2023-06-04 20:10:26

by Thomas Weißschuh

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

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

Fixes: 33158bb86d46 ("tools/nolibc/unistd: add syscall()")
Signed-off-by: Thomas Weißschuh <[email protected]>
---

Just noticed this when responding at
https://lore.kernel.org/lkml/[email protected]/

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 <[email protected]>