Merge branch 'rj/sparse'

* rj/sparse:
  sparse: Fix mingw_main() argument number/type errors
  compat/mingw.c: Fix some sparse warnings
  compat/win32mmap.c: Fix some sparse warnings
  compat/poll/poll.c: Fix a sparse warning
  compat/win32/pthread.c: Fix a sparse warning
  compat/unsetenv.c: Fix a sparse warning
  compat/nedmalloc: Fix compiler warnings on linux
  compat/nedmalloc: Fix some sparse warnings
  compat/fnmatch/fnmatch.c: Fix a sparse error
  compat/regex/regexec.c: Fix some sparse warnings
This commit is contained in:
Junio C Hamano 2013-05-29 14:24:02 -07:00
commit 7e2d574c37
20 changed files with 43 additions and 30 deletions

View File

@ -2003,6 +2003,7 @@ endif
ifdef USE_NED_ALLOCATOR ifdef USE_NED_ALLOCATOR
compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \ compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
-DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR -DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR
compat/nedmalloc/nedmalloc.sp: SPARSE_FLAGS += -Wno-non-pointer-null
endif endif
git-%$X: %.o GIT-LDFLAGS $(GITLIBS) git-%$X: %.o GIT-LDFLAGS $(GITLIBS)

View File

@ -25,6 +25,7 @@
# define _GNU_SOURCE 1 # define _GNU_SOURCE 1
#endif #endif
#include <stddef.h>
#include <errno.h> #include <errno.h>
#include <fnmatch.h> #include <fnmatch.h>
#include <ctype.h> #include <ctype.h>
@ -121,7 +122,7 @@
whose names are inconsistent. */ whose names are inconsistent. */
# if !defined _LIBC && !defined getenv # if !defined _LIBC && !defined getenv
extern char *getenv (); extern char *getenv (const char *name);
# endif # endif
# ifndef errno # ifndef errno

View File

@ -841,8 +841,8 @@ struct pinfo_t {
struct pinfo_t *next; struct pinfo_t *next;
pid_t pid; pid_t pid;
HANDLE proc; HANDLE proc;
} pinfo_t; };
struct pinfo_t *pinfo = NULL; static struct pinfo_t *pinfo = NULL;
CRITICAL_SECTION pinfo_cs; CRITICAL_SECTION pinfo_cs;
static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env, static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
@ -1253,7 +1253,7 @@ static int WSAAPI getaddrinfo_stub(const char *node, const char *service,
else else
sin->sin_addr.s_addr = INADDR_LOOPBACK; sin->sin_addr.s_addr = INADDR_LOOPBACK;
ai->ai_addr = (struct sockaddr *)sin; ai->ai_addr = (struct sockaddr *)sin;
ai->ai_next = 0; ai->ai_next = NULL;
return 0; return 0;
} }

View File

