Comments for empty for-loop parts (was Re: xserver: Branch 'master' - 6 commits)
Ian Romanick
idr at us.ibm.com
Mon Jun 4 13:10:40 PDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Eric Anholt wrote:
> New commits:
> diff-tree 3c982bc1a49509dda7bc469b0eced44df02755b3 (from 4d7469f75fadfc4a59664e88e18eb304203670f4)
> Author: Luo Jie <luojie at nlsde.buaa.edu.cn>
> Date: Thu May 24 11:13:03 2007 -0700
>
> Reinstate an apparently mis-deleted ';' from a for loop with no body.
>
> Fixes an error returning "No core keyboard" with multiple keyboards.
>
> diff --git a/dix/devices.c b/dix/devices.c
> index e227617..da6e590 100644
> --- a/dix/devices.c
> +++ b/dix/devices.c
> @@ -425,6 +425,7 @@ InitAndStartDevices(void)
> for (dev = inputInfo.devices;
> dev && (dev != inputInfo.keyboard);
> dev = dev->next)
> + ;
> if (!dev || (dev != inputInfo.keyboard)) {
> ErrorF("No core keyboard\n");
> return BadImplementation;
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.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQFGZHG/X1gOwKyEAw8RAi8NAJ4oa8kCCaHaR2z5Q/rp7hfWDfJ7ywCeP2Z7
EIFQQnCGokoCd06y/gyApmI=
=sG/3
-----END PGP SIGNATURE-----
More information about the xorg
mailing list