3 ms·
The code is indeed terrible. This for(p=allocp; ; ) { for(temp=0; ; ) { if(!testbusy(p->ptr)) { while(!testbusy((q=p->ptr)->ptr)) { ASSERT(q
by bjourne 9y ago
The code is indeed terrible. This
for(p=allocp; ; ) {
for(temp=0; ; ) {
if(!testbusy(p->ptr)) {
while(!testbusy((q=p->ptr)->ptr)) {
ASSERT(q>p&&q<alloct);
would not pass anyone's code review today. Presumably they had to write it that way to ensure that the compiler emitted adequate code.
- throwaway613834 9y agoWhat exactly do you find the most problematic with this code?
- bjourne 9y agoIsn't it self-evident? Blocks nested five levels, abused for-loop syntax, assignment in testing expressions...
- throwaway613834 9y agoIt's not evident, sorry. Despite what you might hear about having over three levels deep being a sin, five levels of nesting is perfectly fine. And that's not an abuse of for-loop syntax -- that's exactly how you're supposed to do an infinite loop. In fact, `while(1)` is the syntax that abuses loop notation, and consequently raises "conditional expression is constant" warnings. Assignment in conditional, though, I guess I can agree with you on...