Discussion:
tty uiomove() conversion
Martin Natano
2016-01-13 21:30:12 UTC
Permalink
Below the conversion from uiomovei() to uiomove() for kern/tty.c and
kern/tty_pty.c. 'cc' consistently contains small, non-negative integer
values, so leaving the type as int should be ok. It could as well be
changed to size_t, but I don't see a benefit in doing so for that
particular case, except for a lot of unnecessary code churn.

Index: kern/tty.c
===================================================================
RCS file: /cvs/src/sys/kern/tty.c,v
retrieving revision 1.127
diff -u -p -u -r1.127 tty.c
--- kern/tty.c 5 Dec 2015 10:11:53 -0000 1.127
+++ kern/tty.c 13 Jan 2016 21:22:22 -0000
@@ -1782,7 +1782,7 @@ loop:
if (cc == 0) {
cc = MIN(uio->uio_resid, OBUFSIZ);
cp = obuf;
- error = uiomovei(cp, cc, uio);
+ error = uiomove(cp, cc, uio);
if (error) {
cc = 0;
break;
Index: kern/tty_pty.c
===================================================================
RCS file: /cvs/src/sys/kern/tty_pty.c,v
retrieving revision 1.74
diff -u -p -u -r1.74 tty_pty.c
--- kern/tty_pty.c 5 Dec 2015 10:11:53 -0000 1.74
+++ kern/tty_pty.c 13 Jan 2016 21:22:22 -0000
@@ -461,7 +461,7 @@ ptcread(dev_t dev, struct uio *uio, int
if (pti->pt_send & TIOCPKT_IOCTL) {
cc = MIN(uio->uio_resid,
sizeof(tp->t_termios));
- error = uiomovei(&tp->t_termios, cc, uio);
+ error = uiomove(&tp->t_termios, cc, uio);
if (error)
return (error);
}
@@ -496,7 +496,7 @@ ptcread(dev_t dev, struct uio *uio, int
bufcc = cc;
if (cc <= 0)
break;
- error = uiomovei(buf, cc, uio);
+ error = uiomove(buf, cc, uio);
}
ttwakeupwr(tp);
if (bufcc)
@@ -529,7 +529,7 @@ again:
if (cc > bufcc)
bufcc = cc;
cp = buf;
- error = uiomovei(cp, cc, uio);
+ error = uiomove(cp, cc, uio);
if (error)
goto done;
/* check again for safety */
@@ -553,7 +553,7 @@ again:
if (cc > bufcc)
bufcc = cc;
cp = buf;
- error = uiomovei(cp, cc, uio);
+ error = uiomove(cp, cc, uio);
if (error)
goto done;
/* check again for safety */

cheers,
natano
Stefan Kempf
2016-01-23 18:50:30 UTC
Permalink
Post by Martin Natano
Below the conversion from uiomovei() to uiomove() for kern/tty.c and
kern/tty_pty.c. 'cc' consistently contains small, non-negative integer
values, so leaving the type as int should be ok. It could as well be
changed to size_t, but I don't see a benefit in doing so for that
particular case, except for a lot of unnecessary code churn.
Looks good. It's easy to see that cc is always > 0 when passed to
uiomove() here.
Post by Martin Natano
Index: kern/tty.c
===================================================================
RCS file: /cvs/src/sys/kern/tty.c,v
retrieving revision 1.127
diff -u -p -u -r1.127 tty.c
--- kern/tty.c 5 Dec 2015 10:11:53 -0000 1.127
+++ kern/tty.c 13 Jan 2016 21:22:22 -0000
if (cc == 0) {
cc = MIN(uio->uio_resid, OBUFSIZ);
cp = obuf;
- error = uiomovei(cp, cc, uio);
+ error = uiomove(cp, cc, uio);
if (error) {
cc = 0;
break;
Index: kern/tty_pty.c
===================================================================
RCS file: /cvs/src/sys/kern/tty_pty.c,v
retrieving revision 1.74
diff -u -p -u -r1.74 tty_pty.c
--- kern/tty_pty.c 5 Dec 2015 10:11:53 -0000 1.74
+++ kern/tty_pty.c 13 Jan 2016 21:22:22 -0000
@@ -461,7 +461,7 @@ ptcread(dev_t dev, struct uio *uio, int
if (pti->pt_send & TIOCPKT_IOCTL) {
cc = MIN(uio->uio_resid,
sizeof(tp->t_termios));
- error = uiomovei(&tp->t_termios, cc, uio);
+ error = uiomove(&tp->t_termios, cc, uio);
if (error)
return (error);
}
@@ -496,7 +496,7 @@ ptcread(dev_t dev, struct uio *uio, int
bufcc = cc;
if (cc <= 0)
break;
- error = uiomovei(buf, cc, uio);
+ error = uiomove(buf, cc, uio);
}
ttwakeupwr(tp);
if (bufcc)
if (cc > bufcc)
bufcc = cc;
cp = buf;
- error = uiomovei(cp, cc, uio);
+ error = uiomove(cp, cc, uio);
if (error)
goto done;
/* check again for safety */
if (cc > bufcc)
bufcc = cc;
cp = buf;
- error = uiomovei(cp, cc, uio);
+ error = uiomove(cp, cc, uio);
if (error)
goto done;
/* check again for safety */
cheers,
natano
Loading...