Commit 87ade72a799a9a895b4a60918c32b43d3dfc3324
Committed by
Linus Torvalds
1 parent
4d0e1e1075
Exists in
master
and in
7 other branches
sys_swapon: simplify error flow in claim_swapfile()
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 14 deletions Side-by-side Diff
mm/swapfile.c
... | ... | @@ -1900,30 +1900,22 @@ |
1900 | 1900 | sys_swapon); |
1901 | 1901 | if (error < 0) { |
1902 | 1902 | p->bdev = NULL; |
1903 | - error = -EINVAL; | |
1904 | - goto bad_swap; | |
1903 | + return -EINVAL; | |
1905 | 1904 | } |
1906 | 1905 | p->old_block_size = block_size(p->bdev); |
1907 | 1906 | error = set_blocksize(p->bdev, PAGE_SIZE); |
1908 | 1907 | if (error < 0) |
1909 | - goto bad_swap; | |
1908 | + return error; | |
1910 | 1909 | p->flags |= SWP_BLKDEV; |
1911 | 1910 | } else if (S_ISREG(inode->i_mode)) { |
1912 | 1911 | p->bdev = inode->i_sb->s_bdev; |
1913 | 1912 | mutex_lock(&inode->i_mutex); |
1914 | - if (IS_SWAPFILE(inode)) { | |
1915 | - error = -EBUSY; | |
1916 | - goto bad_swap; | |
1917 | - } | |
1918 | - } else { | |
1919 | - error = -EINVAL; | |
1920 | - goto bad_swap; | |
1921 | - } | |
1913 | + if (IS_SWAPFILE(inode)) | |
1914 | + return -EBUSY; | |
1915 | + } else | |
1916 | + return -EINVAL; | |
1922 | 1917 | |
1923 | 1918 | return 0; |
1924 | - | |
1925 | -bad_swap: | |
1926 | - return error; | |
1927 | 1919 | } |
1928 | 1920 | |
1929 | 1921 | SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) |