From: "Ian! D. Allen" <idallen@idallen.ca>
To: linux-btrfs@vger.kernel.org
Cc: Li Zefan <lizf@cn.fujitsu.com>
Subject: Re: [PATCH v2 5/5] Btrfs: Add BTRFS_IOC_SUBVOL_GETFLAGS/SETFLAGS ioctl
Date: Fri, 10 Dec 2010 02:49:34 -0500 [thread overview]
Message-ID: <20101210074934.GE9893@idallen.ca> (raw)
In-Reply-To: <4D01D2E9.9000007@cn.fujitsu.com>
On Fri, Dec 10, 2010 at 03:12:41PM +0800, Li Zefan wrote:
> >> + /* nothing to do */
> >> + if (!!(flags & BTRFS_SUBVOL_RDONLY) == root->readonly)
> >> + goto out_unlock;
> >
> > This is only an aesthetic comment: I prefer a simpler style like
> >
> > if ((flags & BTRFS_SUBVOL_RDONLY) && root->readonly)
> > goto out_unlock;
>
> They are not equivalent. The former checks if the flags and the
> root both have readonly bit set or cleared.
This is an excellent reason to add what you just replied (above) as a
comment into the code ahead of that line, so others don't make the same
mistake in interpreting what it does:
/* nothing to do */
/* check if flags and root both have readonly bit set or cleared */
if (!!(flags & BTRFS_SUBVOL_RDONLY) == root->readonly)
goto out_unlock;
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan
--
| Ian! D. Allen - idallen@idallen.ca - Ottawa, Ontario, Canada
| Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/
| College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/
| Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/
prev parent reply other threads:[~2010-12-10 7:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-09 9:09 [PATCH v2 0/5] Btrfs: Readonly snapshots Li Zefan
2010-12-09 9:10 ` [PATCH v2 1/5] Btrfs: Make async snapshot ioctl more generic Li Zefan
2010-12-09 9:10 ` [PATCH v2 2/5] Btrfs: Refactor btrfs_ioctl_snap_create() Li Zefan
2010-12-09 9:10 ` [PATCH v2 3/5] Btrfs: Add helper __setup_root_post() Li Zefan
2010-12-09 9:11 ` [PATCH v2 4/5] Btrfs: Add readonly snapshots support Li Zefan
2010-12-09 19:34 ` Goffredo Baroncelli
2010-12-10 6:43 ` Li Zefan
2010-12-09 9:11 ` [PATCH v2 5/5] Btrfs: Add BTRFS_IOC_SUBVOL_GETFLAGS/SETFLAGS ioctl Li Zefan
2010-12-09 20:09 ` Goffredo Baroncelli
2010-12-10 7:12 ` Li Zefan
2010-12-10 7:49 ` Ian! D. Allen [this message]
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=20101210074934.GE9893@idallen.ca \
--to=idallen@idallen.ca \
--cc=linux-btrfs@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
/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).