Re:GnuTLS certificate verification vulnerability announced (...
by mpyne on Tuesday March 04, 2014 @03:28PM
(#7342887)
It's actually not horrific IMHO in the context of C when you use it explicitly in this fashion, as a "poor man's exceptions with resource cleanup". And it's not simply a method to avoid typing, it helps with the very common design pattern of:
acquire A
acquire B
acquire C
do_work
release C
release B
release A
It has all the benefit of "common return path" (since it is a common return path) without the 8 levels of indentation and random subsidiary conditional checks that obscure the code logic and add their own confusion. Instead you fail as fast as possible.Like any other design pattern (C or otherwise) it's easy to misuse or abuse and it's not suited to every combination of library usage.
The "goto fail" pattern seems pretty common though - I was wondering what it had in its favour apart from being a easier to type (which would also be true of "not checking for errors" for example).