linux-kernel.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

* Re: [PATCH] fs/vfs: improve __mnt_is_readonly
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Al Viro @ 2016-03-26  0:43 UTC (permalink / raw)
  To: Yaowei Bai; +Cc: linux-fsdevel, linux-kernel

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?

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

* Re: [PATCH] fs/vfs: improve __mnt_is_readonly
  2016-03-26  0:43 ` Al Viro
@ 2016-03-29  6:35   ` Yaowei Bai
  2016-03-29  9:43     ` Richard Weinberger
  0 siblings, 1 reply; 6+ messages in thread
From: Yaowei Bai @ 2016-03-29  6:35 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-fsdevel, linux-kernel

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.

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

* Re: [PATCH] fs/vfs: improve __mnt_is_readonly
  2016-03-29  6:35   ` Yaowei Bai
@ 2016-03-29  9:43     ` Richard Weinberger
  2016-03-30  1:23       ` Yaowei Bai
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Weinberger @ 2016-03-29  9:43 UTC (permalink / raw)
  To: Yaowei Bai; +Cc: Al Viro, linux-fsdevel, LKML

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

-- 
Thanks,
//richard

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

* Re: [PATCH] fs/vfs: improve __mnt_is_readonly
  2016-03-29  9:43     ` Richard Weinberger
@ 2016-03-30  1:23       ` Yaowei Bai
  2016-03-30  7:30         ` Richard Weinberger
  0 siblings, 1 reply; 6+ messages in thread
From: Yaowei Bai @ 2016-03-30  1:23 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: Al Viro, linux-fsdevel, LKML

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

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

* Re: [PATCH] fs/vfs: improve __mnt_is_readonly
  2016-03-30  1:23       ` Yaowei Bai
@ 2016-03-30  7:30         ` Richard Weinberger
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Weinberger @ 2016-03-30  7:30 UTC (permalink / raw)
  To: Yaowei Bai; +Cc: Al Viro, linux-fsdevel, LKML

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

^ permalink raw reply	[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).