o Fix a couple off-by-one errors, style(9).
This commit is contained in:
parent
baaa487753
commit
6e14f80bcc
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=27560
1 changed files with 8 additions and 8 deletions
|
@ -357,11 +357,11 @@ echo_write(dev_t dev, struct uio *uio, int ioflag)
|
|||
|
||||
/* Copy the string in from user memory to kernel memory */
|
||||
err = copyin(uio->uio_iov->iov_base, echomsg->msg,
|
||||
MIN(uio->uio_iov->iov_len,BUFFERSIZE - 1));
|
||||
MIN(uio->uio_iov->iov_len, BUFFERSIZE - 1));
|
||||
|
||||
/* Now we need to null terminate, then record the length */
|
||||
*(echomsg->msg + MIN(uio->uio_iov->iov_len,BUFFERSIZE - 1)) = 0;
|
||||
echomsg->len = MIN(uio->uio_iov->iov_len,BUFFERSIZE);
|
||||
*(echomsg->msg + MIN(uio->uio_iov->iov_len, BUFFERSIZE - 1)) = 0;
|
||||
echomsg->len = MIN(uio->uio_iov->iov_len, BUFFERSIZE);
|
||||
|
||||
if (err != 0) {
|
||||
uprintf("Write failed: bad address!\n");
|
||||
|
@ -493,9 +493,9 @@ echo_read(struct cdev *dev, struct uio *uio, int ioflag)
|
|||
* How big is this read operation? Either as big as the user wants,
|
||||
* or as big as the remaining data
|
||||
*/
|
||||
amt = MIN(uio->uio_resid, (echomsg->len - uio->uio_offset > 0) ?
|
||||
amt = MIN(uio->uio_resid, (echomsg->len - uio->uio_offset > 0) ?
|
||||
echomsg->len - uio->uio_offset : 0);
|
||||
if ((err = uiomove(echomsg->msg + uio->uio_offset,amt,uio)) != 0) {
|
||||
if ((err = uiomove(echomsg->msg + uio->uio_offset, amt, uio)) != 0) {
|
||||
uprintf("uiomove failed!\n");
|
||||
}
|
||||
return(err);
|
||||
|
@ -513,11 +513,11 @@ echo_write(struct cdev *dev, struct uio *uio, int ioflag)
|
|||
|
||||
/* Copy the string in from user memory to kernel memory */
|
||||
err = copyin(uio->uio_iov->iov_base, echomsg->msg,
|
||||
MIN(uio->uio_iov->iov_len,BUFFERSIZE));
|
||||
MIN(uio->uio_iov->iov_len, BUFFERSIZE - 1));
|
||||
|
||||
/* Now we need to null terminate, then record the length */
|
||||
*(echomsg->msg + MIN(uio->uio_iov->iov_len,BUFFERSIZE)) = 0;
|
||||
echomsg->len = MIN(uio->uio_iov->iov_len,BUFFERSIZE);
|
||||
*(echomsg->msg + MIN(uio->uio_iov->iov_len, BUFFERSIZE - 1)) = 0;
|
||||
echomsg->len = MIN(uio->uio_iov->iov_len, BUFFERSIZE);
|
||||
|
||||
if (err != 0) {
|
||||
uprintf("Write failed: bad address!\n");
|
||||
|
|
Loading…
Reference in a new issue