lkml.org 
[lkml]   [2000]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Kernel bugs found using inspect tool
Date
Followup to:  <Pine.LNX.4.04.10002231309270.12259-100000@beaker>
By author: Ricky Beam <jfbeam@bluetopia.net>
In newsgroup: linux.dev.kernel
> >
> > if (foo);
> > bar;
>
> Those are perfectly legal constructions. The compiler, while certainly
> magic, isn't a psychic.
>

Legal, yes. It's also useless (if you really meant it, you ought to
write "foo; bar;" which is equivalent.) Therefore, it should be fixed
one way or the other. Unlike a for or while statement with an empty
clause -- which sometimes have legitimate uses -- an if statement with
an empty clause is pretty much useless. The only case I've seen which
makes sense is if you have something like:

if (foo)
; /* Do nothing */
else
bar;

Note that I *highly* recommend having a comment for this case, to
indicate that there really is no mistake. Same with /* fallthrough */
in switch statements.

I actually would recommend using { } instead of ; as well.

-hpa


--
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.037 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site