]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Remove check for NULL buffer passed to `ptsname_r'
authorArjun Shankar <arjun.is@lostca.se>
Mon, 29 May 2017 14:12:31 +0000 (16:12 +0200)
committerArjun Shankar <arjun.is@lostca.se>
Wed, 7 Jun 2017 15:37:59 +0000 (17:37 +0200)
`ptsname_r' is declared in stdlib.h to only accept a `nonnull'
second argument and therefore GCC may choose to make optimizations
based on the assumption that this argument is NULL. This means
that potentially, GCC can optimize away the NULL check at some
point in the future. Since this is a programming interface, we
might as well remove the NULL check ourselves.

This also warrants a change to the `ptsname_r' manual page that
must be submitted to the corresponding mailing list.

In addition, remove the NULL buffer test in login/tst-ptsname.c.

ChangeLog
login/tst-ptsname.c
sysdeps/unix/sysv/linux/ptsname.c

index f74004b39a0b3b34ba47cdad3f48f4a7c23a6f86..4c06d7ef85084175686a85423393a445fdf77b6e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-06-07  Arjun Shankar  <arjun.is@lostca.se>
+
+       * sysdeps/unix/sysv/linux/ptsname.c (__ptsname_internal):
+       Remove check for NULL 'buf'.
+       * login/tst-ptsname.c (do_test): Remove test with NULL 'buf'.
+
 2017-06-07  Arjun Shankar  <arjun.is@lostca.se>
 
        * sysdeps/unix/sysv/linux/tst-clone2.c: Do not
index be8744dfd01e7f95eaaa5bf9b49338415b81c4e0..96f0449788c23c78fcd3249853c529d5ce086a8c 100644 (file)
@@ -70,7 +70,6 @@ do_test (void)
   if (fd != -1)
     {
       result |= do_single_test (fd, buf, sizeof (buf), 0);
-      result |= do_single_test (fd, NULL, sizeof (buf), EINVAL);
       result |= do_single_test (fd, buf, 1, ERANGE);
       close (fd);
     }
index e3f2ae8ff28b745187f396fd6c93b1f5643db25b..41bb0bbb0e3cb234d9e4b1b8ad3dc693d5218f07 100644 (file)
@@ -72,12 +72,6 @@ __ptsname_internal (int fd, char *buf, size_t buflen, struct stat64 *stp)
   int save_errno = errno;
   unsigned int ptyno;
 
-  if (buf == NULL)
-    {
-      __set_errno (EINVAL);
-      return EINVAL;
-    }
-
   if (!__isatty (fd))
     {
       __set_errno (ENOTTY);