[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 7/8] linux-user/syscall: Introduce errno_exists()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 7/8] linux-user/syscall: Introduce errno_exists() |
Date: |
Thu, 8 Jul 2021 16:11:20 +0200 |
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
linux-user/syscall.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4842a1987b7..56682b06cbd 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -509,6 +509,11 @@ static inline int next_free_host_timer(void)
#define ERRNO_TABLE_SIZE 1200
+static inline bool errno_exists(int err)
+{
+ return err >= 0 && err < ERRNO_TABLE_SIZE;
+}
+
/* target_to_host_errno_table[] is initialized from
* host_to_target_errno_table[] in syscall_init(). */
static uint16_t target_to_host_errno_table[ERRNO_TABLE_SIZE] = {
@@ -672,7 +677,7 @@ const char *target_strerror(int err)
return "Successful exit from sigreturn";
}
- if ((err >= ERRNO_TABLE_SIZE) || (err < 0)) {
+ if (!errno_exists(err)) {
return NULL;
}
return strerror(target_to_host_errno(err));
--
2.31.1
- Re: [PATCH v2 3/8] linux-user: Extract target errno to 'target_errno_defs.h', (continued)