From owner-svn-src-head@FreeBSD.ORG Tue Dec 1 15:24:45 2009 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A9AD1065676; Tue, 1 Dec 2009 15:24:45 +0000 (UTC) (envelope-from green@green.homeunix.org) Received: from green.homeunix.org (green.homeunix.org [66.92.150.152]) by mx1.freebsd.org (Postfix) with ESMTP id BD7198FC0C; Tue, 1 Dec 2009 15:24:44 +0000 (UTC) Received: from green.homeunix.org (green@localhost [127.0.0.1]) by green.homeunix.org (8.14.3/8.14.1) with ESMTP id nB1FOhMM043689; Tue, 1 Dec 2009 10:24:43 -0500 (EST) (envelope-from green@green.homeunix.org) Received: (from green@localhost) by green.homeunix.org (8.14.3/8.14.3/Submit) id nB1FOh87043688; Tue, 1 Dec 2009 10:24:43 -0500 (EST) (envelope-from green) Date: Tue, 1 Dec 2009 10:24:43 -0500 From: Brian Fundakowski Feldman To: Andrey Chernov , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Message-ID: <20091201152442.GB35660@green.homeunix.org> References: <200912010504.nB154VnS053167@svn.freebsd.org> <20091201100602.GA77706@nagual.pp.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20091201100602.GA77706@nagual.pp.ru> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: Subject: Re: svn commit: r199983 - in head: lib/libc/stdlib tools/regression/environ X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Dec 2009 15:24:45 -0000 On Tue, Dec 01, 2009 at 01:06:03PM +0300, Andrey Chernov wrote: > On Tue, Dec 01, 2009 at 05:04:31AM +0000, Brian Feldman wrote: > > - if (environ == NULL || environ[0] == NULL) > > - return (NULL); > > - else if (envVars == NULL || environ != intEnviron) > > + if (envVars == NULL) > > return (__findenv_environ(name, nameLen)); > > - else { > > - envNdx = envVarsTotal - 1; > > - return (__findenv(name, nameLen, &envNdx, true)); > > - } > > + > > + /* Synchronize environment. */ > > + if (__merge_environ() == -1) > > + return (NULL); > > + > > + envNdx = envVarsTotal - 1; > > + return (__findenv(name, nameLen, &envNdx, true)); > > } > > __merge_environ() should be avoided here for speed reasons. If the corrupt environment warnings are not actually that useful, then I agree that there's no other reason not to defer __merge_environ(). I actually wanted to have getenv(3) produce the warnings even if one of the other (modification) functions was never called, but that seemed impossible to do correctly without also having it call __build_environ(). The warnings I don't care much about, but having getenv(3) treat the environment as sane when setenv(3)/unsetenv(3)/putenv(3) operations are indefinitely failing is wrong. -- Brian Fundakowski Feldman \'[ FreeBSD ]''''''''''\ <> green@FreeBSD.org \ The Power to Serve! \ Opinions expressed are my own. \,,,,,,,,,,,,,,,,,,,,,,\