all: cache errno in local variable before using it

This commit is contained in:
Thomas Haller
2019-01-31 13:29:21 +01:00
parent b7bb744973
commit 047998f80a
34 changed files with 217 additions and 147 deletions

View File

@@ -1769,10 +1769,12 @@ nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll)
k = read (fd, p, nbytes);
if (k < 0) {
if (errno == EINTR)
int errsv = errno;
if (errsv == EINTR)
continue;
if (errno == EAGAIN && do_poll) {
if (errsv == EAGAIN && do_poll) {
/* We knowingly ignore any return value here,
* and expect that any error/EOF is reported
@@ -1782,7 +1784,7 @@ nm_utils_fd_read_loop (int fd, void *buf, size_t nbytes, bool do_poll)
continue;
}
return n > 0 ? n : -errno;
return n > 0 ? n : -errsv;
}
if (k == 0)