Skip to content

Commit 4fc8fb4

Browse files
Ramsay Jonesgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5b62e63 commit 4fc8fb4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compat/fnmatch/fnmatch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# define _GNU_SOURCE 1
2626
#endif
2727

28+
#include <stddef.h>
2829
#include <errno.h>
2930
#include <fnmatch.h>
3031
#include <ctype.h>
@@ -121,7 +122,7 @@
121122
whose names are inconsistent. */
122123

123124
# if !defined _LIBC && !defined getenv
124-
extern char *getenv ();
125+
extern char *getenv (const char *name);
125126
# endif
126127

127128
# ifndef errno

0 commit comments

Comments
 (0)