{"thread":{"id":"33648","subject":"[PATCH 6/6] sparse: Fix mingw_main() argument number/type errors","startedAt":"2013-04-27T19:19:47Z","lastAt":"2013-04-29T23:30:57Z","messageCount":6,"participants":["Ramsay Jones","René Scharfe","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"215732","messageId":"517C24D3.8080802@ramsay1.demon.co.uk","threadId":"33648","inReplyTo":null,"subject":"[PATCH 6/6] sparse: Fix mingw_main() argument number/type errors","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-04-27T19:19:47Z","receivedAt":"2013-04-27T19:19:47Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nSparse issues 68 errors (two errors for each main() function) such\nas the following:\n\n      SP git.c\n  git.c:510:5: error: too many arguments for function mingw_main\n  git.c:510:5: error: symbol 'mingw_main' redeclared with different type \\\n    (originally declared at git.c:510) - different argument counts\n\nThe errors are caused by the 'main' macro used by the MinGW build\nto provide a replacement main() function. The original main function\nis effectively renamed to 'mingw_main' and is called from the new\nmain function. The replacement main is used to execute certain actions\ncommon to all git programs on MinGW (e.g. ensure the standard I/O\nstreams are in binary mode).\n\nIn order to suppress the errors, we change the macro to include the\nparameters in the declaration of the mingw_main function.\n\nUnfortunately, this change provokes both sparse and gcc to complain\nabout 9 calls to mingw_main(), such as the following:\n\n      CC git.o\n  git.c: In function 'main':\n  git.c:510: warning: passing argument 2 of 'mingw_main' from \\\n    incompatible pointer type\n  git.c:510: note: expected 'const char **' but argument is of \\\n    type 'char **'\n\nIn order to suppress these warnings, since both of the main\nfunctions need to be declared with the same prototype, we\nchange the declaration of the 9 main functions, thus:\n\n    int main(int argc, char **argv)\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n compat/mingw.h       | 4 ++--\n credential-store.c   | 4 ++--\n fast-import.c        | 4 ++--\n git.c                | 3 ++-\n remote-testsvn.c     | 2 +-\n test-chmtime.c       | 2 +-\n test-index-version.c | 2 +-\n test-mergesort.c     | 2 +-\n test-parse-options.c | 4 ++--\n test-subprocess.c    | 4 ++--\n 10 files changed, 16 insertions(+), 15 deletions(-)\n\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 3036980..bd0a88b 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -346,8 +346,8 @@ extern CRITICAL_SECTION pinfo_cs;\n  */\n \n #define main(c,v) dummy_decl_mingw_main(); \\\n-static int mingw_main(); \\\n-int main(int argc, const char **argv) \\\n+static int mingw_main(c,v); \\\n+int main(int argc, char **argv) \\\n { \\\n \textern CRITICAL_SECTION pinfo_cs; \\\n \t_fmode = _O_BINARY; \\\ndiff --git a/credential-store.c b/credential-store.c\nindex 26f7589..f9146e5 100644\n--- a/credential-store.c\n+++ b/credential-store.c\n@@ -114,7 +114,7 @@ static int lookup_credential(const char *fn, struct credential *c)\n \treturn c->username && c->password;\n }\n \n-int main(int argc, const char **argv)\n+int main(int argc, char **argv)\n {\n \tconst char * const usage[] = {\n \t\t\"git credential-store [options] <action>\",\n@@ -131,7 +131,7 @@ int main(int argc, const char **argv)\n \n \tumask(077);\n \n-\targc = parse_options(argc, argv, NULL, options, usage, 0);\n+\targc = parse_options(argc, (const char **)argv, NULL, options, usage, 0);\n \tif (argc != 1)\n \t\tusage_with_options(usage, options);\n \top = argv[0];\ndiff --git a/fast-import.c b/fast-import.c\nindex 5f539d7..6d94453 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -297,7 +297,7 @@ static int failure;\n static FILE *pack_edges;\n static unsigned int show_stats = 1;\n static int global_argc;\n-static const char **global_argv;\n+static char **global_argv;\n \n /* Memory pools */\n static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);\n@@ -3347,7 +3347,7 @@ static void parse_argv(void)\n \t\tread_marks();\n }\n \n-int main(int argc, const char **argv)\n+int main(int argc, char **argv)\n {\n \tunsigned int i;\n \ndiff --git a/git.c b/git.c\nindex 1ada169..7dd07aa 100644\n--- a/git.c\n+++ b/git.c\n@@ -507,8 +507,9 @@ static int run_argv(int *argcp, const char ***argv)\n }\n \n \n-int main(int argc, const char **argv)\n+int main(int argc, char **av)\n {\n+\tconst char **argv = (const char **) av;\n \tconst char *cmd;\n \n \tstartup_info = &git_startup_info;\ndiff --git a/remote-testsvn.c b/remote-testsvn.c\nindex 5ddf11c..d7cd5d2 100644\n--- a/remote-testsvn.c\n+++ b/remote-testsvn.c\n@@ -286,7 +286,7 @@ static int do_command(struct strbuf *line)\n \treturn 0;\n }\n \n-int main(int argc, const char **argv)\n+int main(int argc, char **argv)\n {\n \tstruct strbuf buf = STRBUF_INIT, url_sb = STRBUF_INIT,\n \t\t\tprivate_ref_sb = STRBUF_INIT, marksfilename_sb = STRBUF_INIT,\ndiff --git a/test-chmtime.c b/test-chmtime.c\nindex 02b42ba..94903c4 100644\n--- a/test-chmtime.c\n+++ b/test-chmtime.c\n@@ -56,7 +56,7 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq)\n \treturn 1;\n }\n \n-int main(int argc, const char *argv[])\n+int main(int argc, char *argv[])\n {\n \tstatic int verbose;\n \ndiff --git a/test-index-version.c b/test-index-version.c\nindex bfaad9e..05d4699 100644\n--- a/test-index-version.c\n+++ b/test-index-version.c\n@@ -1,6 +1,6 @@\n #include \"cache.h\"\n \n-int main(int argc, const char **argv)\n+int main(int argc, char **argv)\n {\n \tstruct cache_header hdr;\n \tint version;\ndiff --git a/test-mergesort.c b/test-mergesort.c\nindex 3f388b4..ea3b959 100644\n--- a/test-mergesort.c\n+++ b/test-mergesort.c\n@@ -22,7 +22,7 @@ static int compare_strings(const void *a, const void *b)\n \treturn strcmp(x->text, y->text);\n }\n \n-int main(int argc, const char **argv)\n+int main(int argc, char **argv)\n {\n \tstruct line *line, *p = NULL, *lines = NULL;\n \tstruct strbuf sb = STRBUF_INIT;\ndiff --git a/test-parse-options.c b/test-parse-options.c\nindex 3c9510a..434e8b8 100644\n--- a/test-parse-options.c\n+++ b/test-parse-options.c\n@@ -29,7 +29,7 @@ static int number_callback(const struct option *opt, const char *arg, int unset)\n \treturn 0;\n }\n \n-int main(int argc, const char **argv)\n+int main(int argc, char **argv)\n {\n \tconst char *prefix = \"prefix/\";\n \tconst char *usage[] = {\n@@ -81,7 +81,7 @@ int main(int argc, const char **argv)\n \t};\n \tint i;\n \n-\targc = parse_options(argc, argv, prefix, options, usage, 0);\n+\targc = parse_options(argc, (const char **)argv, prefix, options, usage, 0);\n \n \tprintf(\"boolean: %d\\n\", boolean);\n \tprintf(\"integer: %u\\n\", integer);\ndiff --git a/test-subprocess.c b/test-subprocess.c\nindex f2d4c0d..93525eb 100644\n--- a/test-subprocess.c\n+++ b/test-subprocess.c\n@@ -1,7 +1,7 @@\n #include \"cache.h\"\n #include \"run-command.h\"\n \n-int main(int argc, const char **argv)\n+int main(int argc, char **argv)\n {\n \tstruct child_process cp;\n \tint nogit = 0;\n@@ -15,6 +15,6 @@ int main(int argc, const char **argv)\n \t}\n \tmemset(&cp, 0, sizeof(cp));\n \tcp.git_cmd = 1;\n-\tcp.argv = argv + 1;\n+\tcp.argv = (const char **)argv + 1;\n \treturn run_command(&cp);\n }\n-- \n1.8.2\n"},{"id":"215776","messageId":"517C6DEF.2050305@lsrfire.ath.cx","threadId":"33648","inReplyTo":"517C24D3.8080802@ramsay1.demon.co.uk","subject":"Re: [PATCH 6/6] sparse: Fix mingw_main() argument number/type errors","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2013-04-28T00:31:43Z","receivedAt":"2013-04-28T00:31:43Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 27.04.2013 21:19, schrieb Ramsay Jones:\n> In order to suppress these warnings, since both of the main\n> functions need to be declared with the same prototype, we\n> change the declaration of the 9 main functions, thus:\n> \n>      int main(int argc, char **argv)\n\nWhy not take the opposite direction with a patch like this?  It's quick\nand dirty and based on v1.8.1.msysgit.1, as that was the version I had\nlying around here, but you get the idea.\n\nRené\n\n---\n compat/mingw.h          |  4 ++--\n daemon.c                | 16 ++++++++--------\n http-backend.c          |  2 +-\n imap-send.c             |  2 +-\n sh-i18n--envsubst.c     |  2 +-\n shell.c                 |  2 +-\n show-index.c            |  2 +-\n test-ctype.c            |  2 +-\n test-date.c             |  8 ++++----\n test-delta.c            |  2 +-\n test-dump-cache-tree.c  |  2 +-\n test-genrandom.c        |  2 +-\n test-line-buffer.c      |  2 +-\n test-match-trees.c      |  2 +-\n test-mktemp.c           |  2 +-\n test-path-utils.c       |  4 ++--\n test-regex.c            |  2 +-\n test-revision-walking.c |  2 +-\n test-run-command.c      |  2 +-\n test-scrap-cache-tree.c |  2 +-\n test-sha1.c             |  2 +-\n test-sigchain.c         |  2 +-\n test-string-list.c      |  2 +-\n test-svn-fe.c           |  4 ++--\n upload-pack.c           |  6 +++---\n 25 files changed, 40 insertions(+), 40 deletions(-)\n\ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 389ae01..74e7b87 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -452,11 +452,11 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen);\n \n void mingw_startup();\n #define main(c,v) dummy_decl_mingw_main(); \\\n-static int mingw_main(); \\\n+static int mingw_main(int, const char **); \\\n int main(int argc, const char **argv) \\\n { \\\n \tmingw_startup(); \\\n-\treturn mingw_main(__argc, __argv); \\\n+\treturn mingw_main(argc, argv); \\\n } \\\n static int mingw_main(c,v)\n \ndiff --git a/daemon.c b/daemon.c\nindex 4602b46..f4186a7 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -36,15 +36,15 @@ static const char daemon_usage[] =\n \"           [<directory>...]\";\n \n /* List of acceptable pathname prefixes */\n-static char **ok_paths;\n+static const char **ok_paths;\n static int strict_paths;\n \n /* If this is set, git-daemon-export-ok is not required */\n static int export_all_trees;\n \n /* Take all paths relative to this one if non-NULL */\n-static char *base_path;\n-static char *interpolated_path;\n+static const char *base_path;\n+static const char *interpolated_path;\n static int base_path_relaxed;\n \n /* Flag indicating client sent extra args. */\n@@ -196,7 +196,7 @@ static const char *path_ok(char *directory)\n \t}\n \n \tif ( ok_paths && *ok_paths ) {\n-\t\tchar **pp;\n+\t\tconst char **pp;\n \t\tint pathlen = strlen(path);\n \n \t\t/* The validation is done on the paths after enter_repo\n@@ -257,7 +257,7 @@ static int daemon_error(const char *dir, const char *msg)\n \treturn -1;\n }\n \n-static char *access_hook;\n+static const char *access_hook;\n \n static int run_access_hook(struct daemon_service *service, const char *dir, const char *path)\n {\n@@ -739,7 +739,7 @@ static void check_dead_children(void)\n \t\t\tcradle = &blanket->next;\n }\n \n-static char **cld_argv;\n+static const char **cld_argv;\n static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)\n {\n \tstruct child_process cld = { NULL };\n@@ -1164,7 +1164,7 @@ static int serve(struct string_list *listen_addr, int listen_port,\n \treturn service_loop(&socklist);\n }\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tint listen_port = 0;\n \tstruct string_list listen_addr = STRING_LIST_INIT_NODUP;\n@@ -1179,7 +1179,7 @@ int main(int argc, char **argv)\n \tgit_extract_argv0_path(argv[0]);\n \n \tfor (i = 1; i < argc; i++) {\n-\t\tchar *arg = argv[i];\n+\t\tconst char *arg = argv[i];\n \n \t\tif (!prefixcmp(arg, \"--listen=\")) {\n \t\t\tstring_list_append(&listen_addr, xstrdup_tolower(arg + 9));\ndiff --git a/http-backend.c b/http-backend.c\nindex f50e77f..ce164bb 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -533,7 +533,7 @@ static struct service_cmd {\n \t{\"POST\", \"/git-receive-pack$\", service_rpc}\n };\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tchar *method = getenv(\"REQUEST_METHOD\");\n \tchar *dir;\ndiff --git a/imap-send.c b/imap-send.c\nindex d42e471..ec98934 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -1502,7 +1502,7 @@ static int git_imap_config(const char *key, const char *val, void *cb)\n \treturn 0;\n }\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tstruct msg_data all_msgs, msg;\n \tstruct store *ctx = NULL;\ndiff --git a/sh-i18n--envsubst.c b/sh-i18n--envsubst.c\nindex 5ddd688..c3d0654 100644\n--- a/sh-i18n--envsubst.c\n+++ b/sh-i18n--envsubst.c\n@@ -64,7 +64,7 @@ static void note_variables (const char *string);\n static void subst_from_stdin (void);\n \n int\n-main (int argc, char *argv[])\n+main (int argc, const char *argv[])\n {\n   /* Default values for command line options.  */\n   /* unsigned short int show_variables = 0; */\ndiff --git a/shell.c b/shell.c\nindex 06a394c..9ec4491 100644\n--- a/shell.c\n+++ b/shell.c\n@@ -129,7 +129,7 @@ static struct commands {\n \t{ NULL },\n };\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tchar *prog;\n \tconst char **user_argv;\ndiff --git a/show-index.c b/show-index.c\nindex 5a9eed7..651a115 100644\n--- a/show-index.c\n+++ b/show-index.c\n@@ -4,7 +4,7 @@\n static const char show_index_usage[] =\n \"git show-index < <packed archive index>\";\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tint i;\n \tunsigned nr;\ndiff --git a/test-ctype.c b/test-ctype.c\nindex 707a821..694dcfb 100644\n--- a/test-ctype.c\n+++ b/test-ctype.c\n@@ -28,7 +28,7 @@ static int is_in(const char *s, int ch)\n #define LOWER \"abcdefghijklmnopqrstuvwxyz\"\n #define UPPER \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tTEST_CLASS(isdigit, DIGIT);\n \tTEST_CLASS(isspace, \" \\n\\r\\t\");\ndiff --git a/test-date.c b/test-date.c\nindex 10afaab..00c9e93 100644\n--- a/test-date.c\n+++ b/test-date.c\n@@ -5,7 +5,7 @@ static const char *usage_msg = \"\\n\"\n \"  test-date parse [date]...\\n\"\n \"  test-date approxidate [date]...\\n\";\n \n-static void show_dates(char **argv, struct timeval *now)\n+static void show_dates(const char **argv, struct timeval *now)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \n@@ -17,7 +17,7 @@ static void show_dates(char **argv, struct timeval *now)\n \tstrbuf_release(&buf);\n }\n \n-static void parse_dates(char **argv, struct timeval *now)\n+static void parse_dates(const char **argv, struct timeval *now)\n {\n \tfor (; *argv; argv++) {\n \t\tchar result[100];\n@@ -34,7 +34,7 @@ static void parse_dates(char **argv, struct timeval *now)\n \t}\n }\n \n-static void parse_approxidate(char **argv, struct timeval *now)\n+static void parse_approxidate(const char **argv, struct timeval *now)\n {\n \tfor (; *argv; argv++) {\n \t\ttime_t t;\n@@ -43,7 +43,7 @@ static void parse_approxidate(char **argv, struct timeval *now)\n \t}\n }\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tstruct timeval now;\n \tconst char *x;\ndiff --git a/test-delta.c b/test-delta.c\nindex af40a3c..b697e87 100644\n--- a/test-delta.c\n+++ b/test-delta.c\n@@ -15,7 +15,7 @@\n static const char usage_str[] =\n \t\"test-delta (-d|-p) <from_file> <data_file> <out_file>\";\n \n-int main(int argc, char *argv[])\n+int main(int argc, const char *argv[])\n {\n \tint fd;\n \tstruct stat st;\ndiff --git a/test-dump-cache-tree.c b/test-dump-cache-tree.c\nindex a6ffdf3..ab75fe0 100644\n--- a/test-dump-cache-tree.c\n+++ b/test-dump-cache-tree.c\n@@ -54,7 +54,7 @@ static int dump_cache_tree(struct cache_tree *it,\n \treturn errs;\n }\n \n-int main(int ac, char **av)\n+int main(int ac, const char **av)\n {\n \tstruct cache_tree *another = cache_tree();\n \tif (read_cache() < 0)\ndiff --git a/test-genrandom.c b/test-genrandom.c\nindex b3c28d9..fa63cfd 100644\n--- a/test-genrandom.c\n+++ b/test-genrandom.c\n@@ -6,7 +6,7 @@\n \n #include \"git-compat-util.h\"\n \n-int main(int argc, char *argv[])\n+int main(int argc, const char *argv[])\n {\n \tunsigned long count, next = 0;\n \tunsigned char *c;\ndiff --git a/test-line-buffer.c b/test-line-buffer.c\nindex ef1d7ba..a018fd7 100644\n--- a/test-line-buffer.c\n+++ b/test-line-buffer.c\n@@ -50,7 +50,7 @@ static void handle_line(const char *line, struct line_buffer *stdin_buf)\n \thandle_command(line, arg + 1, stdin_buf);\n }\n \n-int main(int argc, char *argv[])\n+int main(int argc, const char *argv[])\n {\n \tstruct line_buffer stdin_buf = LINE_BUFFER_INIT;\n \tstruct line_buffer file_buf = LINE_BUFFER_INIT;\ndiff --git a/test-match-trees.c b/test-match-trees.c\nindex a3c4688..2af5d80 100644\n--- a/test-match-trees.c\n+++ b/test-match-trees.c\n@@ -1,7 +1,7 @@\n #include \"cache.h\"\n #include \"tree.h\"\n \n-int main(int ac, char **av)\n+int main(int ac, const char **av)\n {\n \tunsigned char hash1[20], hash2[20], shifted[20];\n \tstruct tree *one, *two;\ndiff --git a/test-mktemp.c b/test-mktemp.c\nindex c8c5421..6f3542c 100644\n--- a/test-mktemp.c\n+++ b/test-mktemp.c\n@@ -3,7 +3,7 @@\n  */\n #include \"git-compat-util.h\"\n \n-int main(int argc, char *argv[])\n+int main(int argc, const char *argv[])\n {\n \tif (argc != 2)\n \t\tusage(\"Expected 1 parameter defining the temporary file template\");\ndiff --git a/test-path-utils.c b/test-path-utils.c\nindex 0092cbf..e02154c 100644\n--- a/test-path-utils.c\n+++ b/test-path-utils.c\n@@ -28,7 +28,7 @@ static int normalize_ceiling_entry(struct string_list_item *item, void *unused)\n \treturn 1;\n }\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tif (argc == 3 && !strcmp(argv[1], \"normalize_path_copy\")) {\n \t\tchar *buf = xmalloc(PATH_MAX + 1);\n@@ -85,7 +85,7 @@ int main(int argc, char **argv)\n \t}\n \n \tif (argc >= 4 && !strcmp(argv[1], \"prefix_path\")) {\n-\t\tchar *prefix = argv[2];\n+\t\tconst char *prefix = argv[2];\n \t\tint prefix_len = strlen(prefix);\n \t\tint nongit_ok;\n \t\tsetup_git_directory_gently(&nongit_ok);\ndiff --git a/test-regex.c b/test-regex.c\nindex b5bfd54..22536aa 100644\n--- a/test-regex.c\n+++ b/test-regex.c\n@@ -1,6 +1,6 @@\n #include <git-compat-util.h>\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tchar *pat = \"[^={} \\t]+\";\n \tchar *str = \"={}\\nfred\";\ndiff --git a/test-revision-walking.c b/test-revision-walking.c\nindex 3ade02c..d305962 100644\n--- a/test-revision-walking.c\n+++ b/test-revision-walking.c\n@@ -45,7 +45,7 @@ static int run_revision_walk(void)\n \treturn got_revision;\n }\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tif (argc < 2)\n \t\treturn 1;\ndiff --git a/test-run-command.c b/test-run-command.c\nindex 37918e1..00f040b 100644\n--- a/test-run-command.c\n+++ b/test-run-command.c\n@@ -13,7 +13,7 @@\n #include <string.h>\n #include <errno.h>\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tstruct child_process proc;\n \ndiff --git a/test-scrap-cache-tree.c b/test-scrap-cache-tree.c\nindex 4728013..cae5bcb 100644\n--- a/test-scrap-cache-tree.c\n+++ b/test-scrap-cache-tree.c\n@@ -4,7 +4,7 @@\n \n static struct lock_file index_lock;\n \n-int main(int ac, char **av)\n+int main(int ac, const char **av)\n {\n \tint fd = hold_locked_index(&index_lock, 1);\n \tif (read_cache() < 0)\ndiff --git a/test-sha1.c b/test-sha1.c\nindex 80daba9..aed67af 100644\n--- a/test-sha1.c\n+++ b/test-sha1.c\n@@ -1,6 +1,6 @@\n #include \"cache.h\"\n \n-int main(int ac, char **av)\n+int main(int ac, const char **av)\n {\n \tgit_SHA_CTX ctx;\n \tunsigned char sha1[20];\ndiff --git a/test-sigchain.c b/test-sigchain.c\nindex 42db234..b00e17f 100644\n--- a/test-sigchain.c\n+++ b/test-sigchain.c\n@@ -13,7 +13,7 @@ X(two)\n X(three)\n #undef X\n \n-int main(int argc, char **argv) {\n+int main(int argc, const char **argv) {\n \tsigchain_push(SIGTERM, one);\n \tsigchain_push(SIGTERM, two);\n \tsigchain_push(SIGTERM, three);\ndiff --git a/test-string-list.c b/test-string-list.c\nindex 00ce6c9..f59cf05 100644\n--- a/test-string-list.c\n+++ b/test-string-list.c\n@@ -41,7 +41,7 @@ static int prefix_cb(struct string_list_item *item, void *cb_data)\n \treturn !prefixcmp(item->string, prefix);\n }\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n \tif (argc == 5 && !strcmp(argv[1], \"split\")) {\n \t\tstruct string_list list = STRING_LIST_INIT_DUP;\ndiff --git a/test-svn-fe.c b/test-svn-fe.c\nindex 0f2d9a4..8ac4954 100644\n--- a/test-svn-fe.c\n+++ b/test-svn-fe.c\n@@ -11,7 +11,7 @@\n static const char test_svnfe_usage[] =\n \t\"test-svn-fe (<dumpfile> | [-d] <preimage> <delta> <len>)\";\n \n-static int apply_delta(int argc, char *argv[])\n+static int apply_delta(int argc, const char *argv[])\n {\n \tstruct line_buffer preimage = LINE_BUFFER_INIT;\n \tstruct line_buffer delta = LINE_BUFFER_INIT;\n@@ -35,7 +35,7 @@ static int apply_delta(int argc, char *argv[])\n \treturn 0;\n }\n \n-int main(int argc, char *argv[])\n+int main(int argc, const char *argv[])\n {\n \tif (argc == 2) {\n \t\tif (svndump_init(argv[1]))\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 6142421..71c72cc 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -780,9 +780,9 @@ static void upload_pack(void)\n \t}\n }\n \n-int main(int argc, char **argv)\n+int main(int argc, const char **argv)\n {\n-\tchar *dir;\n+\tconst char *dir;\n \tint i;\n \tint strict = 0;\n \n@@ -793,7 +793,7 @@ int main(int argc, char **argv)\n \tread_replace_refs = 0;\n \n \tfor (i = 1; i < argc; i++) {\n-\t\tchar *arg = argv[i];\n+\t\tconst char *arg = argv[i];\n \n \t\tif (arg[0] != '-')\n \t\t\tbreak;\n"},{"id":"215803","messageId":"7v38uaqwow.fsf@alter.siamese.dyndns.org","threadId":"33648","inReplyTo":"517C6DEF.2050305@lsrfire.ath.cx","subject":"Re: [PATCH 6/6] sparse: Fix mingw_main() argument number/type errors","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-28T19:31:11Z","receivedAt":"2013-04-28T19:31:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n\n> Why not take the opposite direction with a patch like this?\n> ...\n> diff --git a/compat/mingw.h b/compat/mingw.h\n> index 389ae01..74e7b87 100644\n> --- a/compat/mingw.h\n> +++ b/compat/mingw.h\n> @@ -452,11 +452,11 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen);\n>  \n>  void mingw_startup();\n>  #define main(c,v) dummy_decl_mingw_main(); \\\n> -static int mingw_main(); \\\n> +static int mingw_main(int, const char **); \\\n>  int main(int argc, const char **argv) \\\n\nBut traditionally main is declared like \n\n\tint main(int argc, char *argv[]);\n\nwithout const, no?\n"},{"id":"215860","messageId":"517E9B88.1040807@lsrfire.ath.cx","threadId":"33648","inReplyTo":"7v38uaqwow.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 6/6] sparse: Fix mingw_main() argument number/type errors","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2013-04-29T16:10:48Z","receivedAt":"2013-04-29T16:10:48Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Am 28.04.2013 21:31, schrieb Junio C Hamano:\n> René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n>\n>> Why not take the opposite direction with a patch like this?\n>> ...\n>> diff --git a/compat/mingw.h b/compat/mingw.h\n>> index 389ae01..74e7b87 100644\n>> --- a/compat/mingw.h\n>> +++ b/compat/mingw.h\n>> @@ -452,11 +452,11 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen);\n>>\n>>   void mingw_startup();\n>>   #define main(c,v) dummy_decl_mingw_main(); \\\n>> -static int mingw_main(); \\\n>> +static int mingw_main(int, const char **); \\\n>>   int main(int argc, const char **argv) \\\n>\n> But traditionally main is declared like\n>\n> \tint main(int argc, char *argv[]);\n>\n> without const, no?\n\nYes, http://c-faq.com/ansi/maindecl.html and basically everybody else \nagree.  Now that I actually think about it, the only benefit of \ndeclaring argv constant I can find is that the const'ness could easily \nspread to other variables and function arguments where it may actually \nmatter.  So please ignore my interjection.  Or perhaps it might be worth \nmentioning in the commit message that removal of that \"const\" improves \nthe code's standard compliance.\n\nRené\n"},{"id":"215936","messageId":"517EEBAD.3090201@ramsay1.demon.co.uk","threadId":"33648","inReplyTo":"517C6DEF.2050305@lsrfire.ath.cx","subject":"Re: [PATCH 6/6] sparse: Fix mingw_main() argument number/type errors","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-04-29T21:52:45Z","receivedAt":"2013-04-29T21:52:45Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"René Scharfe wrote:\n> Am 27.04.2013 21:19, schrieb Ramsay Jones:\n>> In order to suppress these warnings, since both of the main\n>> functions need to be declared with the same prototype, we\n>> change the declaration of the 9 main functions, thus:\n>>\n>>      int main(int argc, char **argv)\n> \n> Why not take the opposite direction with a patch like this?  It's quick\n> and dirty and based on v1.8.1.msysgit.1, as that was the version I had\n> lying around here, but you get the idea.\n\nThe main reason (99%) was patch size. I only noticed a \"recent trend\"\nto declare the main() with a 'const char **argv' parameter because,\nover the years, I've had to keep adding to this patch. (Having said\nthat, I suspect it has only been about four additions in four years).\n\nThe other 1% is simply that it just looks wrong! (yeah, this new\n'const' thingamajig has it's uses, but still ... :-D ).\n\nJust FYI, the C99 standard has this to say:\n\n    c99 standard 5.1.2.2.1 \"Program startup\"\n\n    The function called at program startup is named main. The\n    implementation declares no prototype for this function. It\n    shall be defined with a return type of int and with no\n    parameters:\n\n        int main(void) { /* ... */ }\n\n    or with two parameters (referred to here as argc and argv,\n    though any names may be used, as they are local to the\n    function in which they are declared);\n\n        int main(int argc, char *argv[]) { /* ... */ }\n\n    or equivalent;^9 or in some other implementation-defined\n    manner.\n\n    [note 9: Thus, int can be replaced by a typedef name\n    defined as int, or the type of argv can be written as\n    char **argv, and so on.]\n\n    ...\n\n        - The parameters argc and argv and the strings pointed\n        to by the argv array shall be modifiable by the program,\n        and retain their last-stored values between program\n        startup and program termination.\n\n\nThat \"... or in some other implementation-defined manner.\" tends\nto make this text somewhat weak!\n\nATB,\nRamsay Jones\n"},{"id":"215941","messageId":"517F02B1.3030304@ramsay1.demon.co.uk","threadId":"33648","inReplyTo":"517E9B88.1040807@lsrfire.ath.cx","subject":"Re: [PATCH 6/6] sparse: Fix mingw_main() argument number/type errors","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-04-29T23:30:57Z","receivedAt":"2013-04-29T23:30:57Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"René Scharfe wrote:\n> Am 28.04.2013 21:31, schrieb Junio C Hamano:\n>> René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n>>\n>>> Why not take the opposite direction with a patch like this?\n>>> ...\n>>> diff --git a/compat/mingw.h b/compat/mingw.h\n>>> index 389ae01..74e7b87 100644\n>>> --- a/compat/mingw.h\n>>> +++ b/compat/mingw.h\n>>> @@ -452,11 +452,11 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen);\n>>>\n>>>   void mingw_startup();\n>>>   #define main(c,v) dummy_decl_mingw_main(); \\\n>>> -static int mingw_main(); \\\n>>> +static int mingw_main(int, const char **); \\\n>>>   int main(int argc, const char **argv) \\\n>>\n>> But traditionally main is declared like\n>>\n>> \tint main(int argc, char *argv[]);\n>>\n>> without const, no?\n> \n> Yes, http://c-faq.com/ansi/maindecl.html and basically everybody else \n> agree.  Now that I actually think about it, the only benefit of \n> declaring argv constant I can find is that the const'ness could easily \n> spread to other variables and function arguments where it may actually \n> matter.  So please ignore my interjection.  Or perhaps it might be worth \n> mentioning in the commit message that removal of that \"const\" improves \n> the code's standard compliance.\n\nHmm, well, strictly speaking, I can't say that is true! (see previous\nemail). It is certainly true that it more closely follows the *spirit*\nof the standard, if not the letter of the law.\n\nATB,\nRamsay Jones\n"}]}