2 ms·
The approach I use, and that used many places in the Linux kernel, is to use goto for error handling: if(failure_1) { goto error; } if(failure_2) {
by nitrogen 13y ago
The approach I use, and that used many places in the Linux kernel, is to use goto for error handling:
if(failure_1) {
goto error;
}
if(failure_2) {
goto error;
}
// Do stuff
return 0;
error:
if(f != NULL) {
fclose(f);
}
if(s != NULL) {
free(s);
}
return -1;