threads / patch / 33644

patch, 6 partscompat/unsetenv.c: Fix a sparse warning

Subject: [PATCH 1/6] compat/unsetenv.c: Fix a sparse warning

## tl;dr

One message between Apr 27, 2013 and Apr 27, 2013. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Ramsay Jones· Apr 27, 2013, 19:15 UTC · lore

The gitunsetenv function includes an (redundant) declaration of the 'environ' symbol, which is a pointer to the table of environment variables. Unfortunately, on MinGW, this provokes sparse to issue the following warning:

    compat/unsetenv.c:5:20: warning: non-ANSI function declaration of \
    function '__p__environ'

On MinGW, the <stdlib.h> header defines the 'environ' symbol as a preprocessor macro (via _environ) which obtains the environ table pointer via a call to the __p__environ() function.

In order to suppress the warning, we simply remove the redundant declaration of the 'environ' symbol, since the symbol is already declared correctly in <stdlib.h> (included via git-compat-util.h).

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
 compat/unsetenv.c | 1 -
 1 file changed, 1 deletion(-)
Show changes to compat/unsetenv.c +0 −1
diff --git a/compat/unsetenv.c b/compat/unsetenv.c
index eb29f5e..4ea1856 100644
--- a/compat/unsetenv.c
+++ b/compat/unsetenv.c
@@ -2,7 +2,6 @@
 
 void gitunsetenv (const char *name)
 {
-     extern char **environ;
      int src, dst;
      size_t nmln;
 
-- 
1.8.2

← back to recent threads