compat/fnmatch/fnmatch.c: Fix a sparse error

Sparse issues the following error and warnings: SP compat/fnmatch/fnmatch.c .../fnmatch.c:144:17: warning: Using plain integer as NULL pointer .../fnmatch.c:238:67: warning: Using plain integer as NULL pointer .../fnmatch.c:303:40: error: too many arguments for function getenv The error is caused by the extern declaration for the getenv function not including the function prototype. Without the prototype, sparse effectively sees the declaration as 'char *getenv(void)'. In order to suppress the error, we simply include the function prototype. In order to suppress the warnings, we include the <stddef.h> header which provides an appropriate definition of the NULL macro, rather than using the (inappropriate) default definition at fnmatch.c:132. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramsay Jones committed Apr 27, 2013 at 19:44 UTC 4fc8fb48e978b8563493d04069c2507b7fb0064a
1 file changed +2 -1
compat/fnmatch/fnmatch.c
+2 -1
@@ -25,6 +25,7 @@
25 # define _GNU_SOURCE 1
26 #endif
27
28 +#include <stddef.h>
29 #include <errno.h>
30 #include <fnmatch.h>
31 #include <ctype.h>
@@ -121,7 +122,7 @@
122 whose names are inconsistent. */
123
124 # if !defined _LIBC && !defined getenv
124 -extern char *getenv ();
125 +extern char *getenv (const char *name);
126 # endif
127
128 # ifndef errno