about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/ptsname.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-12-11 22:08:19 +0000
committerUlrich Drepper <drepper@redhat.com>2001-12-11 22:08:19 +0000
commit814fc245e5c795e2964ee256e8ceb47c67429e66 (patch)
tree2346dd996076f9914cf8f3442e2c1ed62d13863c /sysdeps/unix/sysv/linux/ptsname.c
parenta4969614eac16f3d089c51d2b976b4a1bc3a3910 (diff)
downloadglibc-814fc245e5c795e2964ee256e8ceb47c67429e66.tar.gz
glibc-814fc245e5c795e2964ee256e8ceb47c67429e66.tar.xz
glibc-814fc245e5c795e2964ee256e8ceb47c67429e66.zip
(__ptsname_r): Use sizeof where appropriate instead of numbers. Little optimizations.
Diffstat (limited to 'sysdeps/unix/sysv/linux/ptsname.c')
-rw-r--r--sysdeps/unix/sysv/linux/ptsname.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sysdeps/unix/sysv/linux/ptsname.c b/sysdeps/unix/sysv/linux/ptsname.c
index 0bdc5edaf3..ec578b3c95 100644
--- a/sysdeps/unix/sysv/linux/ptsname.c
+++ b/sysdeps/unix/sysv/linux/ptsname.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
 
@@ -96,19 +96,19 @@ __ptsname_r (int fd, char *buf, size_t buflen)
          `int' of 8 bytes we never need more than 20 digits.  */
       char numbuf[21];
       const char *devpts = _PATH_DEVPTS;
-      const size_t devptslen = strlen (devpts);
+      const size_t devptslen = strlen (_PATH_DEVPTS);
       char *p;
 
-      numbuf[20] = '\0';
-      p = _itoa_word (ptyno, &numbuf[20], 10, 0);
+      numbuf[sizeof (numbuf) - 1] = '\0';
+      p = _itoa_word (ptyno, &numbuf[sizeof (numbuf) - 1], 10, 0);
 
-      if (buflen < devptslen + strlen (p) + 1)
+      if (buflen < devptslen + &numbuf[sizeof (numbuf)] - p)
 	{
 	  __set_errno (ERANGE);
 	  return ERANGE;
 	}
 
-      __stpcpy (__stpcpy (buf, devpts), p);
+      memcpy (__stpcpy (buf, devpts), p, &numbuf[sizeof (numbuf)] - p);
     }
   else if (errno == EINVAL)
 #endif