From: Valerie Aurora <vaurora@redhat.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Karel Zak <kzak@redhat.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] VFS: Sanity check mount flags passed to change_mnt_propagation()
Date: Fri, 27 Aug 2010 13:43:13 -0400 [thread overview]
Message-ID: <20100827174313.GA26872@shell> (raw)
In-Reply-To: <20100827011436.GB3521@parisc-linux.org>
On Thu, Aug 26, 2010 at 07:14:36PM -0600, Matthew Wilcox wrote:
> On Thu, Aug 26, 2010 at 04:03:18PM -0400, Valerie Aurora wrote:
> > + /* Fail if any non-propagation flags are set */
> > + if (type & ~(MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
> > + return 0;
> > + /* Only one propagation flag should be set */
> > + if (((type & (MS_SHARED)) && (type & ~MS_SHARED)) ||
> > + ((type & (MS_PRIVATE)) && (type & ~MS_PRIVATE)) ||
> > + ((type & (MS_SLAVE)) && (type & ~MS_SLAVE)) ||
> > + ((type & (MS_UNBINDABLE)) && (type & ~MS_UNBINDABLE)))
> > + return 0;
>
> Hrm. I think we can do this a bit more pithily.
>
> /* Only one propagation flag should be set, and no others */
> if (hweight32(type) != 1 &&
> (type & ~(MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
> return 0;
>
> Too clever?
I was hoping someone would go find the best bitop for me, thanks. :)
hweight32() is an awkward name but the comment makes it clear. I'm
happy with either.
Thanks for the help,
-VAL
next prev parent reply other threads:[~2010-08-27 17:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-26 20:03 [PATCH] VFS: Sanity check mount flags passed to change_mnt_propagation() Valerie Aurora
2010-08-27 1:14 ` Matthew Wilcox
2010-08-27 17:43 ` Valerie Aurora [this message]
2010-08-27 17:51 ` Bob Copeland
2010-08-27 18:12 ` Valerie Aurora
2010-08-28 10:57 ` Matthew Wilcox
2010-08-28 13:15 ` Bob Copeland
2010-08-28 21:23 ` Linus Torvalds
2010-08-30 18:26 ` Valerie Aurora
2010-08-27 10:36 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100827174313.GA26872@shell \
--to=vaurora@redhat.com \
--cc=kzak@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).