From 84d32bf7678259c08406571cd6ce4b7a6724dcba Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Sat, 27 Apr 2013 20:19:47 +0100 Subject: sparse: Fix mingw_main() argument number/type errors Sparse issues 68 errors (two errors for each main() function) such as the following: SP git.c git.c:510:5: error: too many arguments for function mingw_main git.c:510:5: error: symbol 'mingw_main' redeclared with different type \ (originally declared at git.c:510) - different argument counts The errors are caused by the 'main' macro used by the MinGW build to provide a replacement main() function. The original main function is effectively renamed to 'mingw_main' and is called from the new main function. The replacement main is used to execute certain actions common to all git programs on MinGW (e.g. ensure the standard I/O streams are in binary mode). In order to suppress the errors, we change the macro to include the parameters in the declaration of the mingw_main function. Unfortunately, this change provokes both sparse and gcc to complain about 9 calls to mingw_main(), such as the following: CC git.o git.c: In function 'main': git.c:510: warning: passing argument 2 of 'mingw_main' from \ incompatible pointer type git.c:510: note: expected 'const char **' but argument is of \ type 'char **' In order to suppress these warnings, since both of the main functions need to be declared with the same prototype, we change the declaration of the 9 main functions, thus: int main(int argc, char **argv) Signed-off-by: Ramsay Jones Signed-off-by: Junio C Hamano --- fast-import.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fast-import.c') diff --git a/fast-import.c b/fast-import.c index 5f539d7d8..6d9445302 100644 --- a/fast-import.c +++ b/fast-import.c @@ -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; -- cgit v1.2.1