From: Andy Whitcroft <apw@canonical.com>
To: Adrian Bunk <bunk@kernel.org>
Cc: Jan Kara <jack@suse.cz>, linux-kernel@vger.kernel.org
Subject: Re: Checkpatch false positive?
Date: Wed, 28 Jan 2009 09:35:25 +0000 [thread overview]
Message-ID: <20090128093525.GB10291@shadowen.org> (raw)
In-Reply-To: <20090127160601.GA20342@localhost.pp.htv.fi>
On Tue, Jan 27, 2009 at 06:06:01PM +0200, Adrian Bunk wrote:
> On Tue, Jan 27, 2009 at 04:49:05PM +0100, Jan Kara wrote:
> > Hi,
> >
> > I've used checkpatch.pl to verify one of my patches. It complains:
> >
> > ERROR: trailing statements should be on next line
> > #167: FILE: fs/quota/quota_tree.c:249:
> > + for (i = 0, ddquot = buf + sizeof(struct qt_disk_dqdbheader);
> > [...]
> > i++, ddquot += info->dqi_entry_size);
> >
> > But the code looks like:
> > for (i = 0, ddquot = buf + sizeof(struct qt_disk_dqdbheader);
> > i < qtree_dqstr_in_blk(info) && !qtree_entry_unused(info, ddquot);
> > i++, ddquot += info->dqi_entry_size);
> >
> > Which is IMHO correct. Maybe it's because the for has actually empty body
> > and the ; is at the end of the line with for. But I didn't find anything in
> > CodingStyle that would forbid
> > for (...);
> > and
> > for (...)
> > ;
> > Looks a bit strange.
>
> for (...); is a common C programming error, usually it's some kind of:
>
> for(........);
> do_something();
>
> This code does something different than intended.
> And yes, we had such bugs in the kernel.
>
>
> for(........)
> ;
>
> is correct. The "looks a bit strange" is what actually tells readers
> what the code is doing (and that the author did it intentionally).
Yeah its about being explicit that you intended there to be an empty
statement in this construct. We tend to get bitten even more by if form
of this:
if (foo);
something();
But we catch them all. And always remember if you really think it looks
better or makes more sense one way and checkpatch is upset you can
ignore checkpatch. It is advice on what will be accepted not
necessarily the final arbiter. That is the maintainers role, checkpatch
is a tool to help you.
-apw
next prev parent reply other threads:[~2009-01-28 9:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-27 15:49 Jan Kara
2009-01-27 16:06 ` Adrian Bunk
2009-01-27 16:34 ` Jan Kara
2009-01-28 9:35 ` Andy Whitcroft [this message]
2009-01-27 16:19 ` Arjan van de Ven
2009-01-27 16:33 ` Jan Kara
-- strict thread matches above, loose matches on Subject: below --
2008-08-01 4:51 Matthew Helsley
2008-08-03 22:18 ` Andy Whitcroft
2008-08-04 22:10 ` Matt Helsley
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=20090128093525.GB10291@shadowen.org \
--to=apw@canonical.com \
--cc=bunk@kernel.org \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome