Re: [RFC patch 0/4] TSC calibration improvements

From: Willy Tarreau
Date: Sun Sep 07 2008 - 02:02:24 EST


On Sat, Sep 06, 2008 at 02:10:32PM -0700, Linus Torvalds wrote:

> The fact is, the code that Ingo added was totally bogus. The real bug was
> that he did a totally bogus "--expect" in the argument to that last call.

BTW, I hate to see state-changing instructions inside an if condition.
I've been bitten several times while debugging. You try to temporarily
comment out the if statement for a test and you end up with different
code. Same for printf. Examples of dangerous usages :

i = 0;
for (x = 0; x < 100; x++) {
update_var(&i);
if (debug && i--)
printf("Hey I'm here\n");
}
return i;

You can bet that the if will go away before production. Variant with
similar effects :

i = 0;
for (x = 0; x < 100; x++) {
update_var(&i);
printf("Hey I'm here : %d\n", --i);
}
return i;

Since it costs nothing (except one tab and one LF) to put the instruction
out of the condition, I prefer to see them extracted :

i = 0;
for (x = 0; x < 100; x++) {
update_var(&i);
i--;
if (debug)
printf("Hey I'm here\n");
}
return i;
>

Willy

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