qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 7/8] linux-user/syscall: Introduce errno_exists()


From: Richard Henderson
Subject: Re: [PATCH v2 7/8] linux-user/syscall: Introduce errno_exists()
Date: Thu, 8 Jul 2021 08:42:25 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 7/8/21 7:11 AM, Philippe Mathieu-Daudé wrote:
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));

After patch 8, you can simply remove this test entirely, as well as the otherwise unused and totally arbitrary ERRNO_TABLE_SIZE.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]