Skip to content

Commit

Permalink
compat/fnmatch/fnmatch.c: Fix a sparse error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ramsay Jones authored and Junio C Hamano committed Apr 28, 2013
1 parent 5b62e63 commit 4fc8fb4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compat/fnmatch/fnmatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# define _GNU_SOURCE 1
#endif

#include <stddef.h>
#include <errno.h>
#include <fnmatch.h>
#include <ctype.h>
Expand Down Expand Up @@ -121,7 +122,7 @@
whose names are inconsistent. */

# if !defined _LIBC && !defined getenv
extern char *getenv ();
extern char *getenv (const char *name);
# endif

# ifndef errno
Expand Down

0 comments on commit 4fc8fb4

Please sign in to comment.