From owner-svn-src-all@FreeBSD.ORG Tue Jun 5 19:41:05 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CCEDF1065749; Tue, 5 Jun 2012 19:41:05 +0000 (UTC) (envelope-from ache@vniz.net) Received: from vniz.net (vniz.net [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 2C4BE8FC19; Tue, 5 Jun 2012 19:41:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vniz.net (8.14.5/8.14.5) with ESMTP id q55Jf2ab021290; Tue, 5 Jun 2012 23:41:03 +0400 (MSK) (envelope-from ache@vniz.net) Received: (from ache@localhost) by localhost (8.14.5/8.14.5/Submit) id q55Jf25B021289; Tue, 5 Jun 2012 23:41:02 +0400 (MSK) (envelope-from ache) Date: Tue, 5 Jun 2012 23:41:02 +0400 From: Andrey Chernov To: Bruce Evans Message-ID: <20120605194102.GA21173@vniz.net> Mail-Followup-To: Andrey Chernov , Bruce Evans , svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG, Pawel Jakub Dawidek , freebsd-arch@FreeBSD.ORG References: <201206042134.q54LYoVJ067685@svn.freebsd.org> <20120605074741.GA1391@garage.freebsd.pl> <20120605130922.GE13306@vniz.net> <20120606043731.D1124@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120606043731.D1124@besplex.bde.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG, Pawel Jakub Dawidek , freebsd-arch@FreeBSD.ORG Subject: Re: svn commit: r236582 - head/lib/libc/stdlib X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Tue, 05 Jun 2012 19:41:05 -0000 On Wed, Jun 06, 2012 at 04:57:29AM +1000, Bruce Evans wrote: > POSIX may require errno to not be clobbered, especially for its functions. > It probably shouldn't do this for Standard C library functions like free(), > since this would be an extension and any use of the extension would give > unnecessarily unportanle code. POSIX feels itself like they own all Standard C functions now. See "Resolved state" text for upcoming standard there: "At line 30583 [XSH free DESCRIPTION], add a paragraph with CX shading: The free() function shall not modify errno if ptr is a null pointer or a pointer previously returned as if by malloc() and not yet deallocated. At line 30591 [APPLICATION USAGE], add a new paragraph: Because the free() function does not modify errno for valid pointers, it is safe to use it in cleanup code without corrupting earlier errors, ..." > OTOH, the libary can assume anything that it wants and > implements for itself, since it is the implementation so it can make > free() easy to use for itself, with any extensions that aren't incompatible > with Standard C. Since free() is allowed to clobber errno, it is also > allowed to do a null clobber as a compatible extension. Yes, it is safe for free() itself to save errno and still stay compliant with both current and upcoming POSIX and with Standard C. But any code which rely on that is compliant with upcoming POSIX only. Since people don't want mass changes in that area, this is some sort of compromise acceptable for me (in case free() itself will save/restore errno, of course). -- http://ache.vniz.net/