summaryrefslogtreecommitdiff
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorCesar Eduardo Barros <cesarb@cesarb.net>2011-03-22 16:33:30 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-22 17:44:08 -0700
commit38719025384cf7121331bd6d41c062d3c5f7bb91 (patch)
tree8848283db6cd61b426491f17de38d9bc15697514 /mm/swapfile.c
parentca8bd38bf6f05481c4155fc444178151884f65d0 (diff)
sys_swapon: simplify error flow in read_swap_header()
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: 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.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 5e13bff1764..058a9dfefef 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1928,7 +1928,7 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
if (memcmp("SWAPSPACE2", swap_header->magic.magic, 10)) {
printk(KERN_ERR "Unable to find swap-space signature\n");
- goto bad_swap;
+ return 0;
}
/* swap partition endianess hack... */
@@ -1944,7 +1944,7 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
printk(KERN_WARNING
"Unable to handle swap header version %d\n",
swap_header->info.version);
- goto bad_swap;
+ return 0;
}
p->lowest_bit = 1;
@@ -1976,22 +1976,19 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
p->highest_bit = maxpages - 1;
if (!maxpages)
- goto bad_swap;
+ return 0;
swapfilepages = i_size_read(inode) >> PAGE_SHIFT;
if (swapfilepages && maxpages > swapfilepages) {
printk(KERN_WARNING
"Swap area shorter than signature indicates\n");
- goto bad_swap;
+ return 0;
}
if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode))
- goto bad_swap;
+ return 0;
if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES)
- goto bad_swap;
+ return 0;
return maxpages;
-
-bad_swap:
- return 0;
}
SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)