if (ret < 0)
return ret;
- /* DLog is often used to log errors, but people usually fail to
- * handle errno correctly, forgetting that logging can also
- * modify it, like this:
- *
- * if (foo() == -1) {
- * dlog_print(...);
- * if (errno == ...) // potentially uses DLog's errno
- *
- * Therefore we take an extra step to remedy this. It is fairly
- * unfortunate to have to do this because it might encourage lazy
- * coding, but it's probably more important that the system works. */
- const int initial_errno = errno;
-
/* Threads can be cancelled before they give up a lock.
* Therefore cancellation is temporarily disabled.
* This solution is comparatively simple and cheap.
pthread_setcancelstate(old_cancel_state, NULL);
- errno = initial_errno;
return ret;
}