linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/vfs: improve __mnt_is_readonly
@ 2016-03-25  2:01 Yaowei Bai
  2016-03-26  0:43 ` Al Viro
  0 siblings, 1 reply; 6+ messages in thread
From: Yaowei Bai @ 2016-03-25  2:01 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, linux-kernel, baiyaowei

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@cmss.chinamobile.com>
---
 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-03-30  7:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-25  2:01 [PATCH] fs/vfs: improve __mnt_is_readonly Yaowei Bai
2016-03-26  0:43 ` Al Viro
2016-03-29  6:35   ` Yaowei Bai
2016-03-29  9:43     ` Richard Weinberger
2016-03-30  1:23       ` Yaowei Bai
2016-03-30  7:30         ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).