From owner-freebsd-standards@FreeBSD.ORG Fri Jan 24 22:39:21 2014 Return-Path: Delivered-To: freebsd-standards@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AB8FB341; Fri, 24 Jan 2014 22:39:21 +0000 (UTC) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6DA28101F; Fri, 24 Jan 2014 22:39:21 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id DC283359306; Fri, 24 Jan 2014 23:39:18 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id CB31228497; Fri, 24 Jan 2014 23:39:18 +0100 (CET) Date: Fri, 24 Jan 2014 23:39:18 +0100 From: Jilles Tjoelker To: Bryan Drewery Subject: Re: closedir(3) handling NULL Message-ID: <20140124223918.GA97844@stack.nl> References: <20140124014105.GC37334@admin.xzibition.com> <20140124132435.GA90996@stack.nl> <20140124165509.GA73838@admin.xzibition.com> <20140125041504.Y986@besplex.bde.org> <20140124213404.GC73838@admin.xzibition.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140124213404.GC73838@admin.xzibition.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: bapt@FreeBSD.org, freebsd-standards@FreeBSD.org X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jan 2014 22:39:21 -0000 On Fri, Jan 24, 2014 at 03:34:04PM -0600, Bryan Drewery wrote: > On Sat, Jan 25, 2014 at 06:00:08AM +1100, Bruce Evans wrote: > > On Fri, 24 Jan 2014, Bryan Drewery wrote: > > > I do think that improving portability is important. Even against > > > sloppy coding. Applications developed for Linux are fine passing > > > NULL to closedir(3), which leads to a style of coding that does > > > not reveal itself to be a problem on FreeBSD until an edge case > > > comes up. > > This unimproves portability. FreeBSD intentionally does the > > opposite for fclose(): from fclose(3): > IMHO we should handle NULL gracefully in all places instead of having > hidden surprises. In many cases (but possibly not this one), handling NULL "gracefully" makes it harder to debug the inevitable failure. For example, if readdir() did not crash when passed a null pointer, a program that fails to check opendir()'s return value would plough on for longer and it would be harder to find the problem. Whether a function that frees something silently does nothing when passed a null pointer is indeed inconsistent. -- Jilles Tjoelker