From: Bruno Haible Date: Sat, 24 Feb 2018 09:53:24 +0000 (+0100) Subject: ptsname_r: Don't expect that this function sets errno. X-Git-Tag: v1.0~5725 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=262981295f31caebf08b2bfc30bf40239e117d7d;p=gnulib.git 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/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); } {