diff mbox

fs/vfs: improve __mnt_is_readonly

Message ID 1458871286-3099-1-git-send-email-baiyaowei@cmss.chinamobile.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yaowei Bai March 25, 2016, 2:01 a.m. UTC
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(-)

Comments

Al Viro March 26, 2016, 12:43 a.m. UTC | #1
On Fri, Mar 25, 2016 at 10:01:26AM +0800, Yaowei Bai wrote:
> 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.

Improve in which way, if I may ask?
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yaowei Bai March 29, 2016, 6:35 a.m. UTC | #2
On Sat, Mar 26, 2016 at 12:43:32AM +0000, Al Viro wrote:
> On Fri, Mar 25, 2016 at 10:01:26AM +0800, Yaowei Bai wrote:
> > 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.
> 
> Improve in which way, if I may ask?

A boolean return value can be more matchable with function's name and
more suitable as this function only returns 0/1.


--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Richard Weinberger March 29, 2016, 9:43 a.m. UTC | #3
On Tue, Mar 29, 2016 at 8:35 AM, Yaowei Bai
<baiyaowei@cmss.chinamobile.com> wrote:
> On Sat, Mar 26, 2016 at 12:43:32AM +0000, Al Viro wrote:
>> On Fri, Mar 25, 2016 at 10:01:26AM +0800, Yaowei Bai wrote:
>> > 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.
>>
>> Improve in which way, if I may ask?
>
> A boolean return value can be more matchable with function's name and
> more suitable as this function only returns 0/1.

Please also think of the arguments made on linux-mtd[1].
Hopping from one subsystem to another trying to sneak patches
in is not the best idea... :-)

[1]: http://lists.infradead.org/pipermail/linux-mtd/2016-March/066296.html
Yaowei Bai March 30, 2016, 1:23 a.m. UTC | #4
On Tue, Mar 29, 2016 at 11:43:21AM +0200, Richard Weinberger wrote:
> On Tue, Mar 29, 2016 at 8:35 AM, Yaowei Bai
> <baiyaowei@cmss.chinamobile.com> wrote:
> > On Sat, Mar 26, 2016 at 12:43:32AM +0000, Al Viro wrote:
> >> On Fri, Mar 25, 2016 at 10:01:26AM +0800, Yaowei Bai wrote:
> >> > 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.
> >>
> >> Improve in which way, if I may ask?
> >
> > A boolean return value can be more matchable with function's name and
> > more suitable as this function only returns 0/1.
> 
> Please also think of the arguments made on linux-mtd[1].
> Hopping from one subsystem to another trying to sneak patches
> in is not the best idea... :-)

Acturally, this patch was sent before the mtd ones and all of them were sent
in one shot. You're really thinking too much.:-)

> 
> [1]: http://lists.infradead.org/pipermail/linux-mtd/2016-March/066296.html
> 
> -- 
> Thanks,
> //richard


--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Richard Weinberger March 30, 2016, 7:30 a.m. UTC | #5
Am 30.03.2016 um 03:23 schrieb Yaowei Bai:
> On Tue, Mar 29, 2016 at 11:43:21AM +0200, Richard Weinberger wrote:
>> On Tue, Mar 29, 2016 at 8:35 AM, Yaowei Bai
>> <baiyaowei@cmss.chinamobile.com> wrote:
>>> On Sat, Mar 26, 2016 at 12:43:32AM +0000, Al Viro wrote:
>>>> On Fri, Mar 25, 2016 at 10:01:26AM +0800, Yaowei Bai wrote:
>>>>> 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.
>>>>
>>>> Improve in which way, if I may ask?
>>>
>>> A boolean return value can be more matchable with function's name and
>>> more suitable as this function only returns 0/1.
>>
>> Please also think of the arguments made on linux-mtd[1].
>> Hopping from one subsystem to another trying to sneak patches
>> in is not the best idea... :-)
> 
> Acturally, this patch was sent before the mtd ones and all of them were sent
> in one shot. You're really thinking too much.:-)

I was referring to your answer not to your patch.

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);