Skip to content

Commit 7e2d574

Browse files
committed
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
2 parents 2f1ef15 + 84d32bf commit 7e2d574

20 files changed

+43
-30
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,6 +2003,7 @@ endif
20032003
ifdef USE_NED_ALLOCATOR
20042004
compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
20052005
-DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR
2006+
compat/nedmalloc/nedmalloc.sp: SPARSE_FLAGS += -Wno-non-pointer-null
20062007
endif
20072008

20082009
git-%$X: %.o GIT-LDFLAGS $(GITLIBS)

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

compat/mingw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,8 @@ struct pinfo_t {
841841
struct pinfo_t *next;
842842
pid_t pid;
843843
HANDLE proc;
844-
} pinfo_t;
845-
struct pinfo_t *pinfo = NULL;
844+
};
845+
static struct pinfo_t *pinfo = NULL;
846846
CRITICAL_SECTION pinfo_cs;
847847

848848
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,
12531253
else
12541254
sin->sin_addr.s_addr = INADDR_LOOPBACK;
12551255
ai->ai_addr = (struct sockaddr *)sin;
1256-
ai->ai_next = 0;
1256+
ai->ai_next = NULL;
12571257
return 0;
12581258
}
12591259

compat/mingw.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,21 @@ void mingw_open_html(const char *path);
333333
char **make_augmented_environ(const char *const *vars);
334334
void free_environ(char **env);
335335

336+
/*
337+
* A critical section used in the implementation of the spawn
338+
* functions (mingw_spawnv[p]e()) and waitpid(). Intialised in
339+
* the replacement main() macro below.
340+
*/
341+
extern CRITICAL_SECTION pinfo_cs;
342+
336343
/*
337344
* A replacement of main() that ensures that argv[0] has a path
338345
* and that default fmode and std(in|out|err) are in binary mode
339346
*/
340347

341348
#define main(c,v) dummy_decl_mingw_main(); \
342-
static int mingw_main(); \
343-
int main(int argc, const char **argv) \
349+
static int mingw_main(c,v); \
350+
int main(int argc, char **argv) \
344351
{ \
345352
extern CRITICAL_SECTION pinfo_cs; \
346353
_fmode = _O_BINARY; \

compat/nedmalloc/malloc.c.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP
484484
#define DLMALLOC_VERSION 20804
485485
#endif /* DLMALLOC_VERSION */
486486

487+
#if defined(linux)
488+
#define _GNU_SOURCE 1
489+
#endif
490+
487491
#ifndef WIN32
488492
#ifdef _WIN32
489493
#define WIN32 1
@@ -1802,7 +1806,7 @@ struct win32_mlock_t
18021806

18031807
static MLOCK_T malloc_global_mutex = { 0, 0, 0};
18041808

1805-
static FORCEINLINE long win32_getcurrentthreadid() {
1809+
static FORCEINLINE long win32_getcurrentthreadid(void) {
18061810
#ifdef _MSC_VER
18071811
#if defined(_M_IX86)
18081812
long *threadstruct=(long *)__readfsdword(0x18);

compat/nedmalloc/nedmalloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ struct mallinfo nedmallinfo(void) THROWSPEC { return nedpmallinfo(0); }
159159
#endif
160160
int nedmallopt(int parno, int value) THROWSPEC { return nedpmallopt(0, parno, value); }
161161
int nedmalloc_trim(size_t pad) THROWSPEC { return nedpmalloc_trim(0, pad); }
162-
void nedmalloc_stats() THROWSPEC { nedpmalloc_stats(0); }
163-
size_t nedmalloc_footprint() THROWSPEC { return nedpmalloc_footprint(0); }
162+
void nedmalloc_stats(void) THROWSPEC { nedpmalloc_stats(0); }
163+
size_t nedmalloc_footprint(void) THROWSPEC { return nedpmalloc_footprint(0); }
164164
void **nedindependent_calloc(size_t elemsno, size_t elemsize, void **chunks) THROWSPEC { return nedpindependent_calloc(0, elemsno, elemsize, chunks); }
165165
void **nedindependent_comalloc(size_t elems, size_t *sizes, void **chunks) THROWSPEC { return nedpindependent_comalloc(0, elems, sizes, chunks); }
166166

compat/poll/poll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
576576
{
577577
/* It's a socket. */
578578
WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev);
579-
WSAEventSelect ((SOCKET) h, 0, 0);
579+
WSAEventSelect ((SOCKET) h, NULL, 0);
580580

581581
/* If we're lucky, WSAEnumNetworkEvents already provided a way
582582
to distinguish FD_READ and FD_ACCEPT; this saves a recv later. */

compat/regex/regexec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,7 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
23132313
}
23142314

23152315
/* Update the state_log if we need */
2316-
re_dfastate_t *
2316+
static re_dfastate_t *
23172317
internal_function
23182318
merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
23192319
re_dfastate_t *next_state)
@@ -2326,7 +2326,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
23262326
mctx->state_log[cur_idx] = next_state;
23272327
mctx->state_log_top = cur_idx;
23282328
}
2329-
else if (mctx->state_log[cur_idx] == 0)
2329+
else if (mctx->state_log[cur_idx] == NULL)
23302330
{
23312331
mctx->state_log[cur_idx] = next_state;
23322332
}
@@ -2392,7 +2392,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
23922392
/* Skip bytes in the input that correspond to part of a
23932393
multi-byte match, then look in the log for a state
23942394
from which to restart matching. */
2395-
re_dfastate_t *
2395+
static re_dfastate_t *
23962396
internal_function
23972397
find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
23982398
{

compat/unsetenv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
void gitunsetenv (const char *name)
44
{
5-
extern char **environ;
65
int src, dst;
76
size_t nmln;
87

compat/win32/pthread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)
5252

5353
pthread_t pthread_self(void)
5454
{
55-
pthread_t t = { 0 };
55+
pthread_t t = { NULL };
5656
t.tid = GetCurrentThreadId();
5757
return t;
5858
}

0 commit comments

Comments
 (0)