Re: [PATCH] gcc-3.0 warnings

Tim Wright (timw@splhi.com)
Mon, 26 Mar 2001 06:25:57 -0800


On Fri, Mar 23, 2001 at 05:16:26PM -0800, Stephen Satchell wrote:
[...]
> Really? I have a "cleanup" function that can be called during failure
> cases (and success cases -- but you didn't mention that) so that the cost
> is very low and I don't have to code ANY labels.
>
> But then again, I'm a double-pipe abuser, in that I tend to code "atomic"
> sequences as
>
> if ((a) || (b) || (c) || (d) || (e) || (f) || (g) || ... ) { something
> failed} else {it all worked!}
>
> and make sure that the failure value is non-zero for each a, b, c, d, and
> so forth.
>

Sorry, my example was too simplistic. Replace simple allocations with e.g.
allocate();
grab lock;
set flag;
allocate();

or something similar. Yes it's possible to code a state variable to remember
where you got to, or to e.g. add an extra boolean variable to indicate that
you grabbed the lock, but I'd argue that this obfuscates the code as well as
making it less efficient. It's no good looking to see if the lock has been
grabbed - if you failed at the first stage, it may still be locked by a
different CPU.

Tim

-- 
Tim Wright - timw@splhi.com or timw@aracnet.com or twright@us.ibm.com
IBM Linux Technology Center, Beaverton, Oregon
Interested in Linux scalability ? Look at http://lse.sourceforge.net/
"Nobody ever said I was charming, they said "Rimmer, you're a git!"" RD VI
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/