Commit bdb8e3f68320f897de3f3a4c363fe2802037f21d
Committed by
Linus Torvalds
1 parent
915d4d7bc0
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 5 additions and 14 deletions Side-by-side Diff
mm/swapfile.c
... | ... | @@ -1998,7 +1998,6 @@ |
1998 | 1998 | sector_t *span) |
1999 | 1999 | { |
2000 | 2000 | int i; |
2001 | - int error; | |
2002 | 2001 | unsigned int nr_good_pages; |
2003 | 2002 | int nr_extents; |
2004 | 2003 | |
... | ... | @@ -2006,10 +2005,8 @@ |
2006 | 2005 | |
2007 | 2006 | for (i = 0; i < swap_header->info.nr_badpages; i++) { |
2008 | 2007 | unsigned int page_nr = swap_header->info.badpages[i]; |
2009 | - if (page_nr == 0 || page_nr > swap_header->info.last_page) { | |
2010 | - error = -EINVAL; | |
2011 | - goto bad_swap; | |
2012 | - } | |
2008 | + if (page_nr == 0 || page_nr > swap_header->info.last_page) | |
2009 | + return -EINVAL; | |
2013 | 2010 | if (page_nr < maxpages) { |
2014 | 2011 | swap_map[page_nr] = SWAP_MAP_BAD; |
2015 | 2012 | nr_good_pages--; |
2016 | 2013 | |
2017 | 2014 | |
... | ... | @@ -2021,22 +2018,16 @@ |
2021 | 2018 | p->max = maxpages; |
2022 | 2019 | p->pages = nr_good_pages; |
2023 | 2020 | nr_extents = setup_swap_extents(p, span); |
2024 | - if (nr_extents < 0) { | |
2025 | - error = nr_extents; | |
2026 | - goto bad_swap; | |
2027 | - } | |
2021 | + if (nr_extents < 0) | |
2022 | + return nr_extents; | |
2028 | 2023 | nr_good_pages = p->pages; |
2029 | 2024 | } |
2030 | 2025 | if (!nr_good_pages) { |
2031 | 2026 | printk(KERN_WARNING "Empty swap-file\n"); |
2032 | - error = -EINVAL; | |
2033 | - goto bad_swap; | |
2027 | + return -EINVAL; | |
2034 | 2028 | } |
2035 | 2029 | |
2036 | 2030 | return nr_extents; |
2037 | - | |
2038 | -bad_swap: | |
2039 | - return error; | |
2040 | 2031 | } |
2041 | 2032 | |
2042 | 2033 | SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) |