diff options
author | Cesar Eduardo Barros <cesarb@cesarb.net> | 2011-03-22 19:33:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-22 20:44:08 -0400 |
commit | bdb8e3f68320f897de3f3a4c363fe2802037f21d (patch) | |
tree | 0eeb4907e05daa418ec8e98c2492b4177ab67e3c /mm/swapfile.c | |
parent | 915d4d7bc0d719f2f0907273c01967d38751c625 (diff) |
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@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>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r-- | mm/swapfile.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index a0f39f9dc5a5..be0d0a28690e 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, | |||
1998 | sector_t *span) | 1998 | sector_t *span) |
1999 | { | 1999 | { |
2000 | int i; | 2000 | int i; |
2001 | int error; | ||
2002 | unsigned int nr_good_pages; | 2001 | unsigned int nr_good_pages; |
2003 | int nr_extents; | 2002 | int nr_extents; |
2004 | 2003 | ||
@@ -2006,10 +2005,8 @@ static int setup_swap_map_and_extents(struct swap_info_struct *p, | |||
2006 | 2005 | ||
2007 | for (i = 0; i < swap_header->info.nr_badpages; i++) { | 2006 | for (i = 0; i < swap_header->info.nr_badpages; i++) { |
2008 | unsigned int page_nr = swap_header->info.badpages[i]; | 2007 | unsigned int page_nr = swap_header->info.badpages[i]; |
2009 | if (page_nr == 0 || page_nr > swap_header->info.last_page) { | 2008 | if (page_nr == 0 || page_nr > swap_header->info.last_page) |
2010 | error = -EINVAL; | 2009 | return -EINVAL; |
2011 | goto bad_swap; | ||
2012 | } | ||
2013 | if (page_nr < maxpages) { | 2010 | if (page_nr < maxpages) { |
2014 | swap_map[page_nr] = SWAP_MAP_BAD; | 2011 | swap_map[page_nr] = SWAP_MAP_BAD; |
2015 | nr_good_pages--; | 2012 | nr_good_pages--; |
@@ -2021,22 +2018,16 @@ static int setup_swap_map_and_extents(struct swap_info_struct *p, | |||
2021 | p->max = maxpages; | 2018 | p->max = maxpages; |
2022 | p->pages = nr_good_pages; | 2019 | p->pages = nr_good_pages; |
2023 | nr_extents = setup_swap_extents(p, span); | 2020 | nr_extents = setup_swap_extents(p, span); |
2024 | if (nr_extents < 0) { | 2021 | if (nr_extents < 0) |
2025 | error = nr_extents; | 2022 | return nr_extents; |
2026 | goto bad_swap; | ||
2027 | } | ||
2028 | nr_good_pages = p->pages; | 2023 | nr_good_pages = p->pages; |
2029 | } | 2024 | } |
2030 | if (!nr_good_pages) { | 2025 | if (!nr_good_pages) { |
2031 | printk(KERN_WARNING "Empty swap-file\n"); | 2026 | printk(KERN_WARNING "Empty swap-file\n"); |
2032 | error = -EINVAL; | 2027 | return -EINVAL; |
2033 | goto bad_swap; | ||
2034 | } | 2028 | } |
2035 | 2029 | ||
2036 | return nr_extents; | 2030 | return nr_extents; |
2037 | |||
2038 | bad_swap: | ||
2039 | return error; | ||
2040 | } | 2031 | } |
2041 | 2032 | ||
2042 | SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) | 2033 | SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) |