Funny code snippet of the month
parawaiter
parawaiter at gmail.com
Tue Nov 3 23:07:32 UTC 2009
On Nov 3, 2009, at 11:44 PM, David N. Lombard wrote:
> On Tue, Nov 03, 2009 at 01:42:48PM -0800, Alexander Shishkin wrote:
>> On Втр, Ноя 03, 2009 at 04:28:09 +0100, Denys Vlasenko wrote:
>>> assert (*buffer == info->buffer);
>>> *buffer = info->buffer;
>> "Never say never".
>
> Ummm, if the order was reversed, one could argue this was an attempt
> to catch a
> silent data corruption (SDC).
I'd say the order was correct, but you had a freak bug; *buffer should
be info->buffer, but once in a blue moon it isn't. You are trying to
catch it, but haven't been able to figure it out yet. For release
builds you can make sure whatever follows works by ensuring the value
is correct. For debug builds, you are trying to catch it with an
assert. Yeah, it's a crappy workaround that doesn't ensure
correctness, but it could improve release-build robustness an order of
magnitude until you are able to fix the bug. The resulting code looks
ridiculous.
But the more likely explanation for code like this is that the code
transformed from something very different, and it's more or less in
the category of a copy-bug now.
Regards,
Lars J
More information about the busybox
mailing list