* [PATCH] fs: use the switch statement in init_special_inode()
@ 2025-09-09 7:54 Mateusz Guzik
2025-09-09 11:15 ` Jan Kara
2025-09-15 12:19 ` Christian Brauner
0 siblings, 2 replies; 3+ messages in thread
From: Mateusz Guzik @ 2025-09-09 7:54 UTC (permalink / raw)
To: brauner; +Cc: viro, jack, linux-kernel, linux-fsdevel, Mateusz Guzik
Similar to may_open().
No functional changes.
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
fs/inode.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/fs/inode.c b/fs/inode.c
index 01ebdc40021e..8c520a22afba 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2519,21 +2519,28 @@ void __init inode_init(void)
void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev)
{
inode->i_mode = mode;
- if (S_ISCHR(mode)) {
+ switch (inode->i_mode & S_IFMT) {
+ case S_IFCHR:
inode->i_fop = &def_chr_fops;
inode->i_rdev = rdev;
- } else if (S_ISBLK(mode)) {
+ break;
+ case S_IFBLK:
if (IS_ENABLED(CONFIG_BLOCK))
inode->i_fop = &def_blk_fops;
inode->i_rdev = rdev;
- } else if (S_ISFIFO(mode))
+ break;
+ case S_IFIFO:
inode->i_fop = &pipefifo_fops;
- else if (S_ISSOCK(mode))
- ; /* leave it no_open_fops */
- else
+ break;
+ case S_IFSOCK:
+ /* leave it no_open_fops */
+ break;
+ default:
printk(KERN_DEBUG "init_special_inode: bogus i_mode (%o) for"
" inode %s:%lu\n", mode, inode->i_sb->s_id,
inode->i_ino);
+ break;
+ }
}
EXPORT_SYMBOL(init_special_inode);
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] fs: use the switch statement in init_special_inode()
2025-09-09 7:54 [PATCH] fs: use the switch statement in init_special_inode() Mateusz Guzik
@ 2025-09-09 11:15 ` Jan Kara
2025-09-15 12:19 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2025-09-09 11:15 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: brauner, viro, jack, linux-kernel, linux-fsdevel
On Tue 09-09-25 09:54:58, Mateusz Guzik wrote:
> Similar to may_open().
>
> No functional changes.
>
> Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Looks sane. Just one style nit below. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
> - else if (S_ISSOCK(mode))
> - ; /* leave it no_open_fops */
> - else
> + break;
> + case S_IFSOCK:
> + /* leave it no_open_fops */
> + break;
> + default:
> printk(KERN_DEBUG "init_special_inode: bogus i_mode (%o) for"
> " inode %s:%lu\n", mode, inode->i_sb->s_id,
> inode->i_ino);
> + break;
We usually don't bother with 'break' for the 'default' label.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: use the switch statement in init_special_inode()
2025-09-09 7:54 [PATCH] fs: use the switch statement in init_special_inode() Mateusz Guzik
2025-09-09 11:15 ` Jan Kara
@ 2025-09-15 12:19 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2025-09-15 12:19 UTC (permalink / raw)
To: Mateusz Guzik; +Cc: Christian Brauner, viro, jack, linux-kernel, linux-fsdevel
On Tue, 09 Sep 2025 09:54:58 +0200, Mateusz Guzik wrote:
> Similar to may_open().
>
> No functional changes.
>
>
Applied to the vfs-6.18.misc branch of the vfs/vfs.git tree.
Patches in the vfs-6.18.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.18.misc
[1/1] fs: use the switch statement in init_special_inode()
https://git.kernel.org/vfs/vfs/c/4635c2c8bd5c
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-15 12:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-09 7:54 [PATCH] fs: use the switch statement in init_special_inode() Mateusz Guzik
2025-09-09 11:15 ` Jan Kara
2025-09-15 12:19 ` Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®