@ -333,14 +333,21 @@ void mingw_open_html(const char *path);
char **make_augmented_environ(const char *const *vars); char **make_augmented_environ(const char *const *vars);
void free_environ(char **env); void free_environ(char **env);
/*
* A critical section used in the implementation of the spawn
* functions (mingw_spawnv[p]e()) and waitpid(). Intialised in
* the replacement main() macro below.
*/
extern CRITICAL_SECTION pinfo_cs;
/* /*
* A replacement of main() that ensures that argv[0] has a path * A replacement of main() that ensures that argv[0] has a path
* and that default fmode and std(in|out|err) are in binary mode * and that default fmode and std(in|out|err) are in binary mode
*/ */
#define main(c,v) dummy_decl_mingw_main(); \ #define main(c,v) dummy_decl_mingw_main(); \
static int mingw_main(); \ static int mingw_main(c,v); \
int main(int argc, const char **argv) \ int main(int argc, char **argv) \
{ \ { \
extern CRITICAL_SECTION pinfo_cs; \ extern CRITICAL_SECTION pinfo_cs; \
_fmode = _O_BINARY; \ _fmode = _O_BINARY; \

View File

@ -484,6 +484,10 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP
#define DLMALLOC_VERSION 20804 #define DLMALLOC_VERSION 20804
#endif /* DLMALLOC_VERSION */ #endif /* DLMALLOC_VERSION */
#if defined(linux)
#define _GNU_SOURCE 1
#endif
#ifndef WIN32 #ifndef WIN32
#ifdef _WIN32 #ifdef _WIN32
#define WIN32 1 #define WIN32 1
@ -1802,7 +1806,7 @@ struct win32_mlock_t
static MLOCK_T malloc_global_mutex = { 0, 0, 0}; static MLOCK_T malloc_global_mutex = { 0, 0, 0};
static FORCEINLINE long win32_getcurrentthreadid() { static FORCEINLINE long win32_getcurrentthreadid(void) {
#ifdef _MSC_VER #ifdef _MSC_VER
#if defined(_M_IX86) #if defined(_M_IX86)
long *threadstruct=(long *)__readfsdword(0x18); long *threadstruct=(long *)__readfsdword(0x18);

View File

@ -159,8 +159,8 @@ struct mallinfo nedmallinfo(void) THROWSPEC { return nedpmallinfo(0); }
#endif #endif
int nedmallopt(int parno, int value) THROWSPEC { return nedpmallopt(0, parno, value); } int nedmallopt(int parno, int value) THROWSPEC { return nedpmallopt(0, parno, value); }
int nedmalloc_trim(size_t pad) THROWSPEC { return nedpmalloc_trim(0, pad); } int nedmalloc_trim(size_t pad) THROWSPEC { return nedpmalloc_trim(0, pad); }
void nedmalloc_stats() THROWSPEC { nedpmalloc_stats(0); } void nedmalloc_stats(void) THROWSPEC { nedpmalloc_stats(0); }
size_t nedmalloc_footprint() THROWSPEC { return nedpmalloc_footprint(0); } size_t nedmalloc_footprint(void) THROWSPEC { return nedpmalloc_footprint(0); }
void **nedindependent_calloc(size_t elemsno, size_t elemsize, void **chunks) THROWSPEC { return nedpindependent_calloc(0, elemsno, elemsize, chunks); } void **nedindependent_calloc(size_t elemsno, size_t elemsize, void **chunks) THROWSPEC { return nedpindependent_calloc(0, elemsno, elemsize, chunks); }
void **nedindependent_comalloc(size_t elems, size_t *sizes, void **chunks) THROWSPEC { return nedpindependent_comalloc(0, elems, sizes, chunks); } void **nedindependent_comalloc(size_t elems, size_t *sizes, void **chunks) THROWSPEC { return nedpindependent_comalloc(0, elems, sizes, chunks); }

View File

@ -576,7 +576,7 @@ restart:
{ {
/* It's a socket. */ /* It's a socket. */
WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev); WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev);
WSAEventSelect ((SOCKET) h, 0, 0); WSAEventSelect ((SOCKET) h, NULL, 0);
/* If we're lucky, WSAEnumNetworkEvents already provided a way /* If we're lucky, WSAEnumNetworkEvents already provided a way
to distinguish FD_READ and FD_ACCEPT; this saves a recv later. */ to distinguish FD_READ and FD_ACCEPT; this saves a recv later. */

View File

@ -2313,7 +2313,7 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
} }
/* Update the state_log if we need */ /* Update the state_log if we need */
re_dfastate_t * static re_dfastate_t *
internal_function internal_function
merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx, merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
re_dfastate_t *next_state) re_dfastate_t *next_state)
@ -2326,7 +2326,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
mctx->state_log[cur_idx] = next_state; mctx->state_log[cur_idx] = next_state;
mctx->state_log_top = cur_idx; mctx->state_log_top = cur_idx;
} }
else if (mctx->state_log[cur_idx] == 0) else if (mctx->state_log[cur_idx] == NULL)
{ {
mctx->state_log[cur_idx] = next_state; mctx->state_log[cur_idx] = next_state;
} }
@ -2392,7 +2392,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
/* Skip bytes in the input that correspond to part of a /* Skip bytes in the input that correspond to part of a
multi-byte match, then look in the log for a state multi-byte match, then look in the log for a state
from which to restart matching. */ from which to restart matching. */
re_dfastate_t * static re_dfastate_t *
internal_function internal_function
find_recover_state (reg_errcode_t *err, re_match_context_t *mctx) find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
{ {

View File

@ -2,7 +2,6 @@
void gitunsetenv (const char *name) void gitunsetenv (const char *name)
{ {
extern char **environ;
int src, dst; int src, dst;
size_t nmln; size_t nmln;

View File

@ -52,7 +52,7 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)
pthread_t pthread_self(void) pthread_t pthread_self(void)
{ {
pthread_t t = { 0 }; pthread_t t = { NULL };
t.tid = GetCurrentThreadId(); t.tid = GetCurrentThreadId();
return t; return t;
} }

View File

@ -21,8 +21,8 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
if (!(flags & MAP_PRIVATE)) if (!(flags & MAP_PRIVATE))
die("Invalid usage of mmap when built with USE_WIN32_MMAP"); die("Invalid usage of mmap when built with USE_WIN32_MMAP");
hmap = CreateFileMapping((HANDLE)_get_osfhandle(fd), 0, PAGE_WRITECOPY, hmap = CreateFileMapping((HANDLE)_get_osfhandle(fd), NULL,
0, 0, 0); PAGE_WRITECOPY, 0, 0, NULL);
if (!hmap) if (!hmap)
return MAP_FAILED; return MAP_FAILED;

View File

@ -114,7 +114,7 @@ static int lookup_credential(const char *fn, struct credential *c)
return c->username && c->password; return c->username && c->password;
} }
int main(int argc, const char **argv) int main(int argc, char **argv)
{ {
const char * const usage[] = { const char * const usage[] = {
"git credential-store [options] <action>", "git credential-store [options] <action>",
@ -131,7 +131,7 @@ int main(int argc, const char **argv)
umask(077); umask(077);
argc = parse_options(argc, argv, NULL, options, usage, 0); argc = parse_options(argc, (const char **)argv, NULL, options, usage, 0);
if (argc != 1) if (argc != 1)
usage_with_options(usage, options); usage_with_options(usage, options);
op = argv[0]; op = argv[0];

View File

@ -297,7 +297,7 @@ static int failure;
static FILE *pack_edges; static FILE *pack_edges;
static unsigned int show_stats = 1; static unsigned int show_stats = 1;
static int global_argc; static int global_argc;
static const char **global_argv; static char **global_argv;
/* Memory pools */ /* Memory pools */
static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool); static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);
@ -3347,7 +3347,7 @@ static void parse_argv(void)
read_marks(); read_marks();
} }
int main(int argc, const char **argv) int main(int argc, char **argv)
{ {
unsigned int i; unsigned int i;

3
git.c
View File

@ -507,8 +507,9 @@ static int run_argv(int *argcp, const char ***argv)
} }
int main(int argc, const char **argv) int main(int argc, char **av)
{ {
const char **argv = (const char **) av;
const char *cmd; const char *cmd;
startup_info = &git_startup_info; startup_info = &git_startup_info;

View File

@ -286,7 +286,7 @@ static int do_command(struct strbuf *line)
return 0; return 0;
} }
int main(int argc, const char **argv) int main(int argc, char **argv)
{ {
struct strbuf buf = STRBUF_INIT, url_sb = STRBUF_INIT, struct strbuf buf = STRBUF_INIT, url_sb = STRBUF_INIT,
private_ref_sb = STRBUF_INIT, marksfilename_sb = STRBUF_INIT, private_ref_sb = STRBUF_INIT, marksfilename_sb = STRBUF_INIT,

View File

@ -56,7 +56,7 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq)
return 1; return 1;
} }
int main(int argc, const char *argv[]) int main(int argc, char *argv[])
{ {
static int verbose; static int verbose;

View File

@ -1,6 +1,6 @@
#include "cache.h" #include "cache.h"
int main(int argc, const char **argv) int main(int argc, char **argv)
{ {
struct cache_header hdr; struct cache_header hdr;
int version; int version;

View File

@ -22,7 +22,7 @@ static int compare_strings(const void *a, const void *b)
return strcmp(x->text, y->text); return strcmp(x->text, y->text);
} }
int main(int argc, const char **argv) int main(int argc, char **argv)
{ {
struct line *line, *p = NULL, *lines = NULL; struct line *line, *p = NULL, *lines = NULL;
struct strbuf sb = STRBUF_INIT; struct strbuf sb = STRBUF_INIT;

View File

@ -29,7 +29,7 @@ static int number_callback(const struct option *opt, const char *arg, int unset)
return 0; return 0;
} }
int main(int argc, const char **argv) int main(int argc, char **argv)
{ {
const char *prefix = "prefix/"; const char *prefix = "prefix/";
const char *usage[] = { const char *usage[] = {
@ -81,7 +81,7 @@ int main(int argc, const char **argv)
}; };
int i; int i;
argc = parse_options(argc, argv, prefix, options, usage, 0); argc = parse_options(argc, (const char **)argv, prefix, options, usage, 0);
printf("boolean: %d\n", boolean); printf("boolean: %d\n", boolean);
printf("integer: %u\n", integer); printf("integer: %u\n", integer);

View File

@ -1,7 +1,7 @@
#include "cache.h" #include "cache.h"
#include "run-command.h" #include "run-command.h"
int main(int argc, const char **argv) int main(int argc, char **argv)
{ {
struct child_process cp; struct child_process cp;
int nogit = 0; int nogit = 0;
@ -15,6 +15,6 @@ int main(int argc, const char **argv)
} }
memset(&cp, 0, sizeof(cp)); memset(&cp, 0, sizeof(cp));
cp.git_cmd = 1; cp.git_cmd = 1;
cp.argv = argv + 1; cp.argv = (const char **)argv + 1;
return run_command(&cp); return run_command(&cp);
} }