Making EPERM friendlier
Posted Jan 21, 2013 18:47 UTC (Mon) by
dtlin (
✭ supporter ✭, #36537)
In reply to:
Making EPERM friendlier by johill
Parent article:
Making EPERM friendlier
I'm pretty sure etienne was not suggesting that, because if you had been reading the article, this breaks existing programs.
do_something_that_might_fail();
{ /* maybe inside an interrupt, logging routine,
* or anything else that happens between where
* the error occurs and its consumer */
errno_t saved_errno = errno;
do_something_else(); /* might change errno */
errno = saved_errno; /* so put errno back */
}
Now you've just clobbered a single field in
errno_storage, which might have been saving information from a different call.
If you make the variable
errno encompass the entire extended storage space, then that code is fine, but then you can't treat it as an int, which is certainly used in many places too.
(
Log in to post comments)