[PULL 07/24] linux-user: Do not call get_errno() in do_brk()

Richard Henderson posted 24 patches 1 year, 3 months ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Laurent Vivier <laurent@vivier.eu>, Brian Cain <bcain@quicinc.com>
[PULL 07/24] linux-user: Do not call get_errno() in do_brk()
Posted by Richard Henderson 1 year, 3 months ago
From: Akihiko Odaki <akihiko.odaki@daynix.com>

Later the returned value is compared with -1, and negated errno is not
expected.

Fixes: 00faf08c95 ("linux-user: Don't use MAP_FIXED in do_brk()")
Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-Id: <20230802071754.14876-4-akihiko.odaki@daynix.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 95727a816a..b9d2ec02f9 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -862,9 +862,9 @@ abi_long do_brk(abi_ulong brk_val)
      */
     if (new_host_brk_page > brk_page) {
         new_alloc_size = new_host_brk_page - brk_page;
-        mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size,
-                                        PROT_READ|PROT_WRITE,
-                                        MAP_ANON|MAP_PRIVATE, 0, 0));
+        mapped_addr = target_mmap(brk_page, new_alloc_size,
+                                  PROT_READ|PROT_WRITE,
+                                  MAP_ANON|MAP_PRIVATE, 0, 0);
     } else {
         new_alloc_size = 0;
         mapped_addr = brk_page;
-- 
2.34.1
Re: [PULL 07/24] linux-user: Do not call get_errno() in do_brk()
Posted by Michael Tokarev 1 year, 3 months ago
06.08.2023 06:36, Richard Henderson wrote:

> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c

> -        mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size,
> -                                        PROT_READ|PROT_WRITE,
> -                                        MAP_ANON|MAP_PRIVATE, 0, 0));
> +        mapped_addr = target_mmap(brk_page, new_alloc_size,
> +                                  PROT_READ|PROT_WRITE,
> +                                  MAP_ANON|MAP_PRIVATE, 0, 0);

Can't we add spaces around "|" here at apply time to make checkpatch happy?
Just a nitpick really..  I thought this will be done in some of the Vn,
but it is not.

/mjt
Re: [PULL 07/24] linux-user: Do not call get_errno() in do_brk()
Posted by Richard Henderson 1 year, 3 months ago
On 8/5/23 23:53, Michael Tokarev wrote:
> 06.08.2023 06:36, Richard Henderson wrote:
> 
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
> 
>> -        mapped_addr = get_errno(target_mmap(brk_page, new_alloc_size,
>> -                                        PROT_READ|PROT_WRITE,
>> -                                        MAP_ANON|MAP_PRIVATE, 0, 0));
>> +        mapped_addr = target_mmap(brk_page, new_alloc_size,
>> +                                  PROT_READ|PROT_WRITE,
>> +                                  MAP_ANON|MAP_PRIVATE, 0, 0);
> 
> Can't we add spaces around "|" here at apply time to make checkpatch happy?
> Just a nitpick really..  I thought this will be done in some of the Vn,
> but it is not.

Since I had to re-spin, I did so.


r~