A discussion of C’s goto describes routing multiple failure points through shared cleanup code instead of duplicating resource release. The cited original was unavailable because of a TLS error, so the public summary was checked against Linux’s coding-style guidance. That guidance recommends direct returns when no cleanup is needed and descriptive labels when it is. A single error label can incorrectly free an inner pointer that was never initialized; staged cleanup labels and exercising failure paths are therefore important.
Back to Tech
Using goto to centralize resource cleanup in C
Cleanup labels must match initialization stages to avoid introducing their own errors.