From owner-svn-src-head@freebsd.org Mon Feb 15 20:48:12 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E062AA8D68; Mon, 15 Feb 2016 20:48:12 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id 69A9A38A; Mon, 15 Feb 2016 20:48:11 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c110-21-41-193.carlnfd1.nsw.optusnet.com.au (c110-21-41-193.carlnfd1.nsw.optusnet.com.au [110.21.41.193]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id A71C3428A6F; Tue, 16 Feb 2016 07:48:01 +1100 (AEDT) Date: Tue, 16 Feb 2016 07:48:00 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: "Pedro F. Giffuni" cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r295631 - head/lib/libc/stdio In-Reply-To: <201602151813.u1FIDXAt067326@repo.freebsd.org> Message-ID: <20160216073421.B1073@besplex.bde.org> References: <201602151813.u1FIDXAt067326@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=cK4dyQqN c=1 sm=1 tr=0 a=73JWPhLeruqQCjN69UNZtQ==:117 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=6I5d2MoRAAAA:8 a=eSLwWqLpvfrKKQYTYqUA:9 a=AW_D2bVKUYMoeODe:21 a=L81pZzv6jk-Ry1xg:21 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Feb 2016 20:48:12 -0000 On Mon, 15 Feb 2016, Pedro F. Giffuni wrote: > Log: > fputs: Return the number of bytes written. > > POSIX.1-2008 requires that successful completion simply return a > non-negative integer. We have regularly returned a constant value. > Another, equally valid, implementation convention implies returning > the number of bytes written. > > Adopt this last convention to be in line with what Apple's libc > does. POSIX also explicitly notes: > > Note that this implementation convention cannot be adhered to for strings > longer than {INT_MAX} bytes as the value would not be representable in the > return type of the function. For backwards-compatibility, implementations > can return the number of bytes for strings of up to {INT_MAX} bytes, and > return {INT_MAX} for all longer strings. > > Developers shouldn't depend specifically on either convention but > the change may help port software from Apple. > > Differential Revision: https://reviews.freebsd.org/D442 (Partial) > Obtained from: Apple Inc. (Libc 997.90.3 with changes) > Relnotes: yes > > Modified: > head/lib/libc/stdio/fputs.c > > Modified: head/lib/libc/stdio/fputs.c > ============================================================================== > --- head/lib/libc/stdio/fputs.c Mon Feb 15 17:14:10 2016 (r295630) > +++ head/lib/libc/stdio/fputs.c Mon Feb 15 18:13:33 2016 (r295631) > @@ -37,6 +37,7 @@ static char sccsid[] = "@(#)fputs.c 8.1 > __FBSDID("$FreeBSD$"); > > #include "namespace.h" > +#include > #include > #include > #include "un-namespace.h" > @@ -62,5 +63,7 @@ fputs(const char * __restrict s, FILE * > ORIENT(fp, -1); > retval = __sfvwrite(fp, &uio); > FUNLOCKFILE(fp); > + if (retval == 0) > + return (iov.iov_len > INT_MAX ? INT_MAX : uio.uio_resid); > return (retval); > } Testing would have shown that this change has no effect except in the unusual case where iov.iov_len > INT_MAX. uio.resid is always reduced to 0 if all the output actually worked. Bruce