[PATCH] fs/vfs: improve __mnt_is_readonly

From: Yaowei Bai
Date: Thu Mar 24 2016 - 22:01:57 EST


This patch refactors __mnt_is_readonly and makes it return bool to
improve readability due to this particular function only using either
one or zero as its return value.

No functional change.

Signed-off-by: Yaowei Bai <baiyaowei@xxxxxxxxxxxxxxxxxxxx>
---
fs/namespace.c | 9 +++------
include/linux/mount.h | 2 +-
2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 4fb1691..4f2facd 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -271,13 +271,10 @@ out_free_cache:
* mnt_want/drop_write() will _keep_ the filesystem
* r/w.
*/
-int __mnt_is_readonly(struct vfsmount *mnt)
+bool __mnt_is_readonly(struct vfsmount *mnt)
{
- if (mnt->mnt_flags & MNT_READONLY)
- return 1;
- if (mnt->mnt_sb->s_flags & MS_RDONLY)
- return 1;
- return 0;
+ return mnt->mnt_flags & MNT_READONLY ||
+ mnt->mnt_sb->s_flags & MS_RDONLY;
}
EXPORT_SYMBOL_GPL(__mnt_is_readonly);

diff --git a/include/linux/mount.h b/include/linux/mount.h
index f822c3c..c143e15 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -80,7 +80,7 @@ extern void mnt_drop_write_file(struct file *file);
extern void mntput(struct vfsmount *mnt);
extern struct vfsmount *mntget(struct vfsmount *mnt);
extern struct vfsmount *mnt_clone_internal(struct path *path);
-extern int __mnt_is_readonly(struct vfsmount *mnt);
+extern bool __mnt_is_readonly(struct vfsmount *mnt);

struct path;
extern struct vfsmount *clone_private_mount(struct path *path);
--
1.9.1