Date: Sat, 28 Feb 2009 14:20:26 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r189167 - head/sys/kern Message-ID: <200902281420.n1SEKQCe010904@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Sat Feb 28 14:20:26 2009 New Revision: 189167 URL: http://svn.freebsd.org/changeset/base/189167 Log: Replace bcopy() calls inside the TTY layer with memcpy()/strlcpy(). In all these cases the buffers never overlap. Program names are also likely to be shorter, so use a regular strlcpy() to copy p_comm. Modified: head/sys/kern/tty.c head/sys/kern/tty_info.c head/sys/kern/tty_pts.c Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Sat Feb 28 11:25:05 2009 (r189166) +++ head/sys/kern/tty.c Sat Feb 28 14:20:26 2009 (r189167) @@ -724,14 +724,14 @@ ttyil_ioctl(struct cdev *dev, u_long cmd switch (cmd) { case TIOCGETA: /* Obtain terminal flags through tcgetattr(). */ - bcopy(dev->si_drv2, data, sizeof(struct termios)); + memcpy(data, dev->si_drv2, sizeof(struct termios)); break; case TIOCSETA: /* Set terminal flags through tcsetattr(). */ error = priv_check(td, PRIV_TTY_SETA); if (error) break; - bcopy(data, dev->si_drv2, sizeof(struct termios)); + memcpy(dev->si_drv2, data, sizeof(struct termios)); break; case TIOCGETD: *(int *)data = TTYDISC; @@ -769,7 +769,7 @@ tty_init_termios(struct tty *tp) t->c_oflag = TTYDEF_OFLAG; t->c_ispeed = TTYDEF_SPEED; t->c_ospeed = TTYDEF_SPEED; - bcopy(ttydefchars, &t->c_cc, sizeof ttydefchars); + memcpy(&t->c_cc, ttydefchars, sizeof ttydefchars); tp->t_termios_init_out = *t; } @@ -1344,7 +1344,7 @@ tty_generic_ioctl(struct tty *tp, u_long return (0); case TIOCGETA: /* Obtain terminal flags through tcgetattr(). */ - bcopy(&tp->t_termios, data, sizeof(struct termios)); + memcpy(data, &tp->t_termios, sizeof(struct termios)); return (0); case TIOCSETA: case TIOCSETAW: @@ -1399,7 +1399,7 @@ tty_generic_ioctl(struct tty *tp, u_long tp->t_termios.c_iflag = t->c_iflag; tp->t_termios.c_oflag = t->c_oflag; tp->t_termios.c_lflag = t->c_lflag; - bcopy(t->c_cc, &tp->t_termios.c_cc, sizeof(t->c_cc)); + memcpy(&tp->t_termios.c_cc, t->c_cc, sizeof t->c_cc); ttydisc_optimize(tp); @@ -1568,13 +1568,13 @@ tty_generic_ioctl(struct tty *tp, u_long return (0); case TIOCGWINSZ: /* Obtain window size. */ - bcopy(&tp->t_winsize, data, sizeof(struct winsize)); + memcpy(data, &tp->t_winsize, sizeof(struct winsize)); return (0); case TIOCSWINSZ: /* Set window size. */ if (bcmp(&tp->t_winsize, data, sizeof(struct winsize)) == 0) return (0); - bcopy(data, &tp->t_winsize, sizeof(struct winsize)); + memcpy(&tp->t_winsize, data, sizeof(struct winsize)); tty_signal_pgrp(tp, SIGWINCH); return (0); case TIOCEXCL: Modified: head/sys/kern/tty_info.c ============================================================================== --- head/sys/kern/tty_info.c Sat Feb 28 11:25:05 2009 (r189166) +++ head/sys/kern/tty_info.c Sat Feb 28 14:20:26 2009 (r189167) @@ -299,7 +299,7 @@ tty_info(struct tty *tp) PGRP_UNLOCK(tp->t_pgrp); rufetchcalc(pick, &ru, &utime, &stime); pid = pick->p_pid; - bcopy(pick->p_comm, comm, sizeof(comm)); + strlcpy(comm, pick->p_comm, sizeof comm); PROC_UNLOCK(pick); /* Print command, pid, state, utime, stime, %cpu, and rss. */ Modified: head/sys/kern/tty_pts.c ============================================================================== --- head/sys/kern/tty_pts.c Sat Feb 28 11:25:05 2009 (r189166) +++ head/sys/kern/tty_pts.c Sat Feb 28 14:20:26 2009 (r189167) @@ -310,7 +310,7 @@ ptsdev_ioctl(struct file *fp, u_long cmd case TIOCGETA: /* Obtain terminal flags through tcgetattr(). */ tty_lock(tp); - bcopy(&tp->t_termios, data, sizeof(struct termios)); + memcpy(data, &tp->t_termios, sizeof(struct termios)); tty_unlock(tp); return (0); #endif /* PTS_LINUX */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902281420.n1SEKQCe010904>