diff mbox

[18/18] linux-user: Special-case ERESTARTSYS in target_strerror()

Message ID 1465239499-5048-19-git-send-email-peter.maydell@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Maydell June 6, 2016, 6:58 p.m. UTC
Since TARGET_ERESTARTSYS and TARGET_ESIGRETURN are internal-to-QEMU
error numbers, handle them specially in target_strerror(), to avoid
confusing strace output like:

9521 rt_sigreturn(14,8,274886297808,8,0,268435456) = -1 errno=513 (Unknown error 513)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/syscall.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Laurent Vivier June 7, 2016, 7:53 p.m. UTC | #1
Le 06/06/2016 à 20:58, Peter Maydell a écrit :
> Since TARGET_ERESTARTSYS and TARGET_ESIGRETURN are internal-to-QEMU
> error numbers, handle them specially in target_strerror(), to avoid
> confusing strace output like:
> 
> 9521 rt_sigreturn(14,8,274886297808,8,0,268435456) = -1 errno=513 (Unknown error 513)
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  linux-user/syscall.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index bcee02d..782d475 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -619,6 +619,13 @@ static inline int is_error(abi_long ret)
>  
>  const char *target_strerror(int err)
>  {
> +    if (err == TARGET_ERESTARTSYS) {
> +        return "To be restarted";
> +    }
> +    if (err == TARGET_QEMU_ESIGRETURN) {
> +        return "Successful exit from sigreturn";
> +    }
> +
>      if ((err >= ERRNO_TABLE_SIZE) || (err < 0)) {
>          return NULL;
>      }

This is not the aim of this patch, but target_to_host_errno() has now
these checks, perhaps we can remove this while we are here...

Laurent
Peter Maydell June 7, 2016, 9:31 p.m. UTC | #2
On 7 June 2016 at 20:53, Laurent Vivier <laurent@vivier.eu> wrote:
>
>
> Le 06/06/2016 à 20:58, Peter Maydell a écrit :
>> Since TARGET_ERESTARTSYS and TARGET_ESIGRETURN are internal-to-QEMU
>> error numbers, handle them specially in target_strerror(), to avoid
>> confusing strace output like:
>>
>> 9521 rt_sigreturn(14,8,274886297808,8,0,268435456) = -1 errno=513 (Unknown error 513)
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>  linux-user/syscall.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>> index bcee02d..782d475 100644
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
>> @@ -619,6 +619,13 @@ static inline int is_error(abi_long ret)
>>
>>  const char *target_strerror(int err)
>>  {
>> +    if (err == TARGET_ERESTARTSYS) {
>> +        return "To be restarted";
>> +    }
>> +    if (err == TARGET_QEMU_ESIGRETURN) {
>> +        return "Successful exit from sigreturn";
>> +    }
>> +
>>      if ((err >= ERRNO_TABLE_SIZE) || (err < 0)) {
>>          return NULL;
>>      }
>
> This is not the aim of this patch, but target_to_host_errno() has now
> these checks, perhaps we can remove this while we are here...

I think that would break the callers, which assume they can
pass in any number as a potential errno, and get
back NULL if it wasn't actually an errno. If we passed
them through to target_to_host_errno() it would pass
them on unchanged and the host strerror() would generate
a string "Unknown errno 134134234" or whatever.

thanks
-- PMM
diff mbox

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index bcee02d..782d475 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -619,6 +619,13 @@  static inline int is_error(abi_long ret)
 
 const char *target_strerror(int err)
 {
+    if (err == TARGET_ERESTARTSYS) {
+        return "To be restarted";
+    }
+    if (err == TARGET_QEMU_ESIGRETURN) {
+        return "Successful exit from sigreturn";
+    }
+
     if ((err >= ERRNO_TABLE_SIZE) || (err < 0)) {
         return NULL;
     }