diff options
author | Pratik Shinde <pratikshinde320@gmail.com> | 2019-08-30 15:26:15 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-09-04 08:31:54 +0200 |
commit | 512f9922eeb1e5b0b1e099fd56829e1dad993437 (patch) | |
tree | c02079f727c82463fd2c92a07425364799fb7f54 /fs/erofs | |
parent | 3b531807e605bfa8290531a63886d1972809e310 (diff) | |
download | linux-stable-512f9922eeb1e5b0b1e099fd56829e1dad993437.tar.gz linux-stable-512f9922eeb1e5b0b1e099fd56829e1dad993437.tar.bz2 linux-stable-512f9922eeb1e5b0b1e099fd56829e1dad993437.zip |
erofs: using switch-case while checking the inode type.
while filling the linux inode, using switch-case statement to check
the type of inode.
switch-case statement looks more clean here.
Signed-off-by: Pratik Shinde <pratikshinde320@gmail.com>
Reviewed-by: Gao Xiang <gaoxiang25@huawei.com>
Link: https://lore.kernel.org/r/20190830095615.10995-1-pratikshinde320@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/erofs')
-rw-r--r-- | fs/erofs/inode.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index e7c190cf101a..8a0574530a0a 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -190,22 +190,28 @@ static int fill_inode(struct inode *inode, int isdir) err = read_inode(inode, data + ofs); if (!err) { /* setup the new inode */ - if (S_ISREG(inode->i_mode)) { + switch (inode->i_mode & S_IFMT) { + case S_IFREG: inode->i_op = &erofs_generic_iops; inode->i_fop = &generic_ro_fops; - } else if (S_ISDIR(inode->i_mode)) { + break; + case S_IFDIR: inode->i_op = &erofs_dir_iops; inode->i_fop = &erofs_dir_fops; - } else if (S_ISLNK(inode->i_mode)) { + break; + case S_IFLNK: /* by default, page_get_link is used for symlink */ inode->i_op = &erofs_symlink_iops; inode_nohighmem(inode); - } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || - S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { + break; + case S_IFCHR: + case S_IFBLK: + case S_IFIFO: + case S_IFSOCK: inode->i_op = &erofs_generic_iops; init_special_inode(inode, inode->i_mode, inode->i_rdev); goto out_unlock; - } else { + default: err = -EFSCORRUPTED; goto out_unlock; } |