> if(status) goto done;
> Which of them do you think is easier to read and maintain???
I have seen code like this before. I personally prefer nested if's to facilitate
cleanup lining up clearly through horizontal indentation. Both approaches I
think are ugly. It's a developer decision.
Like so many things in my engineering life, my opinion on these topics has changed over the years.
For many years, I favored the "early out" pattern of multiple return points from a function... because this was the most common pattern seen in Windows kernel mode "back in the day".
I *really* don't like if NT_SUCCESS() ... if NT_SUCCESS() ... if NT_SUCCESS()... indent. I find this to be both ugly and confusing. To ME, the logic gets lost in the error handling. Then again, I still insist on code being no wider than 80 columns.
A few years back, just about everyone here at OSR has uniformly switched to the "goto done" model, and this has proved *very* satisfactory. I find the code easy to follow, and indents from the left follow the code *logic* not the success path for function invocation.
But, as Mr. Kreamer said, "it's a developer decision"... every man should be able to select his own tools.