From 262981295f31caebf08b2bfc30bf40239e117d7d Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 24 Feb 2018 10:53:24 +0100 Subject: [PATCH] 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. --- ChangeLog | 7 +++++++ doc/glibc-functions/ptsname_r.texi | 4 ++++ tests/test-ptsname_r.c | 12 +++--------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c51a009ba..66996fa90a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2018-02-24 Bruno Haible + + 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. + 2018-02-23 Bruno Haible xmalloca: pacify gcc -Wbad-function-cast diff --git a/doc/glibc-functions/ptsname_r.texi b/doc/glibc-functions/ptsname_r.texi index 810908507a..979a0904bd 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 +@item +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 ca313d10b0..dcbecc4302 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); } { -- 2.39.5