Author: pfg
Date: Tue Jul 22 23:29:54 2014
New Revision: 269001
URL: http://svnweb.freebsd.org/changeset/base/269001

Log:
  Avoid possible cast degradation.
  
  For consistency with r268985 for fputs.c, assign iov_len
  first, avoiding the cast to uio_resid (int in stdio)
  from degrading the value.
  
  We currently don't support lengths higher than INT_MAX so
  this change is little more than cosmetic.
  
  MFC after:    3 days

Modified:
  head/lib/libc/stdio/fputws.c
  head/lib/libc/stdio/putw.c

Modified: head/lib/libc/stdio/fputws.c
==============================================================================
--- head/lib/libc/stdio/fputws.c        Tue Jul 22 23:16:28 2014        
(r269000)
+++ head/lib/libc/stdio/fputws.c        Tue Jul 22 23:29:54 2014        
(r269001)
@@ -67,7 +67,7 @@ fputws_l(const wchar_t * __restrict ws, 
                    &fp->_mbstate);
                if (nbytes == (size_t)-1)
                        goto error;
-               iov.iov_len = uio.uio_resid = nbytes;
+               uio.uio_resid = iov.iov_len = nbytes;
                if (__sfvwrite(fp, &uio) != 0)
                        goto error;
        } while (wsp != NULL);

Modified: head/lib/libc/stdio/putw.c
==============================================================================
--- head/lib/libc/stdio/putw.c  Tue Jul 22 23:16:28 2014        (r269000)
+++ head/lib/libc/stdio/putw.c  Tue Jul 22 23:29:54 2014        (r269001)
@@ -50,7 +50,7 @@ putw(int w, FILE *fp)
        struct __siov iov;
 
        iov.iov_base = &w;
-       iov.iov_len = uio.uio_resid = sizeof(w);
+       uio.uio_resid = iov.iov_len = sizeof(w);
        uio.uio_iov = &iov;
        uio.uio_iovcnt = 1;
        FLOCKFILE(fp);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to