Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 May 2007 20:50:25 -0400 (EDT)
From:      Daniel Eischen <deischen@freebsd.org>
To:        "Sean C. Farley" <sean-freebsd@farley.org>
Cc:        arch@freebsd.org
Subject:   Re: HEADS DOWN
Message-ID:  <Pine.GSO.4.64.0705022034180.8590@sea.ntplx.net>
In-Reply-To: <20070502183100.P1317@baba.farley.org>
References:  <20070501083009.GA4627@nagual.pp.ru> <20070501160645.GA9333@nagual.pp.ru> <20070501135439.B36275@thor.farley.org> <20070502.102822.-957833022.imp@bsdimp.com> <Pine.GSO.4.64.0705021332020.8590@sea.ntplx.net> <20070502183100.P1317@baba.farley.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 2 May 2007, Sean C. Farley wrote:

>
> Here[1] is my POSIX version of the *env() (including putenv())
> functions.  It also has the leak-avoidance change that occurs with
> setenv("ab") -> setenv("a") -> setenv("ab").  It is also faster than the
> current code.
>
> Where it diverges from POSIX:
> 1. putenv() sets errno to EINVAL since it performs checks (NULL pointer,
>   empty string and string without '=') on the string given to it.  It
>   makes it a bit more like setenv() in its validation.  I found this
>   note[2] that says that providing invalid data to putenv() will result
>   in undefined behavior.  I thought that undefined could mean an error
>   is returned.  The check is easy to remove.

I think that is fine as it falls under "undefined behavior",
and the function is already defined as returning an error code.

> 2. getenv() sets errno to EINVAL and returns NULL if given a bad name to
>   find.  setenv() and unsetenv() perform the same check on the name;
>   should not getenv() do the same?  The check is easy to remove.

I don't think getenv() should set errno.  The fact that it
returns NULL is sufficient and POSIX doesn't define any errors
for it.

-- 
DE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.0705022034180.8590>