HEADS DOWN
Daniel Eischen
deischen at freebsd.org
Thu May 3 00:50:41 UTC 2007
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
More information about the freebsd-arch
mailing list