Date: Sat, 5 May 2007 01:33:12 +0400 From: Andrey Chernov <ache@freebsd.org> To: "Sean C. Farley" <sean-freebsd@farley.org> Cc: Daniel Eischen <deischen@freebsd.org>, arch@freebsd.org Subject: Re: HEADS DOWN Message-ID: <20070504213312.GA33163@nagual.pp.ru> In-Reply-To: <20070504085905.J39482@thor.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> <Pine.GSO.4.64.0705022034180.8590@sea.ntplx.net> <20070502230413.Y30614@thor.farley.org> <20070503160351.GA15008@nagual.pp.ru> <20070504085905.J39482@thor.farley.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, May 04, 2007 at 01:21:50PM -0500, Sean C. Farley wrote: > I believe I check all that you did in your changes. Mine looks a little > different since some checks were combined for speed (i.e., > __strleneq()). Looking at http://www.farley.org/freebsd/tmp/setenv-8/POSIX/sysenv.c __strleneq() - "Inline strlen() for performance." - no performance gain such way but lost, because strlen() already auto-inlined with gcc -O2 in much better assembler form: repnz scasb So there is no point to call __strleneq(..., false); too instead of just strlen() (which will be auto-inlined by gcc) directly. Currently __clean_env is unused. Why don't #if 0 it? I think "Check for malformed name" should be before "Initialize environment" - with malformed arg complex environment mallocing/copying initialization ever not needed. In __build_env() when strdup() returns NULL, you better free all previous strdups in that loop and envVars too before returning (-1) Why you use strstr(envVars[envNdx].name, "="); instead of strchr(envVars[envNdx].name, '='); ? In theory strchr() can be gcc-inlined or assembler-implemented with more probability than strstr() (currently both are not inlined at i386). __rebuild_environ() needs to use realloc() instead of reallocf() because realloc() not touch original pointer/content when fails. I.e. _whole_ "environ" will not be lost in case can't be enlarged. Something like that: TempEnvironSize = newEnvSize * 2; TempEnviron = realloc(environ, sizeof (*environ) * (TempEnvironSize + 1)); if (TempEnviron == NULL) return (-1); environ = TempEnviron; environSize = TempEnvironSize; > The only other question I have is about leading whitespace in the name > passed to *env(): > 1. Should it be removed up to the first non-whitespace character? > 2. Treated as part of the variable name. Is this allowed by the > specification? > 3. Return errno = EINVAL. getenv() would just return NULL. POSIX says about names: 1) "names shall not contain the character '='" and "points to an empty string". 2) "Other characters may be permitted by an implementation; applications shall tolerate the presence of such names." So I see no point to treat ' ' some special way. -- http://ache.pp.ru/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070504213312.GA33163>