Skip to content

Commit

Permalink
mm/mmap.c: use while instead of if+goto
Browse files Browse the repository at this point in the history
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 6597d78 ("mm/mmap.c: replace find_vma_prepare()
with clearer find_vma_links()").

[[email protected]: fix 80-col overflows]
Signed-off-by: Rasmus Villemoes <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Cc: Sasha Levin <[email protected]>
Cc: Cyrill Gorcunov <[email protected]>
Cc: Roman Gushchin <[email protected]>
Cc: Hugh Dickins <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Villemoes authored and torvalds committed Apr 15, 2015
1 parent 215ba78 commit 9fcd145
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1551,11 +1551,10 @@ 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;
}

/*
Expand All @@ -1571,7 +1570,8 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
/*
* Can we just expand an old mapping?
*/
vma = vma_merge(mm, prev, addr, addr + len, vm_flags, NULL, file, pgoff, NULL);
vma = vma_merge(mm, prev, addr, addr + len, vm_flags, NULL, file, pgoff,
NULL);
if (vma)
goto out;

Expand Down Expand Up @@ -2739,11 +2739,10 @@ 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... */
Expand Down

0 comments on commit 9fcd145

Please sign in to comment.