Date: Tue, 22 Jul 2014 23:29:55 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r269001 - head/lib/libc/stdio Message-ID: <201407222329.s6MNTtLI069643@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407222329.s6MNTtLI069643>