git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC 1/2] wrapper: supply xsetenv

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Dec 13, 2011, 18:52 UTC
Message-ID
<CABPQNSZ_r4u-yXtEGw8duZyoN3SdF5p+7vabz2qqS161kgkHWQ@mail.gmail.com>
In-Reply-To
<7vwra0uxqo.fsf@alter.siamese.dyndns.org>
On Tue, Dec 13, 2011 at 7:34 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Jeff King <peff@peff.net> writes:
>
>> On Tue, Dec 13, 2011 at 01:10:26PM +0100, Erik Faye-Lund wrote:
>>
>>> +int xsetenv(const char *name, const char *val, int overwrite)
>>> +{
>>> +    if (setenv(name, val, overwrite))
>>> +            die_errno("setenv failed");
>>> +}
>>
>> It probably doesn't matter, because the error condition is almost
>> certainly just "oops, we ran out of memory". But you could also print
>> the name of the variable being set, which may give the user a clue to
>> some misconfiguration (e.g., trying to put some extremely long value
>> into the environment).
>
> Do we have enough memory to format that message in that situation ;-)?

We could. Running out of environment space is not the same as running out of memory. For instance, Windows has a maximum environment size of 32 kB. Older Linux kernels maxed out at 128 kB.

So I think it's a good idea to at least try. The worst that can happen is another, less descriptive error, no?

Previous: Junio C HamanoNext: Andreas Schwab
Message 8 of 9 in “wrapper: supply xsetenv”
  1. 1/2 wrapper: supply xsetenvErik Faye-Lund, Dec 13, 2011
  2. 2/2 change all unchecked calls to setenv to xsetenvErik Faye-Lund, Dec 13, 2011
  3. Jeff KingDec 13, 2011
  4. Junio C HamanoDec 13, 2011
  5. Erik Faye-LundDec 13, 2011
  6. Jeff KingDec 13, 2011
  7. Junio C HamanoDec 13, 2011
  8. Erik Faye-LundDec 13, 2011
  9. Andreas SchwabDec 13, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.