[PATCH] mmap_region: cleanup, remove unneeded file != NULL check

From: Oleg Nesterov
Date: Sun Feb 03 2008 - 12:58:24 EST


mmap_region() checks "file != NULL" when we know "file && vma_merge() == T".
Also, swap these if/else branches, imho make the code a bit more readable.

Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>

--- MM/mm/mmap.c~1_MMAP 2008-01-27 17:09:47.000000000 +0300
+++ MM/mm/mmap.c 2008-02-03 20:49:39.000000000 +0300
@@ -1189,22 +1189,20 @@ munmap_back:
if (vma_wants_writenotify(vma))
vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED);

- if (!file || !vma_merge(mm, prev, addr, vma->vm_end,
+ if (file && vma_merge(mm, prev, addr, vma->vm_end,
vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) {
+ mpol_free(vma_policy(vma));
+ kmem_cache_free(vm_area_cachep, vma);
+ if (correct_wcount)
+ atomic_inc(&inode->i_writecount);
+ fput(file);
+ } else {
file = vma->vm_file;
vma_link(mm, vma, prev, rb_link, rb_parent);
if (correct_wcount)
atomic_inc(&inode->i_writecount);
- } else {
- if (file) {
- if (correct_wcount)
- atomic_inc(&inode->i_writecount);
- fput(file);
- }
- mpol_free(vma_policy(vma));
- kmem_cache_free(vm_area_cachep, vma);
}
-out:
+out:
mm->total_vm += len >> PAGE_SHIFT;
vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
if (vm_flags & VM_LOCKED) {

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/