lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 27 Jan 2009 18:06:01 +0200
From:	Adrian Bunk <bunk@...nel.org>
To:	Jan Kara <jack@...e.cz>
Cc:	apw@...onical.com, linux-kernel@...r.kernel.org
Subject: Re: Checkpatch false positive?

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).


> 									Honza

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