Skip to contentSkip to conversation

erofs: using switch-case while checking the inode type.

PATCH In review Pratik Shinde 4 participants 6 messages Aug 30, 2019 – Sep 4, 2019 EROFS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fs/erofs/inode.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
fs/erofs/inode.c +12 -6
index 80f4fe9..6336cc1 100644
@@ -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;
 		}
Signature · 1 line
2.9.3
#1 lore raw

Hi Pratik,

The subject line could be better as '[PATCH v2] xxxxxx'...

Quoted 5 lines · Pratik Shinde

while filling the linux inode, using switch-case statement to check the type of inode.
switch-case statement looks more clean here.

I have no problem of this patch, and I will do a test and reply you "Reviewed-by:" in hours (I'm doing another patchset to resolve what Christoph suggested again)...

Thanks,
Gao Xiang

Quoted 50 lines
---
 fs/erofs/inode.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
fs/erofs/inode.c +12 -6
index 80f4fe9..6336cc1 100644
@@ -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;
 		}
Signature · 6 lines
2.9.3

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Reviewed-by
#2 lore raw
Quoted 9 lines · Gao Xiang

Hi Pratik,

The subject line could be better as '[PATCH v2] xxxxxx'...

Quoted 4 lines · Pratik Shinde

while filling the linux inode, using switch-case statement to check the type of inode.
switch-case statement looks more clean here.

Quoted 5 lines
Quoted 1 line

I have no problem of this patch, and I will do a test and reply you "Reviewed-by:" in hours (I'm doing another patchset to resolve what Christoph suggested again)...

Thanks,
Gao Xiang

Quoted 54 lines

Thanks,
Gao Xiang

Quoted 50 lines
---
 fs/erofs/inode.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
fs/erofs/inode.c +12 -6
index 80f4fe9..6336cc1 100644
@@ -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;
 		}
Signature · 6 lines
2.9.3

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
#3 lore raw

Hi Greg,

Quoted 10 lines · Gao Xiang
Quoted 9 lines · Gao Xiang

Hi Pratik,

The subject line could be better as '[PATCH v2] xxxxxx'...

Quoted 4 lines · Pratik Shinde

while filling the linux inode, using switch-case statement to check the type of inode.
switch-case statement looks more clean here.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I have no problem of this patch, and I will do a test and reply you "Reviewed-by:" in hours (I'm doing another patchset to resolve what Christoph suggested again)...

ping.. could you kindly merge this patch, the following patchset has dependency on it...

Thanks,
Gao Xiang

Quoted 58 lines

Thanks,
Gao Xiang

Quoted 54 lines

Thanks,
Gao Xiang

Quoted 50 lines
---
 fs/erofs/inode.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
fs/erofs/inode.c +12 -6
index 80f4fe9..6336cc1 100644
@@ -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;
 		}
Signature · 6 lines
2.9.3

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
#4 lore raw
Quoted 15 lines · Gao Xiang

Hi Greg,

Quoted 12 lines · Gao Xiang
Quoted 11 lines · Gao Xiang

Hi Pratik,

The subject line could be better as '[PATCH v2] xxxxxx'...

Quoted 5 lines · Pratik Shinde

while filling the linux inode, using switch-case statement to check the type of inode.
switch-case statement looks more clean here.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I have no problem of this patch, and I will do a test and reply you "Reviewed-by:" in hours (I'm doing another patchset to resolve what Christoph suggested again)...

ping.. could you kindly merge this patch, the following patchset has dependency on it...

Will go do that now, sorry for the delay.

greg k-h

#5 lore raw
Quoted 20 lines · Greg KH
Quoted 19 lines · Gao Xiang

Hi Greg,

Quoted 16 lines · Gao Xiang
Quoted 14 lines · Gao Xiang

Hi Pratik,

The subject line could be better as '[PATCH v2] xxxxxx'...

Quoted 5 lines · Pratik Shinde

while filling the linux inode, using switch-case statement to check the type of inode.
switch-case statement looks more clean here.

I have no problem of this patch, and I will do a test and reply you "Reviewed-by:" in hours (I'm doing another patchset to resolve what Christoph suggested again)...

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

ping.. could you kindly merge this patch, the following patchset has dependency on it...

Will go do that now, sorry for the delay.

Thanks Greg...

Thanks,
Gao Xiang

Quoted 2 lines

greg k-h