2016-03-25 02:01:54

by baiyaowei

[permalink] [raw]
Subject: [PATCH] fs/vfs: improve __mnt_is_readonly

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 <[email protected]>
---
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




2016-03-26 00:43:36

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH] fs/vfs: improve __mnt_is_readonly

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?

2016-03-29 06:36:14

by baiyaowei

[permalink] [raw]
Subject: Re: [PATCH] fs/vfs: improve __mnt_is_readonly

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.


2016-03-29 09:43:26

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH] fs/vfs: improve __mnt_is_readonly

On Tue, Mar 29, 2016 at 8:35 AM, Yaowei Bai
<[email protected]> 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

--
Thanks,
//richard

2016-03-30 01:23:42

by baiyaowei

[permalink] [raw]
Subject: Re: [PATCH] fs/vfs: improve __mnt_is_readonly

On Tue, Mar 29, 2016 at 11:43:21AM +0200, Richard Weinberger wrote:
> On Tue, Mar 29, 2016 at 8:35 AM, Yaowei Bai
> <[email protected]> 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


2016-03-30 07:30:16

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH] fs/vfs: improve __mnt_is_readonly

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
>> <[email protected]> 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