3 ms·
goto is the best way to do early exit and cleanup from a C function. The alternatives are 1) deeply nested if's, one level for each function call that can retur
by marcoperaza 9y ago
goto is the best way to do early exit and cleanup from a C function. The alternatives are 1) deeply nested if's, one level for each function call that can return an error code, or 2) repeat the same cleanup code over and over again at every exit point.
- anonfunction 9y agohttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/kernel/exit.c?id=1c9fec470b81ca5e89391c20a11ead31a1e9314b https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...