sys_swapon: simplify error flow in setup_swap_map_and_extents()
authorCesar Eduardo Barros <cesarb@cesarb.net>
Tue, 22 Mar 2011 23:33:33 +0000 (16:33 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 23 Mar 2011 00:44:08 +0000 (17:44 -0700)
Since there is no cleanup to do, there is no reason to jump to a label.
Return directly instead.

Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>
Tested-by: Eric B Munson <emunson@mgebm.net>
Acked-by: Eric B Munson <emunson@mgebm.net>
Reviewed-by: Pekka Enberg <penberg@kernel.org>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/swapfile.c

index a0f39f9..be0d0a2 100644 (file)
@@ -1998,7 +1998,6 @@ static int setup_swap_map_and_extents(struct swap_info_struct *p,
                                        sector_t *span)
 {
        int i;
-       int error;
        unsigned int nr_good_pages;
        int nr_extents;
 
@@ -2006,10 +2005,8 @@ static int setup_swap_map_and_extents(struct swap_info_struct *p,
 
        for (i = 0; i < swap_header->info.nr_badpages; i++) {
                unsigned int page_nr = swap_header->info.badpages[i];
-               if (page_nr == 0 || page_nr > swap_header->info.last_page) {
-                       error = -EINVAL;
-                       goto bad_swap;
-               }
+               if (page_nr == 0 || page_nr > swap_header->info.last_page)
+                       return -EINVAL;
                if (page_nr < maxpages) {
                        swap_map[page_nr] = SWAP_MAP_BAD;
                        nr_good_pages--;
@@ -2021,22 +2018,16 @@ static int setup_swap_map_and_extents(struct swap_info_struct *p,
                p->max = maxpages;
                p->pages = nr_good_pages;
                nr_extents = setup_swap_extents(p, span);
-               if (nr_extents < 0) {
-                       error = nr_extents;
-                       goto bad_swap;
-               }
+               if (nr_extents < 0)
+                       return nr_extents;
                nr_good_pages = p->pages;
        }
        if (!nr_good_pages) {
                printk(KERN_WARNING "Empty swap-file\n");
-               error = -EINVAL;
-               goto bad_swap;
+               return -EINVAL;
        }
 
        return nr_extents;
-
-bad_swap:
-       return error;
 }
 
 SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)