Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


What exactly do you find the most problematic with this code?


Isn't it self-evident? Blocks nested five levels, abused for-loop syntax, assignment in testing expressions...


It'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...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: