From owner-freebsd-arch@FreeBSD.ORG  Sat May 12 22:25:10 2007
Return-Path: <owner-freebsd-arch@FreeBSD.ORG>
X-Original-To: arch@FreeBSD.org
Delivered-To: freebsd-arch@FreeBSD.ORG
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 4F03416A407;
	Sat, 12 May 2007 22:25:10 +0000 (UTC)
	(envelope-from sean-freebsd@farley.org)
Received: from mail.farley.org (farley.org [67.64.95.201])
	by mx1.freebsd.org (Postfix) with ESMTP id 0C5FA13C48A;
	Sat, 12 May 2007 22:25:09 +0000 (UTC)
	(envelope-from sean-freebsd@farley.org)
Received: from thor.farley.org (thor.farley.org [192.168.1.5])
	by mail.farley.org (8.14.1/8.14.1) with ESMTP id l4CMP3GV005745;
	Sat, 12 May 2007 17:25:03 -0500 (CDT)
	(envelope-from sean-freebsd@farley.org)
Date: Sat, 12 May 2007 17:25:03 -0500 (CDT)
From: "Sean C. Farley" <sean-freebsd@farley.org>
To: Robert Watson <rwatson@FreeBSD.org>
In-Reply-To: <20070512160859.T63806@fledge.watson.org>
Message-ID: <20070512170737.F7595@thor.farley.org>
References: <20070504213312.GA33163@nagual.pp.ru>
	<20070504174657.D1343@thor.farley.org>
	<20070505213202.GA49925@nagual.pp.ru>
	<20070505163707.J6670@thor.farley.org>
	<20070505221125.GA50439@nagual.pp.ru>
	<20070506091835.A43775@besplex.bde.org>
	<20070508162458.G6015@baba.farley.org>
	<20070508222521.GA59534@nagual.pp.ru>
	<20070509200000.B56490@besplex.bde.org>
	<20070510184447.H4969@baba.farley.org>
	<20070511003443.GA6422@nagual.pp.ru>
	<20070511182126.U9004@baba.farley.org>
	<20070512160859.T63806@fledge.watson.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
Cc: Daniel Eischen <deischen@FreeBSD.org>, arch@FreeBSD.org,
	Andrey Chernov <ache@FreeBSD.org>
Subject: Re: HEADS DOWN
X-BeenThere: freebsd-arch@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Discussion related to FreeBSD architecture <freebsd-arch.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-arch>,
	<mailto:freebsd-arch-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-arch>
List-Post: <mailto:freebsd-arch@freebsd.org>
List-Help: <mailto:freebsd-arch-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-arch>,
	<mailto:freebsd-arch-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 12 May 2007 22:25:10 -0000

On Sat, 12 May 2007, Robert Watson wrote:

> On Fri, 11 May 2007, Sean C. Farley wrote:
>
>> On Fri, 11 May 2007, Andrey Chernov wrote:

<snip>

>>> I suggest to change errx() to warnx()+return(failure).
>> 
>> No need to worry any longer; I changed them into warnx().  What value
>> should I give errno?  I do not want the program to receive a random
>> error code. The first warnx() could be EINVAL.  The second warnx()
>> would be a coding error on my part.  EDOOFUS would fit.  :)  I know I
>> should not use it. EINVAL?
>
> Actually, I'm not convinced that crashing the program isn't the right
> answer.  If an application corrupts memory managed by libc or other
> libraries, crashing is generally considered an entirely acceptable
> failure mode.

There are two scenarios when rebuilding the environment for the first
time that I am using warnx/errx:
1. The user supplied an environ where a variable is missing an "=value"
    portion.
2. The code I wrote did not work as expected.

Is your thought that since the API has no means (specification-wise) to
inform the user that something is wrong that an exit should/may be
performed?  To stick with the specification, I see why errx() would be
desired.  In addition, malloc() can handle a double-free and still run
correctly.  For environ, if it is incorrect, the code will never allow
*env() to succeed.

Sean
-- 
sean-freebsd@farley.org