2020-12-22 10:36:24

by Huang Adrian

[permalink] [raw]
Subject: [PATCH 1/1] mm: mmap: Remove unnecessary local variable

From: Adrian Huang <[email protected]>

The local variable 'retval' is assigned just for once in __do_sys_brk(),
and the function returns the value of the local variable right after
the assignment. Remove unnecessary assignment and local variable
declaration.

Signed-off-by: Adrian Huang <[email protected]>
---
mm/mmap.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index dc7206032387..482c0c0bbe06 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -189,7 +189,6 @@ static int do_brk_flags(unsigned long addr, unsigned long request, unsigned long
struct list_head *uf);
SYSCALL_DEFINE1(brk, unsigned long, brk)
{
- unsigned long retval;
unsigned long newbrk, oldbrk, origbrk;
struct mm_struct *mm = current->mm;
struct vm_area_struct *next;
@@ -281,9 +280,8 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
return brk;

out:
- retval = origbrk;
mmap_write_unlock(mm);
- return retval;
+ return origbrk;
}

static inline unsigned long vma_compute_gap(struct vm_area_struct *vma)
--
2.17.1


2020-12-22 15:19:51

by Souptick Joarder

[permalink] [raw]
Subject: Re: [PATCH 1/1] mm: mmap: Remove unnecessary local variable

On Tue, Dec 22, 2020 at 4:03 PM Adrian Huang <[email protected]> wrote:
>
> From: Adrian Huang <[email protected]>
>
> The local variable 'retval' is assigned just for once in __do_sys_brk(),
> and the function returns the value of the local variable right after
> the assignment. Remove unnecessary assignment and local variable
> declaration.
>
> Signed-off-by: Adrian Huang <[email protected]>

Acked-by: Souptick Joarder <[email protected]>

> ---
> mm/mmap.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index dc7206032387..482c0c0bbe06 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -189,7 +189,6 @@ static int do_brk_flags(unsigned long addr, unsigned long request, unsigned long
> struct list_head *uf);
> SYSCALL_DEFINE1(brk, unsigned long, brk)
> {
> - unsigned long retval;
> unsigned long newbrk, oldbrk, origbrk;
> struct mm_struct *mm = current->mm;
> struct vm_area_struct *next;
> @@ -281,9 +280,8 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
> return brk;
>
> out:
> - retval = origbrk;
> mmap_write_unlock(mm);
> - return retval;
> + return origbrk;
> }
>
> static inline unsigned long vma_compute_gap(struct vm_area_struct *vma)
> --
> 2.17.1
>
>

2020-12-29 09:21:44

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH 1/1] mm: mmap: Remove unnecessary local variable

On 22.12.20 11:32, Adrian Huang wrote:
> From: Adrian Huang <[email protected]>
>
> The local variable 'retval' is assigned just for once in __do_sys_brk(),
> and the function returns the value of the local variable right after
> the assignment. Remove unnecessary assignment and local variable
> declaration.
>
> Signed-off-by: Adrian Huang <[email protected]>
> ---
> mm/mmap.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index dc7206032387..482c0c0bbe06 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -189,7 +189,6 @@ static int do_brk_flags(unsigned long addr, unsigned long request, unsigned long
> struct list_head *uf);
> SYSCALL_DEFINE1(brk, unsigned long, brk)
> {
> - unsigned long retval;
> unsigned long newbrk, oldbrk, origbrk;
> struct mm_struct *mm = current->mm;
> struct vm_area_struct *next;
> @@ -281,9 +280,8 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
> return brk;
>
> out:
> - retval = origbrk;
> mmap_write_unlock(mm);
> - return retval;
> + return origbrk;
> }

Reviewed-by: David Hildenbrand <[email protected]>


--
Thanks,

David / dhildenb