git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: <rsbecker@nexbridge.com>
Cc: <git@vger.kernel.org>
Subject: Re: [Bug] wrapper.c uses unportable unsetenv
Date: Fri, 29 Oct 2021 14:42:12 -0700	[thread overview]
Message-ID: <xmqqwnlvik3v.fsf@gitster.g> (raw)
In-Reply-To: <013a01d7cd09$72d91cb0$588b5610$@nexbridge.com> (rsbecker@nexbridge.com's message of "Fri, 29 Oct 2021 17:10:44 -0400")

<rsbecker@nexbridge.com> writes:

> The actual issue is this:
>
>         if (!unsetenv(name))
>             ^
> "/home/ituglib/randall/git/wrapper.c", line 156: error(134):  expression
> must have arithmetic or pointer type
>
> This is with NO_UNSETENV = YesPlease. It makes no sense to me why this isn't
> compiling.

Ah, compat/unsetenv.c is broken.  gitunsetenv() should return int,
not void.

----- >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.

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;
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



  reply	other threads:[~2021-10-29 21:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29 20:14 [Bug] wrapper.c uses unportable unsetenv rsbecker
2021-10-29 20:35 ` Junio C Hamano
2021-10-29 20:49   ` rsbecker
2021-10-29 21:10     ` rsbecker
2021-10-29 21:42       ` Junio C Hamano [this message]
2021-10-29 21:50         ` Johannes Schindelin
2021-10-29 21:57           ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqwnlvik3v.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=rsbecker@nexbridge.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).