Martin Natano wrote:
> Below the uiomove() conversion for net/ppp_tty.c. M_TRAILINGSPACE()
> returns int, but the result can't be negative, so using u_int for the
> return value should be fine.

Looks good. m->m_len is unsigned and yes, given that the mbuf fields
aren't corrupted M_TRAILINGSPACE is >= 0.

ok?
 
> Index: net/ppp_tty.c
> ===================================================================
> RCS file: /cvs/src/sys/net/ppp_tty.c,v
> retrieving revision 1.41
> diff -u -p -u -r1.41 ppp_tty.c
> --- net/ppp_tty.c     21 Dec 2015 21:49:02 -0000      1.41
> +++ net/ppp_tty.c     13 Jan 2016 19:44:53 -0000
> @@ -321,7 +321,7 @@ pppread(struct tty *tp, struct uio *uio,
>      splx(s);
>  
>      for (m = m0; m && uio->uio_resid; m = m->m_next)
> -     if ((error = uiomovei(mtod(m, u_char *), m->m_len, uio)) != 0)
> +     if ((error = uiomove(mtod(m, u_char *), m->m_len, uio)) != 0)
>           break;
>      m_freem(m0);
>      return (error);
> @@ -336,7 +336,8 @@ pppwrite(struct tty *tp, struct uio *uio
>      struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;
>      struct mbuf *m, *m0, **mp;
>      struct sockaddr dst;
> -    int len, error;
> +    u_int len;
> +    int error;
>  
>      if ((tp->t_state & TS_CARR_ON) == 0 && (tp->t_cflag & CLOCAL) == 0)
>       return 0;               /* wrote 0 bytes */
> @@ -361,7 +362,7 @@ pppwrite(struct tty *tp, struct uio *uio
>       len = M_TRAILINGSPACE(m);
>       if (len > uio->uio_resid)
>           len = uio->uio_resid;
> -     if ((error = uiomovei(mtod(m, u_char *), len, uio)) != 0) {
> +     if ((error = uiomove(mtod(m, u_char *), len, uio)) != 0) {
>           m_freem(m0);
>           return (error);
>       }
> 
> cheers,
> natano
> 

Reply via email to