Thread (2 messages) flat view 2 messages, 2 authors, 2021-10-29

Re: [Bug] wrapper.c uses unportable unsetenv

From: Junio C Hamano <hidden>
Date: 2021-10-29 21:42:19

[off-list ref] 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 <redacted>
---
 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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help