[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ptsname_r: don't expect that this function sets errno
From: |
Bruno Haible |
Subject: |
ptsname_r: don't expect that this function sets errno |
Date: |
Sat, 24 Feb 2018 11:00:01 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-112-generic; KDE/5.18.0; x86_64; ; ) |
glibc ptsname_r sets errno when it fails, but this is not specified in
https://www.gnu.org/software/libc/manual/html_node/Allocation.html
and musl libc does not do the same thing. This leads to a test failure
of 'test-ptsname_r' on Alpine Linux 3.7.0.
This patch fixes it.
2018-02-24 Bruno Haible <address@hidden>
ptsname_r: Don't expect that this function sets errno.
* tests/test-ptsname_r.c (test_errors): Don't test errno after return
from ptsname_r().
* doc/glibc-functions/ptsname_r.texi: Mention the issue.
diff --git a/doc/glibc-functions/ptsname_r.texi
b/doc/glibc-functions/ptsname_r.texi
index 8109085..979a090 100644
--- a/doc/glibc-functions/ptsname_r.texi
+++ b/doc/glibc-functions/ptsname_r.texi
@@ -22,4 +22,8 @@ OSF/1 5.1.
Portability problems not fixed by Gnulib:
@itemize
address@hidden
+When this functions fails, it provides the error code only as the
+return value, without setting @code{errno}, on some platforms:
+musl libc.
@end itemize
diff --git a/tests/test-ptsname_r.c b/tests/test-ptsname_r.c
index ca313d1..dcbecc4 100644
--- a/tests/test-ptsname_r.c
+++ b/tests/test-ptsname_r.c
@@ -70,7 +70,6 @@ test_errors (int fd, const char *slave)
for (buflen = 0; buflen <= buflen_max; buflen++)
{
memset (buffer, 'X', sizeof buffer);
- errno = 0;
result = ptsname_r (fd, buffer, buflen);
if (buflen > len)
{
@@ -80,17 +79,14 @@ test_errors (int fd, const char *slave)
else
{
ASSERT (result != 0);
- ASSERT (result == errno);
- ASSERT (errno == ERANGE);
+ ASSERT (result == ERANGE);
ASSERT (buffer[0] == 'X');
}
}
- errno = 0;
result = ptsname_r (fd, null_ptr (), 0);
ASSERT (result != 0);
- ASSERT (result == errno);
- ASSERT (errno == EINVAL);
+ ASSERT (result == EINVAL);
}
int
@@ -108,11 +104,9 @@ main (void)
char buffer[256];
int result;
- errno = 0;
result = ptsname_r (-1, buffer, sizeof buffer);
ASSERT (result != 0);
- ASSERT (result == errno);
- ASSERT (errno == EBADF || errno == ENOTTY);
+ ASSERT (result == EBADF || result == ENOTTY);
}
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- ptsname_r: don't expect that this function sets errno,
Bruno Haible <=