aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorCesar Eduardo Barros <cesarb@cesarb.net>2011-03-22 19:33:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-22 20:44:08 -0400
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 5e13bff1764c..058a9dfefefd 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1928,7 +1928,7 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
1928 1928
1929 if (memcmp("SWAPSPACE2", swap_header->magic.magic, 10)) { 1929 if (memcmp("SWAPSPACE2", swap_header->magic.magic, 10)) {
1930 printk(KERN_ERR "Unable to find swap-space signature\n"); 1930 printk(KERN_ERR "Unable to find swap-space signature\n");
1931 goto bad_swap; 1931 return 0;
1932 } 1932 }
1933 1933
1934 /* swap partition endianess hack... */ 1934 /* swap partition endianess hack... */
@@ -1944,7 +1944,7 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
1944 printk(KERN_WARNING 1944 printk(KERN_WARNING
1945 "Unable to handle swap header version %d\n", 1945 "Unable to handle swap header version %d\n",
1946 swap_header->info.version); 1946 swap_header->info.version);
1947 goto bad_swap; 1947 return 0;
1948 } 1948 }
1949 1949
1950 p->lowest_bit = 1; 1950 p->lowest_bit = 1;
@@ -1976,22 +1976,19 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
1976 p->highest_bit = maxpages - 1; 1976 p->highest_bit = maxpages - 1;
1977 1977
1978 if (!maxpages) 1978 if (!maxpages)
1979 goto bad_swap; 1979 return 0;
1980 swapfilepages = i_size_read(inode) >> PAGE_SHIFT; 1980 swapfilepages = i_size_read(inode) >> PAGE_SHIFT;
1981 if (swapfilepages && maxpages > swapfilepages) { 1981 if (swapfilepages && maxpages > swapfilepages) {
1982 printk(KERN_WARNING 1982 printk(KERN_WARNING
1983 "Swap area shorter than signature indicates\n"); 1983 "Swap area shorter than signature indicates\n");
1984 goto bad_swap; 1984 return 0;
1985 } 1985 }
1986 if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode)) 1986 if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode))
1987 goto bad_swap; 1987 return 0;
1988 if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES) 1988 if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES)
1989 goto bad_swap; 1989 return 0;
1990 1990
1991 return maxpages; 1991 return maxpages;
1992
1993bad_swap:
1994 return 0;
1995} 1992}
1996 1993
1997SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) 1994SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)