diff --git a/Makefile b/Makefile index 9999a09490..411669e8bf 100644 --- a/Makefile +++ b/Makefile @@ -355,7 +355,7 @@ GIT-VERSION-FILE: FORCE # CFLAGS and LDFLAGS are for the users to override from the command line. -CFLAGS = -g -O2 -Wall +CFLAGS = -g -O2 -Wall -Werror LDFLAGS = ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS) diff --git a/compat/mingw.c b/compat/mingw.c index efe840c1e2..ab2957dec3 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -8,6 +8,8 @@ #undef isatty +#define HCAST(type, handle) ((type)(intptr_t)handle) + static const int delay[] = { 0, 1, 10, 20, 40 }; unsigned int _CRT_fmode = _O_BINARY; @@ -728,13 +730,13 @@ int pipe(int filedes[2]) errno = err_win_to_posix(GetLastError()); return -1; } - filedes[0] = _open_osfhandle((int)h[0], O_NOINHERIT); + filedes[0] = _open_osfhandle(HCAST(int, h[0]), O_NOINHERIT); if (filedes[0] < 0) { CloseHandle(h[0]); CloseHandle(h[1]); return -1; } - filedes[1] = _open_osfhandle((int)h[1], O_NOINHERIT); + filedes[1] = _open_osfhandle(HCAST(int, h[1]), O_NOINHERIT); if (filedes[0] < 0) { close(filedes[0]); CloseHandle(h[1]); @@ -1958,7 +1960,8 @@ void mingw_open_html(const char *unixpath) die("cannot run browser"); printf("Launching default browser to display HTML ...\n"); - r = (int)ShellExecute(NULL, "open", htmlpath, NULL, "\\", SW_SHOWNORMAL); + r = HCAST(int, ShellExecute(NULL, "open", htmlpath, + NULL, "\\", SW_SHOWNORMAL)); FreeLibrary(shell32); /* see the MSDN documentation referring to the result codes here */ if (r <= 32) { @@ -2364,8 +2367,8 @@ int mingw_isatty(int fd) { char buffer[64]; for (i = 0; i < ARRAY_SIZE(is_tty); i++) { - sprintf(buffer, " %ld ", (unsigned long) - GetStdHandle(id[i])); + sprintf(buffer, " %" PRIuMAX " ", + HCAST(uintmax_t, GetStdHandle(id[i]))); is_tty[i] = !!strstr(env, buffer); } } diff --git a/compat/poll/poll.c b/compat/poll/poll.c index db4e03ed79..b10adc780f 100644 --- a/compat/poll/poll.c +++ b/compat/poll/poll.c @@ -76,7 +76,7 @@ #ifdef WIN32_NATIVE -#define IsConsoleHandle(h) (((long) (h) & 3) == 3) +#define IsConsoleHandle(h) (((long) (intptr_t) (h) & 3) == 3) static BOOL IsSocketHandle (HANDLE h) diff --git a/compat/regex/regcomp.c b/compat/regex/regcomp.c index 06f3088708..d8bde06f1a 100644 --- a/compat/regex/regcomp.c +++ b/compat/regex/regcomp.c @@ -2577,7 +2577,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, old_tree = NULL; if (elem->token.type == SUBEXP) - postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx); + postorder (elem, mark_opt_subexp, (void *) (intptr_t) elem->token.opr.idx); tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); if (BE (tree == NULL, 0)) @@ -3806,7 +3806,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node) { - int idx = (int) (long) extra; + int idx = (int) (intptr_t) extra; if (node->token.type == SUBEXP && node->token.opr.idx == idx) node->token.opt_subexp = 1; diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h index 1ade961769..62151d7550 100644 --- a/compat/win32/pthread.h +++ b/compat/win32/pthread.h @@ -18,7 +18,10 @@ */ #define pthread_mutex_t CRITICAL_SECTION -#define pthread_mutex_init(a,b) (InitializeCriticalSection((a)), 0) +static inline int return_0(int i) { + return 0; +} +#define pthread_mutex_init(a,b) return_0((InitializeCriticalSection((a)), 0)) #define pthread_mutex_destroy(a) DeleteCriticalSection((a)) #define pthread_mutex_lock EnterCriticalSection #define pthread_mutex_unlock LeaveCriticalSection diff --git a/compat/winansi.c b/compat/winansi.c index 71fb0a4f25..23dec64007 100644 --- a/compat/winansi.c +++ b/compat/winansi.c @@ -456,7 +456,8 @@ static HANDLE duplicate_handle(HANDLE hnd) HANDLE hresult, hproc = GetCurrentProcess(); if (!DuplicateHandle(hproc, hnd, hproc, &hresult, 0, TRUE, DUPLICATE_SAME_ACCESS)) - die_lasterr("DuplicateHandle(%li) failed", (long) hnd); + die_lasterr("DuplicateHandle(%li) failed", + (long) (intptr_t) hnd); return hresult; } diff --git a/config.mak.uname b/config.mak.uname index 06c47af02b..98aad70555 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -547,6 +547,7 @@ else BASIC_LDFLAGS += -Wl,--large-address-aware endif CC = gcc + COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 INSTALL = /bin/install NO_R_TO_GCC_LINKER = YesPlease INTERNAL_QSORT = YesPlease diff --git a/git-compat-util.h b/git-compat-util.h index 6373d93679..fc66006b76 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -516,7 +516,7 @@ extern int git_lstat(const char *, struct stat *); #endif #define DEFAULT_PACKED_GIT_LIMIT \ - ((1024L * 1024L) * (sizeof(void*) >= 8 ? 8192 : 256)) + ((1024L * 1024L) * (size_t)(sizeof(void*) >= 8 ? 8192 : 256)) #ifdef NO_PREAD #define pread git_pread diff --git a/pack-revindex.c b/pack-revindex.c index 5c8376e978..e542ea7703 100644 --- a/pack-revindex.c +++ b/pack-revindex.c @@ -21,7 +21,7 @@ static int pack_revindex_hashsz; static int pack_revindex_ix(struct packed_git *p) { - unsigned long ui = (unsigned long)p; + unsigned long ui = (unsigned long)(intptr_t)p; int i; ui = ui ^ (ui >> 16); /* defeat structure alignment */ diff --git a/sha1_file.c b/sha1_file.c index 88f06bac92..77efc0e8a9 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2017,7 +2017,7 @@ static unsigned long pack_entry_hash(struct packed_git *p, off_t base_offset) { unsigned long hash; - hash = (unsigned long)p + (unsigned long)base_offset; + hash = (unsigned long)(intptr_t)p + (unsigned long)base_offset; hash += (hash >> 8) + (hash >> 16); return hash % MAX_DELTA_CACHE; }