summaryrefslogtreecommitdiffstats
path: root/regress/lib/libc/stdio_threading
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2014-07-20 01:38:40 +0000
committerguenther <guenther@openbsd.org>2014-07-20 01:38:40 +0000
commitffb4dd050d1e35f39b1d6c1c600db7c6443475c2 (patch)
tree0e41db8f3c733eb324a6a362a29149f077ad4c74 /regress/lib/libc/stdio_threading
parentDelete unused variables found by -Wall (diff)
downloadwireguard-openbsd-ffb4dd050d1e35f39b1d6c1c600db7c6443475c2.tar.xz
wireguard-openbsd-ffb4dd050d1e35f39b1d6c1c600db7c6443475c2.zip
Make sure the correct errno is reported by warn* or err* and not
the errno of an intervening cleanup operation like close/unlink/etc. Diff from Doug Hogan (doug (at) acyclic.org)
Diffstat (limited to 'regress/lib/libc/stdio_threading')
-rwxr-xr-xregress/lib/libc/stdio_threading/fgetln/fgetln_test.c3
-rwxr-xr-xregress/lib/libc/stdio_threading/fgets/fgets_test.c3
-rwxr-xr-xregress/lib/libc/stdio_threading/fputs/fputs_test.c3
-rwxr-xr-xregress/lib/libc/stdio_threading/fread/fread_test.c3
-rwxr-xr-xregress/lib/libc/stdio_threading/fwrite/fwrite_test.c3
-rw-r--r--regress/lib/libc/stdio_threading/include/local.h1
6 files changed, 11 insertions, 5 deletions
diff --git a/regress/lib/libc/stdio_threading/fgetln/fgetln_test.c b/regress/lib/libc/stdio_threading/fgetln/fgetln_test.c
index 0c815838d0b..76d154bb2a3 100755
--- a/regress/lib/libc/stdio_threading/fgetln/fgetln_test.c
+++ b/regress/lib/libc/stdio_threading/fgetln/fgetln_test.c
@@ -49,11 +49,12 @@ main(void)
strlcpy(sfn, "/tmp/barnacles.XXXXXXXX", sizeof(sfn));
if ((fd = mkstemp(sfn)) == -1 ||
(sfp = fdopen(fd, "w+")) == NULL) {
+ int saved_errno = errno;
if (fd != -1) {
unlink(sfn);
close(fd);
}
- err(1, "could not open temporary file");
+ errc(1, saved_errno, "could not open temporary file");
}
for (i = 0; i < 4096 * THREAD_COUNT; i++)
diff --git a/regress/lib/libc/stdio_threading/fgets/fgets_test.c b/regress/lib/libc/stdio_threading/fgets/fgets_test.c
index c53abbc06bc..7c5008e2adf 100755
--- a/regress/lib/libc/stdio_threading/fgets/fgets_test.c
+++ b/regress/lib/libc/stdio_threading/fgets/fgets_test.c
@@ -48,11 +48,12 @@ main(void)
strlcpy(sfn, "/tmp/barnacles.XXXXXXXX", sizeof(sfn));
if ((fd = mkstemp(sfn)) == -1 ||
(sfp = fdopen(fd, "w+")) == NULL) {
+ int saved_errno = errno;
if (fd != -1) {
unlink(sfn);
close(fd);
}
- err(1, "could not open temporary file");
+ errc(1, saved_errno, "could not open temporary file");
}
for (i = 0; i < 4096 * THREAD_COUNT; i++)
diff --git a/regress/lib/libc/stdio_threading/fputs/fputs_test.c b/regress/lib/libc/stdio_threading/fputs/fputs_test.c
index 90b6179fd5e..93d0f0b6c76 100755
--- a/regress/lib/libc/stdio_threading/fputs/fputs_test.c
+++ b/regress/lib/libc/stdio_threading/fputs/fputs_test.c
@@ -46,11 +46,12 @@ main(void)
strlcpy(sfn, "/tmp/barnacles.XXXXXXXX", sizeof(sfn));
if ((fd = mkstemp(sfn)) == -1 ||
(sfp = fdopen(fd, "w+")) == NULL) {
+ int saved_errno = errno;
if (fd != -1) {
unlink(sfn);
close(fd);
}
- err(1, "could not open temporary file");
+ errc(1, saved_errno, "could not open temporary file");
}
run_threads(fputs_thread, sfp);
diff --git a/regress/lib/libc/stdio_threading/fread/fread_test.c b/regress/lib/libc/stdio_threading/fread/fread_test.c
index c45a64d14e4..6bd734b4705 100755
--- a/regress/lib/libc/stdio_threading/fread/fread_test.c
+++ b/regress/lib/libc/stdio_threading/fread/fread_test.c
@@ -50,11 +50,12 @@ main(void)
strlcpy(sfn, "/tmp/barnacles.XXXXXXXX", sizeof(sfn));
if ((fd = mkstemp(sfn)) == -1 ||
(sfp = fdopen(fd, "w+")) == NULL) {
+ int saved_errno = errno;
if (fd != -1) {
unlink(sfn);
close(fd);
}
- err(1, "could not open temporary file");
+ errc(1, saved_errno, "could not open temporary file");
}
for (i = 0; i < 4096 * THREAD_COUNT; i++)
diff --git a/regress/lib/libc/stdio_threading/fwrite/fwrite_test.c b/regress/lib/libc/stdio_threading/fwrite/fwrite_test.c
index 621c5cb6e8e..86c450cbc9b 100755
--- a/regress/lib/libc/stdio_threading/fwrite/fwrite_test.c
+++ b/regress/lib/libc/stdio_threading/fwrite/fwrite_test.c
@@ -46,11 +46,12 @@ main(void)
strlcpy(sfn, "/tmp/barnacles.XXXXXXXX", sizeof(sfn));
if ((fd = mkstemp(sfn)) == -1 ||
(sfp = fdopen(fd, "w+")) == NULL) {
+ int saved_errno = errno;
if (fd != -1) {
unlink(sfn);
close(fd);
}
- err(1, "could not open temporary file");
+ errc(1, saved_errno, "could not open temporary file");
}
run_threads(fwrite_thread, sfp);
diff --git a/regress/lib/libc/stdio_threading/include/local.h b/regress/lib/libc/stdio_threading/include/local.h
index 8d0e628cf6c..7a7822a452e 100644
--- a/regress/lib/libc/stdio_threading/include/local.h
+++ b/regress/lib/libc/stdio_threading/include/local.h
@@ -15,6 +15,7 @@
*/
#include <err.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>