summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-05-26 21:45:41 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-05-26 21:45:41 -0700
commit4388a06cb509ff98eaf0be822e3fb41a49534dca (patch)
treed0ce445422ce87c321a68dfbae761f637128af6a
parentbe39cb48cc908e1f07d9aa06968012c542031cf6 (diff)
downloadtxr-4388a06cb509ff98eaf0be822e3fb41a49534dca.tar.gz
txr-4388a06cb509ff98eaf0be822e3fb41a49534dca.tar.bz2
txr-4388a06cb509ff98eaf0be822e3fb41a49534dca.zip
streams: avoid double access to errno.
* stream.c (stdio_maybe_read_error): Access errno once, and refer to the value.
-rw-r--r--stream.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/stream.c b/stream.c
index fb0dae68..6fcf73c5 100644
--- a/stream.c
+++ b/stream.c
@@ -593,10 +593,11 @@ static val stdio_maybe_read_error(val stream)
if (h->f == 0)
uw_throwf(file_error_s, lit("error reading ~s: file closed"), stream, nao);
if (ferror(h->f)) {
- val err = num(errno);
+ int eno = errno;
+ val err = num(eno);
h->err = err;
#ifdef EAGAIN
- if (errno == EAGAIN)
+ if (eno == EAGAIN)
uw_ethrowf(timeout_error_s, lit("timed out reading ~s"), stream, nao);
#endif
uw_ethrowf(file_error_s, lit("error reading ~s: ~d/~s"),