Commit 38719025384cf7121331bd6d41c062d3c5f7bb91
Committed by
Linus Torvalds
1 parent
ca8bd38bf6
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 6 additions and 9 deletions Side-by-side Diff
mm/swapfile.c
... | ... | @@ -1928,7 +1928,7 @@ |
1928 | 1928 | |
1929 | 1929 | if (memcmp("SWAPSPACE2", swap_header->magic.magic, 10)) { |
1930 | 1930 | printk(KERN_ERR "Unable to find swap-space signature\n"); |
1931 | - goto bad_swap; | |
1931 | + return 0; | |
1932 | 1932 | } |
1933 | 1933 | |
1934 | 1934 | /* swap partition endianess hack... */ |
... | ... | @@ -1944,7 +1944,7 @@ |
1944 | 1944 | printk(KERN_WARNING |
1945 | 1945 | "Unable to handle swap header version %d\n", |
1946 | 1946 | swap_header->info.version); |
1947 | - goto bad_swap; | |
1947 | + return 0; | |
1948 | 1948 | } |
1949 | 1949 | |
1950 | 1950 | p->lowest_bit = 1; |
1951 | 1951 | |
1952 | 1952 | |
1953 | 1953 | |
1954 | 1954 | |
... | ... | @@ -1976,22 +1976,19 @@ |
1976 | 1976 | p->highest_bit = maxpages - 1; |
1977 | 1977 | |
1978 | 1978 | if (!maxpages) |
1979 | - goto bad_swap; | |
1979 | + return 0; | |
1980 | 1980 | swapfilepages = i_size_read(inode) >> PAGE_SHIFT; |
1981 | 1981 | if (swapfilepages && maxpages > swapfilepages) { |
1982 | 1982 | printk(KERN_WARNING |
1983 | 1983 | "Swap area shorter than signature indicates\n"); |
1984 | - goto bad_swap; | |
1984 | + return 0; | |
1985 | 1985 | } |
1986 | 1986 | if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode)) |
1987 | - goto bad_swap; | |
1987 | + return 0; | |
1988 | 1988 | if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES) |
1989 | - goto bad_swap; | |
1989 | + return 0; | |
1990 | 1990 | |
1991 | 1991 | return maxpages; |
1992 | - | |
1993 | -bad_swap: | |
1994 | - return 0; | |
1995 | 1992 | } |
1996 | 1993 | |
1997 | 1994 | SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) |