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

Re: [Bug] wrapper.c uses unportable unsetenv

From
JSJohannes Schindelin <johannes.schindelin@gmail.com>
Date
Oct 29, 2021, 21:50 UTC
Message-ID
<nycvar.QRO.7.76.6.2110292348530.56@tvgsbejvaqbjf.bet>
In-Reply-To
<xmqqwnlvik3v.fsf@gitster.g>
Hi Junio,
On Fri, 29 Oct 2021, Junio C Hamano wrote:
Show 9 quoted lines
> ----- >8 --------- >8 --------- >8 --------- >8 --------- >8 -----
> Subject: unsetenv(3) returns int, not void
> 
> This compatilibity implementation has been returning a wrong type,
> ever since 731043fd (Add compat/unsetenv.c ., 2006-01-25) added to
> the system, yet nobody noticed it in the past 16 years, presumably
> because no code checks failures in their unsetenv() calls.  Sigh.
> 
> For now, make it always succeed.
Makes sense, but...
Show 18 quoted lines
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  compat/unsetenv.c | 2 +-
>  git-compat-util.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git c/compat/unsetenv.c w/compat/unsetenv.c
> index bf5fd7063b..46d49c2c5e 100644
> --- c/compat/unsetenv.c
> +++ w/compat/unsetenv.c
> @@ -1,6 +1,6 @@
>  #include "../git-compat-util.h"
>  
> -void gitunsetenv (const char *name)
> +int gitunsetenv(const char *name)
>  {
>  #if !defined(__MINGW32__)
>       extern char **environ;
... but we are missing this:
@@ -24,4 +24,5 @@ void gitunsetenv (const char *name)
 	  ++dst;
      }
      environ[dst] = NULL;
+     return 0;
 }

Thanks,
Dscho

> diff --git c/git-compat-util.h w/git-compat-util.h
> index b46605300a..0f7e369a5d 100644
> --- c/git-compat-util.h
> +++ w/git-compat-util.h
> @@ -726,7 +726,7 @@ char *gitmkdtemp(char *);
>  
>  #ifdef NO_UNSETENV
>  #define unsetenv gitunsetenv
> -void gitunsetenv(const char *);
> +int gitunsetenv(const char *);
>  #endif
>  
>  #ifdef NO_STRCASESTR
> 
> 
> 
> 
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 7 in “[Bug] wrapper.c uses unportable unsetenv”
  1. rsbecker@nexbridge.comOct 29, 2021
  2. Junio C HamanoOct 29, 2021
  3. rsbecker@nexbridge.comOct 29, 2021
  4. rsbecker@nexbridge.comOct 29, 2021
  5. Junio C HamanoOct 29, 2021
  6. Johannes SchindelinOct 29, 2021
  7. Junio C HamanoOct 29, 2021

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.