Comments for empty for-loop parts (was Re: xserver: Branch 'master' - 6 commits)

Bernardo Innocenti bernie at codewiz.org
Mon Jun 4 20:57:38 PDT 2007


Ian Romanick wrote:

> Over the years, I have encountered *may* bugs like this.  One way to
> help combat them is to have a policy that empty loop parts are
> documented with a comment of /* empty */.  It makes it explicit to
> people reading the code that the missing parts are intentionally
> missing.  It also helps prevent deletion of the "stray" semicolon of an
> empty loop body.

Some compilers have an option to warn on empty loop
and "if" bodies.  To shut it up, you can replace the
";" with an empty block instead: "{ }", which also
shows the intention more clearly to humans.

Surprisingly, gcc does not seem to support this
warning as of 4.1.

-- 
   // Bernardo Innocenti
 \X/  http://www.codewiz.org/



More information about the xorg mailing list