lkml.org 
[lkml]   [2015]   [Mar]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm/mmap.c: use while instead of if+goto
On Mon, Mar 30, 2015 at 09:40:35PM +0200, Rasmus Villemoes wrote:
> The creators of the C language gave us the while keyword. Let's use
> that instead of synthesizing it from if+goto.
>
> Made possible by 6597d783397a ("mm/mmap.c: replace find_vma_prepare()
> with clearer find_vma_links()").
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>


Looks good, except both your plus-lines are over 80-characters long for no
reason.

> ---
> mm/mmap.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index da9990acc08b..e1ae629b1e9c 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -1553,11 +1553,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
>
> /* Clear old maps */
> error = -ENOMEM;
> -munmap_back:
> - if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
> + while (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
> if (do_munmap(mm, addr, len))
> return -ENOMEM;
> - goto munmap_back;
> }
>
> /*
> @@ -2741,11 +2739,9 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
> /*
> * Clear old maps. this also does some error checking for us
> */
> - munmap_back:
> - if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
> + while (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
> if (do_munmap(mm, addr, len))
> return -ENOMEM;
> - goto munmap_back;
> }
>
> /* Check against address space limits *after* clearing old maps... */
--
Kirill A. Shutemov


\
 
 \ /
  Last update: 2015-03-30 23:21    [W:0.058 / U:1.720 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site