|
|
|
|
|
by acuozzo
842 days ago
|
|
> I’m sure the errno state is not checked at every line, as it is a trivial human error to leave that out While writing code it's trivial to ask yourself if the next statement will include a call to a function which is not defined within a compilation unit under your control. If it will, then you lookup documentation for that function to determine what it expects and how it can fail. Most of my functions which interact with such functions look like long sequences of this: /* close the file */
ret = -1;
do {
errno = 0;
ret = close(fildes);
} while (0 != ret && EINTR == errno);
if (0 != ret) {
perror("Error");
goto off_ramp;
}
I've caused plenty of bugs in my career, but I can say with confidence that 0 of them had to do with ignoring/skipping proper error handling. You have to do so intentionally. |
|