2 ms·
GOTO is still perfectly acceptable and common practice in the Linux kernel and other widely used codebases. https://www.kernel.org/doc/html/v5.0/process/coding
by SonOfKyuss 4y ago
GOTO is still perfectly acceptable and common practice in the Linux kernel and other widely used codebases.
https://www.kernel.org/doc/html/v5.0/process/coding-style.html#centralized-exiting-of-functions https://www.kernel.org/doc/html/v5.0/process/coding-style.ht...
- ghostpepper 4y agoIf anyone is curious, it's not just used to make unreadable spaghetti code. There are certain common paradigms, eg. int do_stuff_in_order(void) { int ret = init_a(); if (ret != success) goto out; ret = init_b(); if (ret != success) goto error1; ret = init_c(); if (ret != success) goto error2; return 0; error2: teardown_b(); error1: teardown_a(); out: return ret; }