[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1299343345-3984-21-git-send-email-cesarb@cesarb.net>
Date: Sat, 5 Mar 2011 13:42:21 -0300
From: Cesar Eduardo Barros <cesarb@...arb.net>
To: linux-mm@...ck.org
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Hugh Dickins <hughd@...gle.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Minchan Kim <minchan.kim@...il.com>,
Jens Axboe <jaxboe@...ionio.com>, linux-kernel@...r.kernel.org,
Eric B Munson <emunson@...bm.net>,
Cesar Eduardo Barros <cesarb@...arb.net>
Subject: [PATCHv2 20/24] sys_swapon: simplify error flow in setup_swap_map_and_extents
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@...arb.net>
Tested-by: Eric B Munson <emunson@...bm.net>
Acked-by: Eric B Munson <emunson@...bm.net>
---
mm/swapfile.c | 19 +++++--------------
1 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 26eb84a..5f6df81 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -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)
--
1.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists