From owner-svn-src-head@freebsd.org Wed May 3 15:24:34 2017 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 2B5BCD5B663 for ; Wed, 3 May 2017 15:24:34 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from nm28-vm5.bullet.mail.ne1.yahoo.com (nm28-vm5.bullet.mail.ne1.yahoo.com [98.138.91.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F360536A for ; Wed, 3 May 2017 15:24:33 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1493823410; bh=7zSGuw3o1V4/9M1EgMyZBAhP9GEObO5ZfCx4EbsN/aw=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From:Subject; b=lSd/nQovXFc7AD1tNkDyj3ocL5M+FIH8sGnypG7MMuFl1APVFcR8WQFrZq/aTnGAmfGm2dlqsE5MofV6RKrRvtTk4ayyswP/9aAhi8MoqkmLhel8UPRKDAyWwOOunx8vXLGtJpnjFqUhsPFB4SvxfOCw970zwPLXmI7B6C5dupye8WUJg4l8xi6qUT+o5u066gWCE4CDv+do3FvUyNXpfTaHiM/CbKv6kEIInq12MaFVfbaBKze/GtXLeD72T6oLYLRj6/+qB0Vq9BqXlg9wkX+xtU53FtSTMHf/sT6PxUeMLYnlW57limBWBO75JnCS98iNDM0qlRbyv/n9zIRztQ== Received: from [98.138.100.102] by nm28.bullet.mail.ne1.yahoo.com with NNFMP; 03 May 2017 14:56:50 -0000 Received: from [98.138.84.39] by tm101.bullet.mail.ne1.yahoo.com with NNFMP; 03 May 2017 14:56:50 -0000 Received: from [127.0.0.1] by smtp107.mail.ne1.yahoo.com with NNFMP; 03 May 2017 14:56:50 -0000 X-Yahoo-Newman-Id: 99512.45305.bm@smtp107.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: EjxUD4oVM1ktQNyxynYm340.yVWuRdXG7UamQguMNGw9iCi Gvfcv9P4bRyjVjAuOU2h6VSRp19ltNFmI_WXw20FwSa1Ep4PBk2WF0TrTnVr COsFNx4yBMsu3VdR_KcxGv48gtjmBlgF4oJ6hjoEx4Gq4F3.Q4DX7NYTLiW7 mNUCTFybekPkLM64bK03XZvFQCpJOtkhCujnjAqaqMs4ATerIw_vV9ZVEUxk XaRmt67o5bfwRo4BoSAnvU.bfxerJeNYQ7Bg1URbSqhXwYrBMfhrXlVwc4iL 3YfhdFzwnHrWwp4CkdGFjdQZYglTqL9QMv6m.4z86TYKRuz4zVK6T.vvoZN3 mLGLBcivlYnPv83_XG_a4hyScsxv.kpnsjTS5AUdRwgHxvsjbhDE5d1xxKC_ _LEf1VaCIBDmyDinEs9SHbV0wMi5m8T3G821fQmVGFzaItFjyNEx7OglD7EK ..Eic4N4Ur2jHiPgHLsrpBypU_M8b13uaAWoydWpxgjH0a_HDhVCyA964TDm e0WQur0ztS2jzPvKK30xzDsb4Y_c.VxQkCrSTPQbryo8A X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf Subject: Re: svn commit: r317709 - head/usr.bin/csplit To: Bruce Evans , Jilles Tjoelker References: <201705022156.v42LuKbp088899@repo.freebsd.org> <20170503162918.U1062@besplex.bde.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Pedro Giffuni Organization: FreeBSD Project Message-ID: <2c7bd200-957d-2c36-076e-41d4d04a2956@FreeBSD.org> Date: Wed, 3 May 2017 09:56:49 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170503162918.U1062@besplex.bde.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 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: Wed, 03 May 2017 15:24:34 -0000 On 3/5/2017 01:55, Bruce Evans wrote: > On Tue, 2 May 2017, Jilles Tjoelker wrote: > >> Log: >> csplit: Fix check of fputs() return value, making csplit work again. >> >> As of r295638, fputs() returns the number of bytes written (if not >> more than >> INT_MAX). This broke csplit completely, since csplit assumed only >> success >> only for the return value 0. >> >> PR: 213510 >> Submitted by: J.R. Oldroyd >> MFC after: 1 week >> Relnotes: yes >> >> Modified: >> head/usr.bin/csplit/csplit.c >> >> Modified: head/usr.bin/csplit/csplit.c >> ============================================================================== >> >> --- head/usr.bin/csplit/csplit.c Tue May 2 21:33:27 2017 (r317708) >> +++ head/usr.bin/csplit/csplit.c Tue May 2 21:56:20 2017 (r317709) >> @@ -195,7 +195,7 @@ main(int argc, char *argv[]) >> /* Copy the rest into a new file. */ >> if (!feof(infile)) { >> ofp = newfile(); >> - while ((p = get_line()) != NULL && fputs(p, ofp) == 0) >> + while ((p = get_line()) != NULL && fputs(p, ofp) != EOF) >> ; >> if (!sflag) >> printf("%jd\n", (intmax_t)ftello(ofp)); > > I don't like checking for the specific value EOF instead of any negative > value, though the EOF is Standard and I like checking for specific -1 > for sysctls. stdio is not very consistent, and this bug is due to old > versions of FreeBSD documenting and returning the specific value 0 on > non-error, which was also Standard. > The standard says non-negative, expecting zero to be the only non-negative value is a bug. The idea was mostly to match the MacOS behavior. MacOS buildbots are expensive and some projects find it's useful to have a FreeBSD builbot to have some idea when non-portable behavior is introduced. > Grepping for fputs in /usr/src shows too many instances to check (mostly > without any error handling). The simplest filter 'if (fputs' found the > dependency on the old FreeBSD behaviour in csplit and 2 other places: > > contrib/mdocml/main.c: if (fputs(cp, stdout)) { > contrib/mdocml/main.c- fclose(stream); > contrib/libreadline/examples/rlcat.c: if (fputs (x, stdout) != 0) > contrib/libreadline/examples/rlcat.c- return 1; > > More complicated filters like 'if ([^(]]*[^a-z_]fputs' failed to find > any problems since I messed up the regexp. > I admittedly ignored contrib, plus I only skimmed for comparisons to zero. Now I am worried: the classic BSD implementation is ubiquitous and this bug is not easy to find, particularly in ports. Do you guys think it we should revert to the previous behavior, at least for 11.1? The bugs should be reported upstream but it is not really our battle to fix the world for Apple is it? Pedro.