News for hackers. Stuff that matters.
Re:Ask HN: Why does Linux Kernel use goto statements? by dusted on Wednesday December 08, 2021 @02:02AM (#29481982)
That's a fine use of goto and not in any way bad design in my opinion.

It makes it very clear that it's _REQUIRED_ to run the cleanup stuff regardless of the skipped block.

It does so without wrapping the entire skipped block in an IF (which also has two side effects: of causing more indentation and making the cleanup stuf look less required, or incidental).

It does so without adding another tiny silly, only-_REALLY_-used-on-place function for cleaning up, which decreases readability and causes more code duplication since there is then a need for not one, but two function calls and/or multiple return paths where not needed.

There are no comments on this comment yet.