Various macro tricks have existed for a long time but nobody has been able to wrap the return statement yet. The lack of RAII-style automatic cleanups was one of the root causes for the legendary goto fail;[1] bug.
[1] https://gotofail.com/
I do not see how defer would have helped in this case.
I do not see how defer would have helped in this case.