* 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
Родитель 2f1ef15070 84d32bf767
Коммит 7e2d574c37
20 изменённых файлов: 43 добавлений и 30 удалений

Просмотреть файл

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

Просмотреть файл

@ -25,6 +25,7 @@
# define _GNU_SOURCE 1
#endif
#include <stddef.h>
#include <errno.h>
#include <fnmatch.h>
#include <ctype.h>
@ -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

Просмотреть файл

@ -841,8 +841,8 @@ struct pinfo_t {
struct pinfo_t *next;
pid_t pid;
HANDLE proc;
} pinfo_t;
struct pinfo_t *pinfo = NULL;
};
static struct pinfo_t *pinfo = NULL;
CRITICAL_SECTION pinfo_cs;
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
sin->sin_addr.s_addr = INADDR_LOOPBACK;
ai->ai_addr = (struct sockaddr *)sin;
ai->ai_next = 0;
ai->ai_next = NULL;
return 0;
}

Просмотреть файл

@ -333,14 +333,21 @@ void mingw_open_html(const char *path);
char **make_augmented_environ(const char *const *vars);
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
* and that default fmode and std(in|out|err) are in binary mode
*/
#define main(c,v) dummy_decl_mingw_main(); \
static int mingw_main(); \
int main(int argc, const char **argv) \
static int mingw_main(c,v); \
int main(int argc, char **argv) \
{ \
extern CRITICAL_SECTION pinfo_cs; \
_fmode = _O_BINARY; \

Просмотреть файл

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

Просмотреть файл

@ -159,8 +159,8 @@ struct mallinfo nedmallinfo(void) THROWSPEC { return nedpmallinfo(0); }
#endif
int nedmallopt(int parno, int value) THROWSPEC { return nedpmallopt(0, parno, value); }
int nedmalloc_trim(size_t pad) THROWSPEC { return nedpmalloc_trim(0, pad); }
void nedmalloc_stats() THROWSPEC { nedpmalloc_stats(0); }
size_t nedmalloc_footprint() THROWSPEC { return nedpmalloc_footprint(0); }
void nedmalloc_stats(void) THROWSPEC { nedpmalloc_stats(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_comalloc(size_t elems, size_t *sizes, void **chunks) THROWSPEC { return nedpindependent_comalloc(0, elems, sizes, chunks); }

Просмотреть файл

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

Просмотреть файл

@ -2313,7 +2313,7 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
}
/* Update the state_log if we need */
re_dfastate_t *
static re_dfastate_t *
internal_function
merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
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_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;
}
@ -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
multi-byte match, then look in the log for a state
from which to restart matching. */
re_dfastate_t *
static re_dfastate_t *
internal_function
find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
{

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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))
die("Invalid usage of mmap when built with USE_WIN32_MMAP");
hmap = CreateFileMapping((HANDLE)_get_osfhandle(fd), 0, PAGE_WRITECOPY,
0, 0, 0);
hmap = CreateFileMapping((HANDLE)_get_osfhandle(fd), NULL,
PAGE_WRITECOPY, 0, 0, NULL);
if (!hmap)
return MAP_FAILED;

Просмотреть файл

@ -114,7 +114,7 @@ static int lookup_credential(const char *fn, struct credential *c)
return c->username && c->password;
}
int main(int argc, const char **argv)
int main(int argc, char **argv)
{
const char * const usage[] = {
"git credential-store [options] <action>",
@ -131,7 +131,7 @@ int main(int argc, const char **argv)
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)
usage_with_options(usage, options);
op = argv[0];

Просмотреть файл

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

3
git.c
Просмотреть файл

@ -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;
startup_info = &git_startup_info;

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -22,7 +22,7 @@ static int compare_strings(const void *a, const void *b)
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 strbuf sb = STRBUF_INIT;

Просмотреть файл

@ -29,7 +29,7 @@ static int number_callback(const struct option *opt, const char *arg, int unset)
return 0;
}
int main(int argc, const char **argv)
int main(int argc, char **argv)
{
const char *prefix = "prefix/";
const char *usage[] = {
@ -81,7 +81,7 @@ int main(int argc, const char **argv)
};
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("integer: %u\n", integer);

Просмотреть файл

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