checked sources of xorg-server 1.7.0 with static code analysis tool cppcheck

Adam Jackson ajax at nwnk.net
Mon Oct 5 12:19:51 PDT 2009


On Sat, 2009-10-03 at 01:17 +0200, Michel Dänzer wrote:

> Mixing code and declarations is a C99 feature, and I'm not sure we
> require a C99 compiler yet. I'm not sure that that these tests serve any
> real purpose, they can probably just be removed.

We don't require a C99 compiler - which is good, because there aren't
any - but we do require some C99 features.  In particular, named
initializers, variadic macros, and mixed code and decls are all
explicitly called out as required by xserver/doc/c-extensions.
(Obviously that list isn't final, but it's served well so far.)

This particular feature is sort of a taste thing.  Personally I think:

    for (int i = 0; i < 17; i++)

is prettier than the alternative, but that many other instances of
relaxed decl placement hurt readability by making it harder to find the
type of whatever it is you're looking at.

In this particular case, I don't have a problem with the code with the
if() either above or below the decls.  But I suspect it's hiding some
other issue.

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
Url : http://lists.x.org/archives/xorg-devel/attachments/20091005/22f0b6c7/attachment.pgp 


More information about the xorg-devel mailing list