[Qemu-devel] [PATCH] linux-user: Remove dead error-checking code

Peter Maydell posted 1 patch 5 years, 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20181019161715.12122-1-peter.maydell@linaro.org
Test docker-clang@ubuntu passed
Test checkpatch passed
Test asan passed
Test docker-mingw@fedora failed
Test docker-quick@centos7 passed
linux-user/m68k/signal.c  | 3 ---
linux-user/sh4/signal.c   | 4 ----
linux-user/sparc/signal.c | 2 --
3 files changed, 9 deletions(-)
[Qemu-devel] [PATCH] linux-user: Remove dead error-checking code
Posted by Peter Maydell 5 years, 6 months ago
Remove some dead code spotted by Coverity (CID 1009855,
1390854, 1390847). The underlying cause in all these cases
is the same: QEMU's put_user operations can't result in
errors, but the kernel's equivalent does. So when code
was copied from the kernel signal-frame-setup/teardown
code, checks on error flags that were needed in the kernel
became dead code for us.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/m68k/signal.c  | 3 ---
 linux-user/sh4/signal.c   | 4 ----
 linux-user/sparc/signal.c | 2 --
 3 files changed, 9 deletions(-)

diff --git a/linux-user/m68k/signal.c b/linux-user/m68k/signal.c
index 38bd77ec160..49ff87c77bc 100644
--- a/linux-user/m68k/signal.c
+++ b/linux-user/m68k/signal.c
@@ -334,9 +334,6 @@ void setup_rt_frame(int sig, struct target_sigaction *ka,
                (uint32_t *)(frame->retcode + 0));
     __put_user(0x4e40, (uint16_t *)(frame->retcode + 4));
 
-    if (err)
-        goto give_sigsegv;
-
     /* Set up to return from userspace */
 
     env->aregs[7] = frame_addr;
diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c
index c6752baa7ee..cc89a48ff8b 100644
--- a/linux-user/sh4/signal.c
+++ b/linux-user/sh4/signal.c
@@ -279,7 +279,6 @@ long do_sigreturn(CPUSH4State *regs)
     sigset_t blocked;
     target_sigset_t target_set;
     int i;
-    int err = 0;
 
     frame_addr = regs->gregs[15];
     trace_user_do_sigreturn(regs, frame_addr);
@@ -292,9 +291,6 @@ long do_sigreturn(CPUSH4State *regs)
         __get_user(target_set.sig[i], &frame->extramask[i - 1]);
     }
 
-    if (err)
-        goto badframe;
-
     target_to_host_sigset_internal(&blocked, &target_set);
     set_sigmask(&blocked);
 
diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c
index e44e99993c6..295e415b1e6 100644
--- a/linux-user/sparc/signal.c
+++ b/linux-user/sparc/signal.c
@@ -256,8 +256,6 @@ void setup_frame(int sig, struct target_sigaction *ka,
         /* t 0x10 */
         val32 = 0x91d02010;
         __put_user(val32, &sf->insns[1]);
-        if (err)
-            goto sigsegv;
     }
     unlock_user(sf, sf_addr, sizeof(struct target_signal_frame));
     return;
-- 
2.19.1


Re: [Qemu-devel] [PATCH] linux-user: Remove dead error-checking code
Posted by Laurent Vivier 5 years, 6 months ago
Le 19/10/2018 à 18:17, Peter Maydell a écrit :
> Remove some dead code spotted by Coverity (CID 1009855,
> 1390854, 1390847). The underlying cause in all these cases
> is the same: QEMU's put_user operations can't result in
> errors, but the kernel's equivalent does. So when code
> was copied from the kernel signal-frame-setup/teardown
> code, checks on error flags that were needed in the kernel
> became dead code for us.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  linux-user/m68k/signal.c  | 3 ---
>  linux-user/sh4/signal.c   | 4 ----
>  linux-user/sparc/signal.c | 2 --
>  3 files changed, 9 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Re: [Qemu-devel] [PATCH] linux-user: Remove dead error-checking code
Posted by Peter Maydell 5 years, 5 months ago
On 19 October 2018 at 17:26, Laurent Vivier <laurent@vivier.eu> wrote:
> Le 19/10/2018 à 18:17, Peter Maydell a écrit :
>> Remove some dead code spotted by Coverity (CID 1009855,
>> 1390854, 1390847). The underlying cause in all these cases
>> is the same: QEMU's put_user operations can't result in
>> errors, but the kernel's equivalent does. So when code
>> was copied from the kernel signal-frame-setup/teardown
>> code, checks on error flags that were needed in the kernel
>> became dead code for us.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>  linux-user/m68k/signal.c  | 3 ---
>>  linux-user/sh4/signal.c   | 4 ----
>>  linux-user/sparc/signal.c | 2 --
>>  3 files changed, 9 deletions(-)
>>
>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Ping? Looks like you reviewed this but it hasn't made it into
a pullreq.

thanks
-- PMM

Re: [Qemu-devel] [PATCH] linux-user: Remove dead error-checking code
Posted by Laurent Vivier 5 years, 5 months ago
On 12/11/2018 15:38, Peter Maydell wrote:
> On 19 October 2018 at 17:26, Laurent Vivier <laurent@vivier.eu> wrote:
>> Le 19/10/2018 à 18:17, Peter Maydell a écrit :
>>> Remove some dead code spotted by Coverity (CID 1009855,
>>> 1390854, 1390847). The underlying cause in all these cases
>>> is the same: QEMU's put_user operations can't result in
>>> errors, but the kernel's equivalent does. So when code
>>> was copied from the kernel signal-frame-setup/teardown
>>> code, checks on error flags that were needed in the kernel
>>> became dead code for us.
>>>
>>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>>> ---
>>>  linux-user/m68k/signal.c  | 3 ---
>>>  linux-user/sh4/signal.c   | 4 ----
>>>  linux-user/sparc/signal.c | 2 --
>>>  3 files changed, 9 deletions(-)
>>>
>>
>> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> 
> Ping? Looks like you reviewed this but it hasn't made it into
> a pullreq.

Sorry... do you want it in 3.1?

Thanks,
Laurent

Re: [Qemu-devel] [PATCH] linux-user: Remove dead error-checking code
Posted by Peter Maydell 5 years, 5 months ago
On 12 November 2018 at 14:45, Laurent Vivier <laurent@vivier.eu> wrote:
> On 12/11/2018 15:38, Peter Maydell wrote:
>> On 19 October 2018 at 17:26, Laurent Vivier <laurent@vivier.eu> wrote:
>>> Le 19/10/2018 à 18:17, Peter Maydell a écrit :
>>>> Remove some dead code spotted by Coverity (CID 1009855,
>>>> 1390854, 1390847). The underlying cause in all these cases
>>>> is the same: QEMU's put_user operations can't result in
>>>> errors, but the kernel's equivalent does. So when code
>>>> was copied from the kernel signal-frame-setup/teardown
>>>> code, checks on error flags that were needed in the kernel
>>>> became dead code for us.
>>>>
>>>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>>>> ---
>>>>  linux-user/m68k/signal.c  | 3 ---
>>>>  linux-user/sh4/signal.c   | 4 ----
>>>>  linux-user/sparc/signal.c | 2 --
>>>>  3 files changed, 9 deletions(-)
>>>>
>>>
>>> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
>>
>> Ping? Looks like you reviewed this but it hasn't made it into
>> a pullreq.
>
> Sorry... do you want it in 3.1?

I think it would be nice to, since it does silence some Coverity
issues.

thanks
-- PMM