From owner-svn-src-all@FreeBSD.ORG Fri Feb 13 16:07:39 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D79A2A78 for ; Fri, 13 Feb 2015 16:07:39 +0000 (UTC) Received: from nm44-vm7.bullet.mail.bf1.yahoo.com (nm44-vm7.bullet.mail.bf1.yahoo.com [216.109.115.31]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8A16526D for ; Fri, 13 Feb 2015 16:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1423843264; bh=MjH1ZtrmLjf1z/uuXaINgd1QGTTmDHyixjh4kVxTlzI=; h=Date:From:To:CC:Subject:References:In-Reply-To:From:Subject; b=KpgU7nBztT0fC0r7zqaTeKxQPym3Xmp9hM1Yx3+ajr99xTv69P5dLsv0prJ7/7lwM0bI0J29FN98Ic/AWAY+q65KOKvq1Ru0W1l7hXDdZOJx7DP0j3gh+jtoSSB5U1JFBArGZFrk8b3ug4IuRtv7oEXReYKSleT/ji9pOHlGO+B2PBggB74Z6lK+mIsi9l51shP3CTNxDTkJwpYaTF2NdkPMsfrsyFGUzR4M6iFHjCWz3uN62jxY7Ov+TDI3D4SdY75Cw1dvELNQ41rB0dJQK2L8jb99HN2qaDwUwHtJBy0Tqm0jHrU7grZPPIIGxE5JbupD7loy8HktymmdkqK/MA== Received: from [98.139.215.143] by nm44.bullet.mail.bf1.yahoo.com with NNFMP; 13 Feb 2015 16:01:04 -0000 Received: from [98.139.211.195] by tm14.bullet.mail.bf1.yahoo.com with NNFMP; 13 Feb 2015 16:01:04 -0000 Received: from [127.0.0.1] by smtp204.mail.bf1.yahoo.com with NNFMP; 13 Feb 2015 16:01:04 -0000 X-Yahoo-Newman-Id: 516109.36204.bm@smtp204.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: swiegUsVM1lTZrJU3SZTlJ8mgMNuLl_U_SFabpCfWK._vFO P3gmscn4lXkhIDD9wGIsKjHjS4J9gL6IYIy_okl57UsTRNU2ABwRSHWcpeyn DkFyL_eXWJaBx8QF_lSO6LscyK9VJBUusUppp.xPeuQnbOInfFRyUGGs50z1 r9ovX1r2Uf7aWoh6Nq5eJsbxEsneDUl_pnUA6rXLPHD.ajh0gPfmOHnDU0bC 2l65Dv6stM2HwJX6cgl0c6m_pI5H7tQNVnEp_Gix_dZ7EY1x82Ax29atdqFl Pf5yoJ7_vjy0cUqYLwe3bKxgOZb4Ww1OWDXEOICDHf16XjFp0daVjWyO4WP2 UfERUxHXlSnvExq118n6P1E.aup1VmMEr5OreaWa0Kt7DaOo6j3nS3fVBjpf dcRBQApyY42Pzn1ZC97gb9.pJuLN4qkWb8fZmRHDGeuNmgBmcmyz2S9PEYX3 w3bd2jQPHeWKlQpIDVmCqh.bXToBjGrTYV4Cxp21BEojRCV_SnUh6OK0eRod R.nV8bp5gpTxxfOFczxv52HjViViz.BL4 X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf Message-ID: <54DE1FC9.4000503@FreeBSD.org> Date: Fri, 13 Feb 2015 11:01:13 -0500 From: Pedro Giffuni User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Bruce Evans , Andrey Chernov Subject: Re: svn commit: r278634 - head/lib/libc/gen References: <201502122107.t1CL7gaO004041@svn.freebsd.org> <54DD2A87.2050008@FreeBSD.org> <9A683D99-C1E9-4736-982C-69F583D3A40D@FreeBSD.org> <20150213172738.C1007@besplex.bde.org> <54DDABF2.9000201@freebsd.org> <54DDAEF6.3060900@freebsd.org> <20150214005543.X2210@besplex.bde.org> In-Reply-To: <20150214005543.X2210@besplex.bde.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2015 16:07:40 -0000 On 02/13/15 09:29, Bruce Evans wrote: > On Fri, 13 Feb 2015, Andrey Chernov wrote: > >> We even don't need to check arg excepting for < 0, because what is >> needed is rlimt_t and not arg. So this version will be better: >> >> rlimt_t targ; >> >> if (arg < 0) { >> errno = EINVAL; >> return (-1); >> } > > > This is reasonable, but not encouraged by the API or compatible with > what setrlimit() does with negative args. (setrlimit() still uses > my hack from 1994, of converting negative args to RLIM_INFINITY. In > 4.4BSD, it doesn't even check for negative args, and mostly stores > them unchanged; then undefined behaviour tends to occur when the > stored values are used without further checking.) > Actually I think the above check would be OK according to POSIX: ... The /ulimit/() function shall fail and the limit shall be unchanged if: [EINVAL] The /cmd/ argument is not valid. ... ... > An incomplete fix with handling of negative values restored is something > like: > > intmax_t targ; > > targ = arg; > if (targ > RLIM_INFINITY / 512) > targ = RLIM_INFINITY / 512; > limit.rlim_max = limit.rlim_cur = targ * 512 > > This is still incomplete. The comparison is still obviously tautologous > when intmax_t == rlim_t (the amd64 case). If intmax_t is larger than > long (the i386 case) or even rlim_t (the notyet case), then it is > slightly > less obviously tautologous. This can be fixed by sprinkling volatiles, > e.g. for targ. > I am passing this (with the check for negative values and __intmax_t) through the tinderbox. FWIW, I had something else that managed to compile but is *very* ugly and can cause an effect similar to tear gas on sensitive eyes ;). Pedro.