{"thread":{"id":"26813","subject":"[PATCH 1/2] Makefile: Cover more files with make check","startedAt":"2011-03-21T09:45:03Z","lastAt":"2011-03-22T17:18:37Z","messageCount":13,"participants":["Stephen Boyd","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"163880","messageId":"1300700704-22674-1-git-send-email-bebarino@gmail.com","threadId":"26813","inReplyTo":null,"subject":"[PATCH 1/2] Makefile: Cover more files with make check","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2011-03-21T09:45:03Z","receivedAt":"2011-03-21T09:45:03Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"After the builtin/ move 'make check' doesn't cover the builtin/\ndirectory. We could just add builtin/*.c but lets just use GIT_OBJS\ninstead so we cover future movement of the source files.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n Makefile |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 654d8ac..97cd150 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2176,7 +2176,7 @@ check-sha1:: test-sha1$X\n check: common-cmds.h\n \tif sparse; \\\n \tthen \\\n-\t\tfor i in *.c; \\\n+\t\tfor i in $(patsubst %.o, %.c, $(GIT_OBJS)); \\\n \t\tdo \\\n \t\t\tsparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \\\n \t\tdone; \\\n-- \n1.7.4.1.343.ga91df\n"},{"id":"163881","messageId":"1300700704-22674-2-git-send-email-bebarino@gmail.com","threadId":"26813","inReplyTo":"1300700704-22674-1-git-send-email-bebarino@gmail.com","subject":"[PATCH 2/2] Fix sparse warnings","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2011-03-21T09:45:04Z","receivedAt":"2011-03-21T09:45:04Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Fix warnings from 'make check'.\n\ndiff.c:631:25: warning: symbol 'diff_words_styles' was not declared.\nShould it be static?\nnotes-merge.c:362:73: warning: Using plain integer as NULL pointer\nparse-options.c:564:6: error: symbol 'usage_with_options' redeclared\nwith different type (originally declared at parse-options.h:158) -\ndifferent modifiers\nparse-options.c:571:6: error: symbol 'usage_msg_opt' redeclared with\ndifferent type (originally declared at parse-options.h:161) - different\nmodifiers\nreplace_object.c:92:21: warning: symbol 'lookup_replace_object' was not\ndeclared. Should it be static?\nsubmodule.c:12:20: warning: symbol 'config_name_for_path' was not\ndeclared. Should it be static?\nsubmodule.c:13:20: warning: symbol\n'config_fetch_recurse_submodules_for_name' was not declared. Should it\nbe static?\nsubmodule.c:14:20: warning: symbol 'config_ignore_for_name' was not\ndeclared. Should it be static?\ntrace.c:78:6: warning: symbol 'trace_printf_key' was not declared.\nShould it be static?\ntransport.c:195:29: warning: Using plain integer as NULL pointer\ntransport-helper.c:79:12: warning: symbol 'remove_ext_force' was not\ndeclared. Should it be static?\nunpack-trees.c:19:12: warning: symbol 'unpack_plumbing_errors' was not\ndeclared. Should it be static?\nurl.c:3:5: warning: symbol 'is_urlschemechar' was not declared. Should\nit be static?\nurl.c:18:5: warning: symbol 'is_url' was not declared. Should it be\nstatic?\nurl.c:104:6: warning: symbol 'url_decode' was not declared. Should it be\nstatic?\nurl.c:117:6: warning: symbol 'url_decode_parameter_name' was not\ndeclared. Should it be static?\nurl.c:123:6: warning: symbol 'url_decode_parameter_value' was not\ndeclared. Should it be static?\nurl.c:129:6: warning: symbol 'end_url_with_slash' was not declared.\nShould it be static?\nurl.c:136:6: warning: symbol 'str_end_url_with_slash' was not declared.\nShould it be static?\nusage.c:49:6: error: symbol 'usagef' redeclared with different type\n(originally declared at git-compat-util.h:239) - different modifiers\nusage.c:58:6: error: symbol 'usage' redeclared with different type\n(originally declared at git-compat-util.h:238) - different modifiers\nusage.c:63:6: error: symbol 'die' redeclared with different type\n(originally declared at git-compat-util.h:240) - different modifiers\nusage.c:72:6: error: symbol 'die_errno' redeclared with different type\n(originally declared at git-compat-util.h:241) - different modifiers\nthread-utils.c:21:5: warning: symbol 'online_cpus' was not declared.\nShould it be static?\nthread-utils.c:48:5: warning: symbol 'init_recursive_mutex' was not\ndeclared. Should it be static?\nbuiltin/clone.c:364:5: warning: symbol 'cmd_clone' was not declared.\nShould it be static?\nbuiltin/fetch-pack.c:797:5: warning: symbol 'cmd_fetch_pack' was not\ndeclared. Should it be static?\nbuiltin/fmt-merge-msg.c:34:6: warning: symbol 'init_src_data' was not\ndeclared. Should it be static?\nbuiltin/hash-object.c:78:5: warning: symbol 'cmd_hash_object' was not\ndeclared. Should it be static?\nbuiltin/index-pack.c:210:13: error: symbol 'bad_object' redeclared with\ndifferent type (originally declared at builtin/index-pack.c:207) -\ndifferent modifiers\nbuiltin/merge-index.c:69:5: warning: symbol 'cmd_merge_index' was not\ndeclared. Should it be static?\nbuiltin/merge-recursive.c:22:5: warning: symbol 'cmd_merge_recursive'\nwas not declared. Should it be static?\nbuiltin/merge-tree.c:341:5: warning: symbol 'cmd_merge_tree' was not\ndeclared. Should it be static?\nbuiltin/mktag.c:156:5: warning: symbol 'cmd_mktag' was not declared.\nShould it be static?\nbuiltin/notes.c:426:5: warning: symbol 'notes_copy_from_stdin' was not\ndeclared. Should it be static?\nbuiltin/notes.c:822:64: warning: Using plain integer as NULL pointer\nbuiltin/pack-redundant.c:596:5: warning: symbol 'cmd_pack_redundant' was\nnot declared. Should it be static?\nbuiltin/pack-refs.c:10:5: warning: symbol 'cmd_pack_refs' was not\ndeclared. Should it be static?\nbuiltin/patch-id.c:60:5: warning: symbol 'get_one_patchid' was not\ndeclared. Should it be static?\nbuiltin/patch-id.c:149:5: warning: symbol 'cmd_patch_id' was not\ndeclared. Should it be static?\nbuiltin/remote.c:1512:5: warning: symbol 'cmd_remote' was not declared.\nShould it be static?\nbuiltin/remote-ext.c:240:5: warning: symbol 'cmd_remote_ext' was not\ndeclared. Should it be static?\nbuiltin/remote-fd.c:53:5: warning: symbol 'cmd_remote_fd' was not\ndeclared. Should it be static?\nbuiltin/reset.c:236:5: warning: symbol 'cmd_reset' was not declared.\nShould it be static?\nbuiltin/send-pack.c:384:5: warning: symbol 'cmd_send_pack' was not\ndeclared. Should it be static?\nbuiltin/unpack-file.c:25:5: warning: symbol 'cmd_unpack_file' was not\ndeclared. Should it be static?\nbuiltin/var.c:75:5: warning: symbol 'cmd_var' was not declared. Should\nit be static?\ndaemon.c:663:38: warning: Using plain integer as NULL pointer\nfast-import.c:2942:35: warning: Using plain integer as NULL pointer\nimap-send.c:1072:48: warning: Using plain integer as NULL pointer\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\nThis is one mega-patch. I can split it into separate files if that's\ndesirable but I figured it was easier to avoid spamming the list\nwith a bunch of oneline patches. There are two trivial conflicts\nin pu with this patch.\n\n builtin/clone.c           |    1 +\n builtin/fetch-pack.c      |    1 +\n builtin/fmt-merge-msg.c   |    2 +-\n builtin/hash-object.c     |    1 +\n builtin/index-pack.c      |    2 +-\n builtin/merge-index.c     |    1 +\n builtin/merge-recursive.c |    1 +\n builtin/merge-tree.c      |    1 +\n builtin/mktag.c           |    1 +\n builtin/notes.c           |    4 ++--\n builtin/pack-redundant.c  |    1 +\n builtin/pack-refs.c       |    1 +\n builtin/patch-id.c        |    3 ++-\n builtin/remote-ext.c      |    1 +\n builtin/remote-fd.c       |    1 +\n builtin/remote.c          |    1 +\n builtin/reset.c           |    1 +\n builtin/send-pack.c       |    1 +\n builtin/unpack-file.c     |    1 +\n builtin/var.c             |    1 +\n daemon.c                  |    2 +-\n diff.c                    |    2 +-\n fast-import.c             |    2 +-\n imap-send.c               |    2 +-\n notes-merge.c             |    2 +-\n parse-options.c           |    4 ++--\n replace_object.c          |    1 +\n submodule.c               |    6 +++---\n thread-utils.c            |    1 +\n trace.c                   |    2 +-\n transport-helper.c        |    2 +-\n transport.c               |    2 +-\n unpack-trees.c            |    2 +-\n url.c                     |    1 +\n usage.c                   |    8 ++++----\n 35 files changed, 43 insertions(+), 23 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 02547ad..53ea012 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -23,6 +23,7 @@\n #include \"branch.h\"\n #include \"remote.h\"\n #include \"run-command.h\"\n+#include \"builtin.h\"\n \n /*\n  * Overall FIXMEs:\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex 272bc38..9d1505c 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -9,6 +9,7 @@\n #include \"fetch-pack.h\"\n #include \"remote.h\"\n #include \"run-command.h\"\n+#include \"builtin.h\"\n \n static int transfer_unpack_limit = -1;\n static int fetch_unpack_limit = -1;\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 5189b16..7581632 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -31,7 +31,7 @@ struct src_data {\n \tint head_status;\n };\n \n-void init_src_data(struct src_data *data)\n+static void init_src_data(struct src_data *data)\n {\n \tdata->branch.strdup_strings = 1;\n \tdata->tag.strdup_strings = 1;\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex c90acdd..8cbbba9 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -9,6 +9,7 @@\n #include \"quote.h\"\n #include \"parse-options.h\"\n #include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n static void hash_fd(int fd, const char *type, int write_object, const char *path)\n {\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex c7e600d..5a67c81 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -207,7 +207,7 @@ static void parse_pack_header(void)\n static NORETURN void bad_object(unsigned long offset, const char *format,\n \t\t       ...) __attribute__((format (printf, 2, 3)));\n \n-static void bad_object(unsigned long offset, const char *format, ...)\n+static NORETURN void bad_object(unsigned long offset, const char *format, ...)\n {\n \tva_list params;\n \tchar buf[1024];\ndiff --git a/builtin/merge-index.c b/builtin/merge-index.c\nindex 2c4cf5e..634327c 100644\n--- a/builtin/merge-index.c\n+++ b/builtin/merge-index.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"run-command.h\"\n #include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n static const char *pgm;\n static int one_shot, quiet;\ndiff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c\nindex c33091b..f8ca00a 100644\n--- a/builtin/merge-recursive.c\n+++ b/builtin/merge-recursive.c\n@@ -3,6 +3,7 @@\n #include \"tag.h\"\n #include \"merge-recursive.h\"\n #include \"xdiff-interface.h\"\n+#include \"builtin.h\"\n \n static const char builtin_merge_recursive_usage[] =\n \t\"git %s <base>... -- <head> <remote> ...\";\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 9b25ddc..ad5afd2 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -3,6 +3,7 @@\n #include \"xdiff-interface.h\"\n #include \"blob.h\"\n #include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n static const char merge_tree_usage[] = \"git merge-tree <base-tree> <branch1> <branch2>\";\n static int resolve_directories = 1;\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 1cb0f3f..6132a43 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"tag.h\"\n #include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n /*\n  * A signature file has a very simple fixed format: four lines\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 0aab150..a0f310b 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -423,7 +423,7 @@ void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c)\n \tfree(c);\n }\n \n-int notes_copy_from_stdin(int force, const char *rewrite_cmd)\n+static int notes_copy_from_stdin(int force, const char *rewrite_cmd)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct notes_rewrite_cfg *c = NULL;\n@@ -819,7 +819,7 @@ static int merge_commit(struct notes_merge_options *o)\n \tt = xcalloc(1, sizeof(struct notes_tree));\n \tinit_notes(t, \"NOTES_MERGE_PARTIAL\", combine_notes_overwrite, 0);\n \n-\to->local_ref = resolve_ref(\"NOTES_MERGE_REF\", sha1, 0, 0);\n+\to->local_ref = resolve_ref(\"NOTES_MERGE_REF\", sha1, 0, NULL);\n \tif (!o->local_ref)\n \t\tdie(\"Failed to resolve NOTES_MERGE_REF\");\n \ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex 41e1615..8fcba68 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -8,6 +8,7 @@\n \n #include \"cache.h\"\n #include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n #define BLKSIZE 512\n \ndiff --git a/builtin/pack-refs.c b/builtin/pack-refs.c\nindex 091860b..9b32efb 100644\n--- a/builtin/pack-refs.c\n+++ b/builtin/pack-refs.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"parse-options.h\"\n #include \"pack-refs.h\"\n+#include \"builtin.h\"\n \n static char const * const pack_refs_usage[] = {\n \t\"git pack-refs [options]\",\ndiff --git a/builtin/patch-id.c b/builtin/patch-id.c\nindex 49a0472..d008960 100644\n--- a/builtin/patch-id.c\n+++ b/builtin/patch-id.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n static void flush_current_id(int patchlen, unsigned char *id, git_SHA_CTX *c)\n {\n@@ -57,7 +58,7 @@ static int scan_hunk_header(const char *p, int *p_before, int *p_after)\n \treturn 1;\n }\n \n-int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)\n+static int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)\n {\n \tstatic char line[1000];\n \tint patchlen = 0, found_next = 0;\ndiff --git a/builtin/remote-ext.c b/builtin/remote-ext.c\nindex ea71977..6ebc26d 100644\n--- a/builtin/remote-ext.c\n+++ b/builtin/remote-ext.c\n@@ -1,6 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"transport.h\"\n #include \"run-command.h\"\n+#include \"builtin.h\"\n \n /*\n  * URL syntax:\ndiff --git a/builtin/remote-fd.c b/builtin/remote-fd.c\nindex 1f2467b..bdecd3a 100644\n--- a/builtin/remote-fd.c\n+++ b/builtin/remote-fd.c\n@@ -1,5 +1,6 @@\n #include \"git-compat-util.h\"\n #include \"transport.h\"\n+#include \"builtin.h\"\n \n /*\n  * URL syntax:\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex cb26080..6faec63 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -6,6 +6,7 @@\n #include \"strbuf.h\"\n #include \"run-command.h\"\n #include \"refs.h\"\n+#include \"builtin.h\"\n \n static const char * const builtin_remote_usage[] = {\n \t\"git remote [-v | --verbose]\",\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 5de2bce..fdac49e 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -20,6 +20,7 @@\n #include \"parse-options.h\"\n #include \"unpack-trees.h\"\n #include \"cache-tree.h\"\n+#include \"builtin.h\"\n \n static const char * const git_reset_usage[] = {\n \t\"git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]\",\ndiff --git a/builtin/send-pack.c b/builtin/send-pack.c\nindex 2cd1c40..973ac66 100644\n--- a/builtin/send-pack.c\n+++ b/builtin/send-pack.c\n@@ -8,6 +8,7 @@\n #include \"send-pack.h\"\n #include \"quote.h\"\n #include \"transport.h\"\n+#include \"builtin.h\"\n \n static const char send_pack_usage[] =\n \"git send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\\n\"\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex 608590a..d3e962a 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"blob.h\"\n #include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n static char *create_temp_file(unsigned char *sha1)\n {\ndiff --git a/builtin/var.c b/builtin/var.c\nindex 0744bb8..6173e0e 100644\n--- a/builtin/var.c\n+++ b/builtin/var.c\n@@ -5,6 +5,7 @@\n  */\n #include \"cache.h\"\n #include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n static const char var_usage[] = \"git var (-l | <variable>)\";\n \ndiff --git a/daemon.c b/daemon.c\nindex 347fd0c..4c8346d 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -660,7 +660,7 @@ static void check_dead_children(void)\n static char **cld_argv;\n static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)\n {\n-\tstruct child_process cld = { 0 };\n+\tstruct child_process cld = { NULL };\n \tchar addrbuf[300] = \"REMOTE_ADDR=\", portbuf[300];\n \tchar *env[] = { addrbuf, portbuf, NULL };\n \ndiff --git a/diff.c b/diff.c\nindex 42a107c..9b3eb99 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -628,7 +628,7 @@ struct diff_words_style {\n \tconst char *newline;\n };\n \n-struct diff_words_style diff_words_styles[] = {\n+static struct diff_words_style diff_words_styles[] = {\n \t{ DIFF_WORDS_PORCELAIN, {\"+\", \"\\n\"}, {\"-\", \"\\n\"}, {\" \", \"\\n\"}, \"~\\n\" },\n \t{ DIFF_WORDS_PLAIN, {\"{+\", \"+}\"}, {\"[-\", \"-]\"}, {\"\", \"\"}, \"\\n\" },\n \t{ DIFF_WORDS_COLOR, {\"\", \"\"}, {\"\", \"\"}, {\"\", \"\"}, \"\\n\" }\ndiff --git a/fast-import.c b/fast-import.c\nindex d9f9a3f..65d65bf 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2939,7 +2939,7 @@ static void parse_ls(struct branch *b)\n {\n \tconst char *p;\n \tstruct tree_entry *root = NULL;\n-\tstruct tree_entry leaf = {0};\n+\tstruct tree_entry leaf = {NULL};\n \n \t/* ls SP (<treeish> SP)? <path> */\n \tp = command_buf.buf + strlen(\"ls \");\ndiff --git a/imap-send.c b/imap-send.c\nindex 71506a8..9adf4b9 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -1069,7 +1069,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)\n \n \tif (srvc->tunnel) {\n \t\tconst char *argv[] = { srvc->tunnel, NULL };\n-\t\tstruct child_process tunnel = {0};\n+\t\tstruct child_process tunnel = {NULL};\n \n \t\timap_info(\"Starting tunnel '%s'... \", srvc->tunnel);\n \ndiff --git a/notes-merge.c b/notes-merge.c\nindex 1467ad3..28046a9 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -359,7 +359,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,\n \tread_mmblob(&remote, p->remote);\n \n \tstatus = ll_merge(&result_buf, sha1_to_hex(p->obj), &base, NULL,\n-\t\t\t  &local, o->local_ref, &remote, o->remote_ref, 0);\n+\t\t\t  &local, o->local_ref, &remote, o->remote_ref, NULL);\n \n \tfree(base.ptr);\n \tfree(local.ptr);\ndiff --git a/parse-options.c b/parse-options.c\nindex 42b51ef..73bd28a 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -561,14 +561,14 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n \treturn PARSE_OPT_HELP;\n }\n \n-void usage_with_options(const char * const *usagestr,\n+void NORETURN usage_with_options(const char * const *usagestr,\n \t\t\tconst struct option *opts)\n {\n \tusage_with_options_internal(NULL, usagestr, opts, 0, 1);\n \texit(129);\n }\n \n-void usage_msg_opt(const char *msg,\n+void NORETURN usage_msg_opt(const char *msg,\n \t\t   const char * const *usagestr,\n \t\t   const struct option *options)\n {\ndiff --git a/replace_object.c b/replace_object.c\nindex eb59604..7c6c754 100644\n--- a/replace_object.c\n+++ b/replace_object.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"sha1-lookup.h\"\n #include \"refs.h\"\n+#include \"commit.h\"\n \n static struct replace_object {\n \tunsigned char sha1[2][20];\ndiff --git a/submodule.c b/submodule.c\nindex e9f2b19..0cb6d18 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -9,9 +9,9 @@\n #include \"refs.h\"\n #include \"string-list.h\"\n \n-struct string_list config_name_for_path;\n-struct string_list config_fetch_recurse_submodules_for_name;\n-struct string_list config_ignore_for_name;\n+static struct string_list config_name_for_path;\n+static struct string_list config_fetch_recurse_submodules_for_name;\n+static struct string_list config_ignore_for_name;\n static int config_fetch_recurse_submodules;\n \n static int add_submodule_odb(const char *path)\ndiff --git a/thread-utils.c b/thread-utils.c\nindex 589f838..2c8c1e3 100644\n--- a/thread-utils.c\n+++ b/thread-utils.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include <pthread.h>\n+#include \"thread-utils.h\"\n \n #if defined(hpux) || defined(__hpux) || defined(_hpux)\n #  include <sys/pstat.h>\ndiff --git a/trace.c b/trace.c\nindex 8390bf7..d953416 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -75,7 +75,7 @@ void trace_vprintf(const char *key, const char *fmt, va_list ap)\n \tstrbuf_release(&buf);\n }\n \n-void trace_printf_key(const char *key, const char *fmt, ...)\n+static void trace_printf_key(const char *key, const char *fmt, ...)\n {\n \tva_list ap;\n \tva_start(ap, fmt);\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 0c5b1bd..5846b55 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -76,7 +76,7 @@ static void write_constant(int fd, const char *str)\n \t\tdie_errno(\"Full write to remote helper failed\");\n }\n \n-const char *remove_ext_force(const char *url)\n+static const char *remove_ext_force(const char *url)\n {\n \tif (url) {\n \t\tconst char *colon = strchr(url, ':');\ndiff --git a/transport.c b/transport.c\nindex 0078660..f1c0781 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -192,7 +192,7 @@ static const char *rsync_url(const char *url)\n static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)\n {\n \tstruct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;\n-\tstruct ref dummy = {0}, *tail = &dummy;\n+\tstruct ref dummy = {NULL}, *tail = &dummy;\n \tstruct child_process rsync;\n \tconst char *args[5];\n \tint temp_dir_len;\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex b68ec82..500ebcf 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -16,7 +16,7 @@\n  * situation better.  See how \"git checkout\" and \"git merge\" replaces\n  * them using setup_unpack_trees_porcelain(), for example.\n  */\n-const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {\n+static const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {\n \t/* ERROR_WOULD_OVERWRITE */\n \t\"Entry '%s' would be overwritten by merge. Cannot merge.\",\n \ndiff --git a/url.c b/url.c\nindex 6a54959..3e06fd3 100644\n--- a/url.c\n+++ b/url.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"url.h\"\n \n int is_urlschemechar(int first_flag, int ch)\n {\ndiff --git a/usage.c b/usage.c\nindex ec4cf53..b5e67e3 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -46,7 +46,7 @@ void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list param\n \tdie_routine = routine;\n }\n \n-void usagef(const char *err, ...)\n+void NORETURN usagef(const char *err, ...)\n {\n \tva_list params;\n \n@@ -55,12 +55,12 @@ void usagef(const char *err, ...)\n \tva_end(params);\n }\n \n-void usage(const char *err)\n+void NORETURN usage(const char *err)\n {\n \tusagef(\"%s\", err);\n }\n \n-void die(const char *err, ...)\n+void NORETURN die(const char *err, ...)\n {\n \tva_list params;\n \n@@ -69,7 +69,7 @@ void die(const char *err, ...)\n \tva_end(params);\n }\n \n-void die_errno(const char *fmt, ...)\n+void NORETURN die_errno(const char *fmt, ...)\n {\n \tva_list params;\n \tchar fmt_with_err[1024];\n-- \n1.7.4.1.343.ga91df\n"},{"id":"163885","messageId":"4D872420.8080501@viscovery.net","threadId":"26813","inReplyTo":"1300700704-22674-2-git-send-email-bebarino@gmail.com","subject":"Re: [PATCH 2/2] Fix sparse warnings","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-03-21T10:10:40Z","receivedAt":"2011-03-21T10:10:40Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 3/21/2011 10:45, schrieb Stephen Boyd:\n> diff --git a/daemon.c b/daemon.c\n> index 347fd0c..4c8346d 100644\n> --- a/daemon.c\n> +++ b/daemon.c\n> @@ -660,7 +660,7 @@ static void check_dead_children(void)\n>  static char **cld_argv;\n>  static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)\n>  {\n> -\tstruct child_process cld = { 0 };\n> +\tstruct child_process cld = { NULL };\n\nIMO this change is not good.\n\nThe purpose of { 0} is not to initialize (only) the first member, but\nrather to serve as a visual marker that says \"We want the complete struct\nzero-initialized\".\n\n> diff --git a/fast-import.c b/fast-import.c\n> index d9f9a3f..65d65bf 100644\n> --- a/fast-import.c\n> +++ b/fast-import.c\n> @@ -2939,7 +2939,7 @@ static void parse_ls(struct branch *b)\n>  {\n>  \tconst char *p;\n>  \tstruct tree_entry *root = NULL;\n> -\tstruct tree_entry leaf = {0};\n> +\tstruct tree_entry leaf = {NULL};\n\nSame here.\n\n> diff --git a/imap-send.c b/imap-send.c\n> index 71506a8..9adf4b9 100644\n> --- a/imap-send.c\n> +++ b/imap-send.c\n> @@ -1069,7 +1069,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)\n>  \n>  \tif (srvc->tunnel) {\n>  \t\tconst char *argv[] = { srvc->tunnel, NULL };\n> -\t\tstruct child_process tunnel = {0};\n> +\t\tstruct child_process tunnel = {NULL};\n\nAnd here.\n\n> diff --git a/transport.c b/transport.c\n> index 0078660..f1c0781 100644\n> --- a/transport.c\n> +++ b/transport.c\n> @@ -192,7 +192,7 @@ static const char *rsync_url(const char *url)\n>  static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)\n>  {\n>  \tstruct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;\n> -\tstruct ref dummy = {0}, *tail = &dummy;\n> +\tstruct ref dummy = {NULL}, *tail = &dummy;\n\nAnd here.\n\n-- Hannes\n"},{"id":"163886","messageId":"4D872490.4000500@gmail.com","threadId":"26813","inReplyTo":"4D872420.8080501@viscovery.net","subject":"Re: [PATCH 2/2] Fix sparse warnings","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2011-03-21T10:12:32Z","receivedAt":"2011-03-21T10:12:32Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"On 03/21/11 03:10, Johannes Sixt wrote:\n> Am 3/21/2011 10:45, schrieb Stephen Boyd:\n>> diff --git a/daemon.c b/daemon.c\n>> index 347fd0c..4c8346d 100644\n>> --- a/daemon.c\n>> +++ b/daemon.c\n>> @@ -660,7 +660,7 @@ static void check_dead_children(void)\n>>  static char **cld_argv;\n>>  static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)\n>>  {\n>> -\tstruct child_process cld = { 0 };\n>> +\tstruct child_process cld = { NULL };\n> \n> IMO this change is not good.\n> \n> The purpose of { 0} is not to initialize (only) the first member, but\n> rather to serve as a visual marker that says \"We want the complete struct\n> zero-initialized\".\n> \n\nSure that's fine. I was iffy on that change, but decided to try to\nsilence sparse as much as possible. I'm fine with dropping those hunks.\n"},{"id":"163920","messageId":"7vsjugsb9n.fsf@alter.siamese.dyndns.org","threadId":"26813","inReplyTo":"4D872420.8080501@viscovery.net","subject":"Re: [PATCH 2/2] Fix sparse warnings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-21T16:12:36Z","receivedAt":"2011-03-21T16:12:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> Am 3/21/2011 10:45, schrieb Stephen Boyd:\n>> diff --git a/daemon.c b/daemon.c\n>> index 347fd0c..4c8346d 100644\n>> --- a/daemon.c\n>> +++ b/daemon.c\n>> @@ -660,7 +660,7 @@ static void check_dead_children(void)\n>>  static char **cld_argv;\n>>  static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)\n>>  {\n>> -\tstruct child_process cld = { 0 };\n>> +\tstruct child_process cld = { NULL };\n>\n> IMO this change is not good.\n>\n> The purpose of { 0} is not to initialize (only) the first member, but\n> rather to serve as a visual marker that says \"We want the complete struct\n> zero-initialized\".\n\nHuh?  News to me.\n\nThe first element of type const char ** is initialized to a NULL pointer\nand the rest if filled with NUL bytes either way.\n"},{"id":"163921","messageId":"7voc54sb41.fsf@alter.siamese.dyndns.org","threadId":"26813","inReplyTo":"1300700704-22674-2-git-send-email-bebarino@gmail.com","subject":"Re: [PATCH 2/2] Fix sparse warnings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-21T16:15:58Z","receivedAt":"2011-03-21T16:15:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Boyd <bebarino@gmail.com> writes:\n\n> Fix warnings from 'make check'.\n>\n> diff.c:631:25: warning: symbol 'diff_words_styles' was not declared.\n> Should it be static?\n> notes-merge.c:362:73: warning: Using plain integer as NULL pointer\n> parse-options.c:564:6: error: symbol 'usage_with_options' redeclared\n> with different type (originally declared at parse-options.h:158) -\n> different modifiers\n> parse-options.c:571:6: error: symbol 'usage_msg_opt' redeclared with\n> different type (originally declared at parse-options.h:161) - different\n> modifiers\n> ...\n\nYuck.  Could you summarize the errors by grouping them by type or\nsomething in the log?  One mega-patch we can swallow, but the log is\nunreadble.\n\n> diff --git a/builtin/clone.c b/builtin/clone.c\n> index 02547ad..53ea012 100644\n> --- a/builtin/clone.c\n> +++ b/builtin/clone.c\n> @@ -23,6 +23,7 @@\n>  #include \"branch.h\"\n>  #include \"remote.h\"\n>  #include \"run-command.h\"\n> +#include \"builtin.h\"\n\nDocumentation/CodingGuidelines suggests to move this to the top, probably\nreplacing '#include \"cache.h\"' we have there:\n\n - The first #include in C files, except in platform specific\n   compat/ implementations, should be git-compat-util.h or another\n   header file that includes it, such as cache.h or builtin.h.\n"},{"id":"163929","messageId":"7vhbawqt7o.fsf@alter.siamese.dyndns.org","threadId":"26813","inReplyTo":"1300700704-22674-1-git-send-email-bebarino@gmail.com","subject":"Re: [PATCH 1/2] Makefile: Cover more files with make check","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-21T17:27:55Z","receivedAt":"2011-03-21T17:27:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Boyd <bebarino@gmail.com> writes:\n\n> After the builtin/ move 'make check' doesn't cover the builtin/\n> directory. We could just add builtin/*.c but lets just use GIT_OBJS\n> instead so we cover future movement of the source files.\n\nThanks for being considerate and not use $(OBJECTS) that would feed sparse\na lot more crap ;-)  GIT_OBJS is sensible (and when vcs-svn graduates from\ncontrib/ status, hopefully it would be included in GIT_OBJS).\n"},{"id":"163934","messageId":"1300730506-6582-1-git-send-email-bebarino@gmail.com","threadId":"26813","inReplyTo":"7voc54sb41.fsf@alter.siamese.dyndns.org","subject":"[PATCHv2 2/2] Fix sparse warnings","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2011-03-21T18:01:46Z","receivedAt":"2011-03-21T18:01:46Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Fix warnings from 'make check'.\n\nbuiltin/clone.c:364:5: warning: symbol 'cmd_clone' was not declared.\nShould it be static?\nbuiltin/fetch-pack.c:797:5: warning: symbol 'cmd_fetch_pack' was not\ndeclared. Should it be static?\nbuiltin/fmt-merge-msg.c:34:6: warning: symbol 'init_src_data' was not\ndeclared. Should it be static?\nbuiltin/hash-object.c:78:5: warning: symbol 'cmd_hash_object' was not\ndeclared. Should it be static?\nbuiltin/index-pack.c:210:13: error: symbol 'bad_object' redeclared with\ndifferent type (originally declared at builtin/index-pack.c:207) -\ndifferent modifiers\nbuiltin/merge-index.c:69:5: warning: symbol 'cmd_merge_index' was not\ndeclared. Should it be static?\nbuiltin/merge-recursive.c:22:5: warning: symbol 'cmd_merge_recursive'\nwas not declared. Should it be static?\nbuiltin/merge-tree.c:341:5: warning: symbol 'cmd_merge_tree' was not\ndeclared. Should it be static?\nbuiltin/mktag.c:156:5: warning: symbol 'cmd_mktag' was not declared.\nShould it be static?\nbuiltin/notes.c:426:5: warning: symbol 'notes_copy_from_stdin' was not\ndeclared. Should it be static?\nbuiltin/notes.c:822:64: warning: Using plain integer as NULL pointer\nbuiltin/pack-redundant.c:596:5: warning: symbol 'cmd_pack_redundant' was\nnot declared. Should it be static?\nbuiltin/pack-refs.c:10:5: warning: symbol 'cmd_pack_refs' was not\ndeclared. Should it be static?\nbuiltin/patch-id.c:60:5: warning: symbol 'get_one_patchid' was not\ndeclared. Should it be static?\nbuiltin/patch-id.c:149:5: warning: symbol 'cmd_patch_id' was not\ndeclared. Should it be static?\nbuiltin/remote.c:1512:5: warning: symbol 'cmd_remote' was not declared.\nShould it be static?\nbuiltin/remote-ext.c:240:5: warning: symbol 'cmd_remote_ext' was not\ndeclared. Should it be static?\nbuiltin/remote-fd.c:53:5: warning: symbol 'cmd_remote_fd' was not\ndeclared. Should it be static?\nbuiltin/reset.c:236:5: warning: symbol 'cmd_reset' was not declared.\nShould it be static?\nbuiltin/send-pack.c:384:5: warning: symbol 'cmd_send_pack' was not\ndeclared. Should it be static?\nbuiltin/unpack-file.c:25:5: warning: symbol 'cmd_unpack_file' was not\ndeclared. Should it be static?\nbuiltin/var.c:75:5: warning: symbol 'cmd_var' was not declared. Should\nit be static?\n\nsubmodule.c:12:20: warning: symbol 'config_name_for_path' was not\ndeclared. Should it be static?\ndiff.c:631:25: warning: symbol 'diff_words_styles' was not declared.\nShould it be static?\nreplace_object.c:92:21: warning: symbol 'lookup_replace_object' was not\ndeclared. Should it be static?\nsubmodule.c:13:20: warning: symbol\n'config_fetch_recurse_submodules_for_name' was not declared. Should it\nbe static?\nsubmodule.c:14:20: warning: symbol 'config_ignore_for_name' was not\ndeclared. Should it be static?\ntrace.c:78:6: warning: symbol 'trace_printf_key' was not declared.\nShould it be static?\ntransport.c:195:29: warning: Using plain integer as NULL pointer\ntransport-helper.c:79:12: warning: symbol 'remove_ext_force' was not\ndeclared. Should it be static?\nunpack-trees.c:19:12: warning: symbol 'unpack_plumbing_errors' was not\ndeclared. Should it be static?\nurl.c:3:5: warning: symbol 'is_urlschemechar' was not declared. Should\nit be static?\nurl.c:18:5: warning: symbol 'is_url' was not declared. Should it be\nstatic?\nurl.c:104:6: warning: symbol 'url_decode' was not declared. Should it be\nstatic?\nurl.c:117:6: warning: symbol 'url_decode_parameter_name' was not\ndeclared. Should it be static?\nurl.c:123:6: warning: symbol 'url_decode_parameter_value' was not\ndeclared. Should it be static?\nurl.c:129:6: warning: symbol 'end_url_with_slash' was not declared.\nShould it be static?\nurl.c:136:6: warning: symbol 'str_end_url_with_slash' was not declared.\nShould it be static?\nthread-utils.c:21:5: warning: symbol 'online_cpus' was not declared.\nShould it be static?\nthread-utils.c:48:5: warning: symbol 'init_recursive_mutex' was not\ndeclared. Should it be static?\n\nparse-options.c:564:6: error: symbol 'usage_with_options' redeclared\nwith different type (originally declared at parse-options.h:158) -\ndifferent modifiers\nparse-options.c:571:6: error: symbol 'usage_msg_opt' redeclared with\ndifferent type (originally declared at parse-options.h:161) - different\nmodifiers\nusage.c:49:6: error: symbol 'usagef' redeclared with different type\n(originally declared at git-compat-util.h:239) - different modifiers\nusage.c:58:6: error: symbol 'usage' redeclared with different type\n(originally declared at git-compat-util.h:238) - different modifiers\nusage.c:63:6: error: symbol 'die' redeclared with different type\n(originally declared at git-compat-util.h:240) - different modifiers\nusage.c:72:6: error: symbol 'die_errno' redeclared with different type\n(originally declared at git-compat-util.h:241) - different modifiers\n\ndaemon.c:663:38: warning: Using plain integer as NULL pointer\nfast-import.c:2942:35: warning: Using plain integer as NULL pointer\nimap-send.c:1072:48: warning: Using plain integer as NULL pointer\nnotes-merge.c:362:73: warning: Using plain integer as NULL pointer\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\nOn 03/21/11 09:15, Junio C Hamano wrote:\n> \n> Yuck.  Could you summarize the errors by grouping them by type or\n> something in the log?  One mega-patch we can swallow, but the log is\n> unreadble.\n> \n\nSure. Both comments addressed.\n\n builtin/clone.c           |    2 +-\n builtin/fetch-pack.c      |    2 +-\n builtin/fmt-merge-msg.c   |    2 +-\n builtin/hash-object.c     |    2 +-\n builtin/index-pack.c      |    2 +-\n builtin/merge-index.c     |    2 +-\n builtin/merge-recursive.c |    2 +-\n builtin/merge-tree.c      |    2 +-\n builtin/mktag.c           |    2 +-\n builtin/notes.c           |    4 ++--\n builtin/pack-redundant.c  |    2 +-\n builtin/pack-refs.c       |    2 +-\n builtin/patch-id.c        |    4 ++--\n builtin/remote-ext.c      |    2 +-\n builtin/remote-fd.c       |    1 +\n builtin/remote.c          |    2 +-\n builtin/reset.c           |    2 +-\n builtin/send-pack.c       |    2 +-\n builtin/unpack-file.c     |    2 +-\n builtin/var.c             |    2 +-\n daemon.c                  |    2 +-\n diff.c                    |    2 +-\n fast-import.c             |    2 +-\n imap-send.c               |    2 +-\n notes-merge.c             |    2 +-\n parse-options.c           |    4 ++--\n replace_object.c          |    1 +\n submodule.c               |    6 +++---\n thread-utils.c            |    1 +\n trace.c                   |    2 +-\n transport-helper.c        |    2 +-\n transport.c               |    2 +-\n unpack-trees.c            |    2 +-\n url.c                     |    1 +\n usage.c                   |    8 ++++----\n 35 files changed, 43 insertions(+), 39 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 02547ad..c6e10bb 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -8,7 +8,7 @@\n  * Clone a repository into a different directory that does not yet exist.\n  */\n \n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"parse-options.h\"\n #include \"fetch-pack.h\"\n #include \"refs.h\"\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex 272bc38..ef39862 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"refs.h\"\n #include \"pkt-line.h\"\n #include \"commit.h\"\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 5189b16..7581632 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -31,7 +31,7 @@ struct src_data {\n \tint head_status;\n };\n \n-void init_src_data(struct src_data *data)\n+static void init_src_data(struct src_data *data)\n {\n \tdata->branch.strdup_strings = 1;\n \tdata->tag.strdup_strings = 1;\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex c90acdd..b96f46a 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -4,7 +4,7 @@\n  * Copyright (C) Linus Torvalds, 2005\n  * Copyright (C) Junio C Hamano, 2005\n  */\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"blob.h\"\n #include \"quote.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex c7e600d..5a67c81 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -207,7 +207,7 @@ static void parse_pack_header(void)\n static NORETURN void bad_object(unsigned long offset, const char *format,\n \t\t       ...) __attribute__((format (printf, 2, 3)));\n \n-static void bad_object(unsigned long offset, const char *format, ...)\n+static NORETURN void bad_object(unsigned long offset, const char *format, ...)\n {\n \tva_list params;\n \tchar buf[1024];\ndiff --git a/builtin/merge-index.c b/builtin/merge-index.c\nindex 2c4cf5e..adc2a6d 100644\n--- a/builtin/merge-index.c\n+++ b/builtin/merge-index.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"run-command.h\"\n #include \"exec_cmd.h\"\n \ndiff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c\nindex c33091b..3a64f5d 100644\n--- a/builtin/merge-recursive.c\n+++ b/builtin/merge-recursive.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"merge-recursive.h\"\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 9b25ddc..1991742 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"tree-walk.h\"\n #include \"xdiff-interface.h\"\n #include \"blob.h\"\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 1cb0f3f..9148cc0 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"tag.h\"\n #include \"exec_cmd.h\"\n \ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 0aab150..a0f310b 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -423,7 +423,7 @@ void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c)\n \tfree(c);\n }\n \n-int notes_copy_from_stdin(int force, const char *rewrite_cmd)\n+static int notes_copy_from_stdin(int force, const char *rewrite_cmd)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct notes_rewrite_cfg *c = NULL;\n@@ -819,7 +819,7 @@ static int merge_commit(struct notes_merge_options *o)\n \tt = xcalloc(1, sizeof(struct notes_tree));\n \tinit_notes(t, \"NOTES_MERGE_PARTIAL\", combine_notes_overwrite, 0);\n \n-\to->local_ref = resolve_ref(\"NOTES_MERGE_REF\", sha1, 0, 0);\n+\to->local_ref = resolve_ref(\"NOTES_MERGE_REF\", sha1, 0, NULL);\n \tif (!o->local_ref)\n \t\tdie(\"Failed to resolve NOTES_MERGE_REF\");\n \ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex 41e1615..760b377 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -6,8 +6,8 @@\n *\n */\n \n-#include \"cache.h\"\n #include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n #define BLKSIZE 512\n \ndiff --git a/builtin/pack-refs.c b/builtin/pack-refs.c\nindex 091860b..39a9d89 100644\n--- a/builtin/pack-refs.c\n+++ b/builtin/pack-refs.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"parse-options.h\"\n #include \"pack-refs.h\"\n \ndiff --git a/builtin/patch-id.c b/builtin/patch-id.c\nindex 49a0472..f5966ae 100644\n--- a/builtin/patch-id.c\n+++ b/builtin/patch-id.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"exec_cmd.h\"\n \n static void flush_current_id(int patchlen, unsigned char *id, git_SHA_CTX *c)\n@@ -57,7 +57,7 @@ static int scan_hunk_header(const char *p, int *p_before, int *p_after)\n \treturn 1;\n }\n \n-int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)\n+static int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)\n {\n \tstatic char line[1000];\n \tint patchlen = 0, found_next = 0;\ndiff --git a/builtin/remote-ext.c b/builtin/remote-ext.c\nindex ea71977..155e609 100644\n--- a/builtin/remote-ext.c\n+++ b/builtin/remote-ext.c\n@@ -1,4 +1,4 @@\n-#include \"git-compat-util.h\"\n+#include \"builtin.h\"\n #include \"transport.h\"\n #include \"run-command.h\"\n \ndiff --git a/builtin/remote-fd.c b/builtin/remote-fd.c\nindex 1f2467b..b11b211 100644\n--- a/builtin/remote-fd.c\n+++ b/builtin/remote-fd.c\n@@ -1,3 +1,4 @@\n+#include \"builtin.h\"\n #include \"git-compat-util.h\"\n #include \"transport.h\"\n \ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex cb26080..b71ecd2 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"parse-options.h\"\n #include \"transport.h\"\n #include \"remote.h\"\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 5de2bce..eb5f98c 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -7,7 +7,7 @@\n  *\n  * Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano\n  */\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"tag.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/builtin/send-pack.c b/builtin/send-pack.c\nindex 2cd1c40..8b0911c 100644\n--- a/builtin/send-pack.c\n+++ b/builtin/send-pack.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n #include \"pkt-line.h\"\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex 608590a..c905d80 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"blob.h\"\n #include \"exec_cmd.h\"\n \ndiff --git a/builtin/var.c b/builtin/var.c\nindex 0744bb8..1787771 100644\n--- a/builtin/var.c\n+++ b/builtin/var.c\n@@ -3,7 +3,7 @@\n  *\n  * Copyright (C) Eric Biederman, 2005\n  */\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"exec_cmd.h\"\n \n static const char var_usage[] = \"git var (-l | <variable>)\";\ndiff --git a/daemon.c b/daemon.c\nindex 347fd0c..4c8346d 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -660,7 +660,7 @@ static void check_dead_children(void)\n static char **cld_argv;\n static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)\n {\n-\tstruct child_process cld = { 0 };\n+\tstruct child_process cld = { NULL };\n \tchar addrbuf[300] = \"REMOTE_ADDR=\", portbuf[300];\n \tchar *env[] = { addrbuf, portbuf, NULL };\n \ndiff --git a/diff.c b/diff.c\nindex 42a107c..9b3eb99 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -628,7 +628,7 @@ struct diff_words_style {\n \tconst char *newline;\n };\n \n-struct diff_words_style diff_words_styles[] = {\n+static struct diff_words_style diff_words_styles[] = {\n \t{ DIFF_WORDS_PORCELAIN, {\"+\", \"\\n\"}, {\"-\", \"\\n\"}, {\" \", \"\\n\"}, \"~\\n\" },\n \t{ DIFF_WORDS_PLAIN, {\"{+\", \"+}\"}, {\"[-\", \"-]\"}, {\"\", \"\"}, \"\\n\" },\n \t{ DIFF_WORDS_COLOR, {\"\", \"\"}, {\"\", \"\"}, {\"\", \"\"}, \"\\n\" }\ndiff --git a/fast-import.c b/fast-import.c\nindex d9f9a3f..65d65bf 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2939,7 +2939,7 @@ static void parse_ls(struct branch *b)\n {\n \tconst char *p;\n \tstruct tree_entry *root = NULL;\n-\tstruct tree_entry leaf = {0};\n+\tstruct tree_entry leaf = {NULL};\n \n \t/* ls SP (<treeish> SP)? <path> */\n \tp = command_buf.buf + strlen(\"ls \");\ndiff --git a/imap-send.c b/imap-send.c\nindex 71506a8..9adf4b9 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -1069,7 +1069,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)\n \n \tif (srvc->tunnel) {\n \t\tconst char *argv[] = { srvc->tunnel, NULL };\n-\t\tstruct child_process tunnel = {0};\n+\t\tstruct child_process tunnel = {NULL};\n \n \t\timap_info(\"Starting tunnel '%s'... \", srvc->tunnel);\n \ndiff --git a/notes-merge.c b/notes-merge.c\nindex 1467ad3..28046a9 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -359,7 +359,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,\n \tread_mmblob(&remote, p->remote);\n \n \tstatus = ll_merge(&result_buf, sha1_to_hex(p->obj), &base, NULL,\n-\t\t\t  &local, o->local_ref, &remote, o->remote_ref, 0);\n+\t\t\t  &local, o->local_ref, &remote, o->remote_ref, NULL);\n \n \tfree(base.ptr);\n \tfree(local.ptr);\ndiff --git a/parse-options.c b/parse-options.c\nindex 42b51ef..73bd28a 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -561,14 +561,14 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n \treturn PARSE_OPT_HELP;\n }\n \n-void usage_with_options(const char * const *usagestr,\n+void NORETURN usage_with_options(const char * const *usagestr,\n \t\t\tconst struct option *opts)\n {\n \tusage_with_options_internal(NULL, usagestr, opts, 0, 1);\n \texit(129);\n }\n \n-void usage_msg_opt(const char *msg,\n+void NORETURN usage_msg_opt(const char *msg,\n \t\t   const char * const *usagestr,\n \t\t   const struct option *options)\n {\ndiff --git a/replace_object.c b/replace_object.c\nindex eb59604..7c6c754 100644\n--- a/replace_object.c\n+++ b/replace_object.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"sha1-lookup.h\"\n #include \"refs.h\"\n+#include \"commit.h\"\n \n static struct replace_object {\n \tunsigned char sha1[2][20];\ndiff --git a/submodule.c b/submodule.c\nindex e9f2b19..0cb6d18 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -9,9 +9,9 @@\n #include \"refs.h\"\n #include \"string-list.h\"\n \n-struct string_list config_name_for_path;\n-struct string_list config_fetch_recurse_submodules_for_name;\n-struct string_list config_ignore_for_name;\n+static struct string_list config_name_for_path;\n+static struct string_list config_fetch_recurse_submodules_for_name;\n+static struct string_list config_ignore_for_name;\n static int config_fetch_recurse_submodules;\n \n static int add_submodule_odb(const char *path)\ndiff --git a/thread-utils.c b/thread-utils.c\nindex 589f838..2c8c1e3 100644\n--- a/thread-utils.c\n+++ b/thread-utils.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include <pthread.h>\n+#include \"thread-utils.h\"\n \n #if defined(hpux) || defined(__hpux) || defined(_hpux)\n #  include <sys/pstat.h>\ndiff --git a/trace.c b/trace.c\nindex 8390bf7..d953416 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -75,7 +75,7 @@ void trace_vprintf(const char *key, const char *fmt, va_list ap)\n \tstrbuf_release(&buf);\n }\n \n-void trace_printf_key(const char *key, const char *fmt, ...)\n+static void trace_printf_key(const char *key, const char *fmt, ...)\n {\n \tva_list ap;\n \tva_start(ap, fmt);\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 0c5b1bd..5846b55 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -76,7 +76,7 @@ static void write_constant(int fd, const char *str)\n \t\tdie_errno(\"Full write to remote helper failed\");\n }\n \n-const char *remove_ext_force(const char *url)\n+static const char *remove_ext_force(const char *url)\n {\n \tif (url) {\n \t\tconst char *colon = strchr(url, ':');\ndiff --git a/transport.c b/transport.c\nindex 0078660..f1c0781 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -192,7 +192,7 @@ static const char *rsync_url(const char *url)\n static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)\n {\n \tstruct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;\n-\tstruct ref dummy = {0}, *tail = &dummy;\n+\tstruct ref dummy = {NULL}, *tail = &dummy;\n \tstruct child_process rsync;\n \tconst char *args[5];\n \tint temp_dir_len;\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex b68ec82..500ebcf 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -16,7 +16,7 @@\n  * situation better.  See how \"git checkout\" and \"git merge\" replaces\n  * them using setup_unpack_trees_porcelain(), for example.\n  */\n-const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {\n+static const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {\n \t/* ERROR_WOULD_OVERWRITE */\n \t\"Entry '%s' would be overwritten by merge. Cannot merge.\",\n \ndiff --git a/url.c b/url.c\nindex 6a54959..3e06fd3 100644\n--- a/url.c\n+++ b/url.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"url.h\"\n \n int is_urlschemechar(int first_flag, int ch)\n {\ndiff --git a/usage.c b/usage.c\nindex ec4cf53..b5e67e3 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -46,7 +46,7 @@ void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list param\n \tdie_routine = routine;\n }\n \n-void usagef(const char *err, ...)\n+void NORETURN usagef(const char *err, ...)\n {\n \tva_list params;\n \n@@ -55,12 +55,12 @@ void usagef(const char *err, ...)\n \tva_end(params);\n }\n \n-void usage(const char *err)\n+void NORETURN usage(const char *err)\n {\n \tusagef(\"%s\", err);\n }\n \n-void die(const char *err, ...)\n+void NORETURN die(const char *err, ...)\n {\n \tva_list params;\n \n@@ -69,7 +69,7 @@ void die(const char *err, ...)\n \tva_end(params);\n }\n \n-void die_errno(const char *fmt, ...)\n+void NORETURN die_errno(const char *fmt, ...)\n {\n \tva_list params;\n \tchar fmt_with_err[1024];\n-- \n1.7.4.1.343.ga91df\n"},{"id":"163958","messageId":"7vzkoop912.fsf@alter.siamese.dyndns.org","threadId":"26813","inReplyTo":"1300730506-6582-1-git-send-email-bebarino@gmail.com","subject":"Re: [PATCHv2 2/2] Fix sparse warnings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-21T19:29:13Z","receivedAt":"2011-03-21T19:29:13Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Boyd <bebarino@gmail.com> writes:\n\n> Fix warnings from 'make check'.\n> ...\n> Signed-off-by: Stephen Boyd <bebarino@gmail.com>\n> ---\n>\n> On 03/21/11 09:15, Junio C Hamano wrote:\n>> \n>> Yuck.  Could you summarize the errors by grouping them by type or\n>> something in the log?  One mega-patch we can swallow, but the log is\n>> unreadble.\n>\n> Sure. Both comments addressed.\n\nStill yeek...\n\nWhat I meant was more like at the minimum:\n\n - \"warning: symbol 'x' was not declared. Should it be static?\"\n   builtin/clone.c:365, builtin/fetch-pack.c:797, ...\n\n - \"error: symbol 'x' redeclared with different type'\n   parse-options.c:564, ...\n\nor much more preferably:\n\n - These files use symbols without declaring, because they do not include\n   \"builtin.h\":\n\n    builtin/clone.c (cmd_clone), builtin/fetch-pack.c (cmd_fetch_pack), ...\n\n - These files define extern symbols without declaring, and they can be\n   file scope static:\n\n    builtin/fmt-merge-msg.c (init_src_data), ...\n\n - These callsites pass literal integer 0 where they mean to pass a NULL\n   pointer:\n\n   builtin/notes.c (resolve_ref), ...\n\nThe patch text itself look more or less Ok, but I see you have builtin.h\nnot as the first include in builtin/pack-redundant.c.\n\nThanks.\n"},{"id":"163989","messageId":"7vd3lknnjy.fsf@alter.siamese.dyndns.org","threadId":"26813","inReplyTo":"7vzkoop912.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv2 2/2] Fix sparse warnings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-21T21:58:25Z","receivedAt":"2011-03-21T21:58:25Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Still yeek...\n>\n> What I meant was more like at the minimum:\n> ...\n> or much more preferably:\n>\n>  - These files use symbols without declaring, because they do not include\n>    \"builtin.h\":\n>\n>     builtin/clone.c (cmd_clone), builtin/fetch-pack.c (cmd_fetch_pack), ...\n>\n>  - These files define extern symbols without declaring, and they can be\n>    file scope static:\n>\n>     builtin/fmt-merge-msg.c (init_src_data), ...\n>\n>  - These callsites pass literal integer 0 where they mean to pass a NULL\n>    pointer:\n>\n>    builtin/notes.c (resolve_ref), ...\n>\n> The patch text itself look more or less Ok, but I see you have builtin.h\n> not as the first include in builtin/pack-redundant.c.\n>\n> Thanks.\n\nI spotted these two.  thread-utils.h already includes pthread.h, and\nbuiltin.h should come before (though technically exec_cmd.h does not\ndepend on any external types, so this is just a conformity issue, not\ncorrectness one).\n\nAgain, thanks.\n\n builtin/pack-redundant.c |    2 +-\n thread-utils.c           |    1 -\n 2 files changed, 1 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex 760b377..a15e366 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -6,8 +6,8 @@\n *\n */\n \n-#include \"exec_cmd.h\"\n #include \"builtin.h\"\n+#include \"exec_cmd.h\"\n \n #define BLKSIZE 512\n \ndiff --git a/thread-utils.c b/thread-utils.c\nindex 2c8c1e3..7f4b76a 100644\n--- a/thread-utils.c\n+++ b/thread-utils.c\n@@ -1,5 +1,4 @@\n #include \"cache.h\"\n-#include <pthread.h>\n #include \"thread-utils.h\"\n \n #if defined(hpux) || defined(__hpux) || defined(_hpux)\n"},{"id":"163991","messageId":"AANLkTinYCqK6zm17O_HedOFtbN6VRhYQbFj-YNk+JrV1@mail.gmail.com","threadId":"26813","inReplyTo":"7vd3lknnjy.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv2 2/2] Fix sparse warnings","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2011-03-21T22:04:32Z","receivedAt":"2011-03-21T22:04:32Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"On Mon, Mar 21, 2011 at 2:58 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Still yeek...\n>>\n>> What I meant was more like at the minimum:\n>> ...\n>> or much more preferably:\n>>\n>>  - These files use symbols without declaring, because they do not include\n>>    \"builtin.h\":\n>>\n>>     builtin/clone.c (cmd_clone), builtin/fetch-pack.c (cmd_fetch_pack), ...\n>>\n>>  - These files define extern symbols without declaring, and they can be\n>>    file scope static:\n>>\n>>     builtin/fmt-merge-msg.c (init_src_data), ...\n>>\n>>  - These callsites pass literal integer 0 where they mean to pass a NULL\n>>    pointer:\n>>\n>>    builtin/notes.c (resolve_ref), ...\n>>\n>> The patch text itself look more or less Ok, but I see you have builtin.h\n>> not as the first include in builtin/pack-redundant.c.\n>>\n\nAh ok, I can do that.\n\n>\n> I spotted these two.  thread-utils.h already includes pthread.h, and\n> builtin.h should come before (though technically exec_cmd.h does not\n> depend on any external types, so this is just a conformity issue, not\n> correctness one).\n>\n> Again, thanks.\n>\n>  builtin/pack-redundant.c |    2 +-\n>  thread-utils.c           |    1 -\n>  2 files changed, 1 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\n> index 760b377..a15e366 100644\n> --- a/builtin/pack-redundant.c\n> +++ b/builtin/pack-redundant.c\n> @@ -6,8 +6,8 @@\n>  *\n>  */\n>\n> -#include \"exec_cmd.h\"\n>  #include \"builtin.h\"\n> +#include \"exec_cmd.h\"\n>\n>  #define BLKSIZE 512\n>\n> diff --git a/thread-utils.c b/thread-utils.c\n> index 2c8c1e3..7f4b76a 100644\n> --- a/thread-utils.c\n> +++ b/thread-utils.c\n> @@ -1,5 +1,4 @@\n>  #include \"cache.h\"\n> -#include <pthread.h>\n>  #include \"thread-utils.h\"\n>\n>  #if defined(hpux) || defined(__hpux) || defined(_hpux)\n>\n\nOk, I'll squash these in and resend tonight when I get home.\n\nAlso, I don't think exec_cmd.h is actually used in some of the builtin\nC files (due to some setup fallouts) so I think we can probably just\nremove the exec_cmd.h includes if they're within contex and unused.\nI'll do that next round.\n"},{"id":"164017","messageId":"1300780265-5698-1-git-send-email-bebarino@gmail.com","threadId":"26813","inReplyTo":"7vzkoop912.fsf@alter.siamese.dyndns.org","subject":"[PATCHv3 2/2] Fix sparse warnings","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2011-03-22T07:51:05Z","receivedAt":"2011-03-22T07:51:05Z","isPatch":false,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Fix warnings from 'make check'.\n\nThese files don't include 'builtin.h' causing sparse to complain that\ncmd_* isn't declared:\n\nbuiltin/clone.c:364, builtin/fetch-pack.c:797,\nbuiltin/fmt-merge-msg.c:34, builtin/hash-object.c:78,\nbuiltin/merge-index.c:69, builtin/merge-recursive.c:22\nbuiltin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426\nbuiltin/notes.c:822, builtin/pack-redundant.c:596,\nbuiltin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149,\nbuiltin/remote.c:1512, builtin/remote-ext.c:240, builtin/remote-fd.c:53,\nbuiltin/reset.c:236, builtin/send-pack.c:384, builtin/unpack-file.c:25,\nbuiltin/var.c:75\n\nThese files have symbols which should be marked static since they're\nonly file scope:\n\nsubmodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13,\nsubmodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79,\nunpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123,\nurl.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48,\n\nThese files redeclare symbols to be different types:\n\nbuiltin/index-pack.c:210, parse-options.c:564, parse-options.c:571,\nusage.c:49, usage.c:58, usage.c:63, usage.c:72,\n\nThese files use a literal integer 0 when they really should use a NULL\npointer:\n\ndaemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362\n\nWhen we're in the area try to cleanup some unused #includes in builtin\nfiles (mostly exec_cmdh.h).\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\nSquashed in Junio's fixup and reworded commit message. Plus\nremoved some of the exec_cmd.h usages and a stray blob.h include.\n\n builtin/clone.c           |    2 +-\n builtin/fetch-pack.c      |    2 +-\n builtin/fmt-merge-msg.c   |    2 +-\n builtin/hash-object.c     |    2 +-\n builtin/index-pack.c      |    2 +-\n builtin/merge-index.c     |    3 +--\n builtin/merge-recursive.c |    2 +-\n builtin/merge-tree.c      |    2 +-\n builtin/mktag.c           |    3 +--\n builtin/notes.c           |    4 ++--\n builtin/pack-redundant.c  |    3 +--\n builtin/pack-refs.c       |    2 +-\n builtin/patch-id.c        |    5 ++---\n builtin/remote-ext.c      |    1 +\n builtin/remote-fd.c       |    1 +\n builtin/remote.c          |    2 +-\n builtin/reset.c           |    2 +-\n builtin/send-pack.c       |    2 +-\n builtin/unpack-file.c     |    4 +---\n builtin/var.c             |    3 +--\n daemon.c                  |    2 +-\n diff.c                    |    2 +-\n fast-import.c             |    2 +-\n imap-send.c               |    2 +-\n notes-merge.c             |    2 +-\n parse-options.c           |    4 ++--\n replace_object.c          |    1 +\n submodule.c               |    6 +++---\n thread-utils.c            |    2 +-\n trace.c                   |    2 +-\n transport-helper.c        |    2 +-\n transport.c               |    2 +-\n unpack-trees.c            |    2 +-\n url.c                     |    1 +\n usage.c                   |    8 ++++----\n 35 files changed, 43 insertions(+), 46 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 02547ad..c6e10bb 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -8,7 +8,7 @@\n  * Clone a repository into a different directory that does not yet exist.\n  */\n \n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"parse-options.h\"\n #include \"fetch-pack.h\"\n #include \"refs.h\"\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex 272bc38..ef39862 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"refs.h\"\n #include \"pkt-line.h\"\n #include \"commit.h\"\ndiff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c\nindex 5189b16..7581632 100644\n--- a/builtin/fmt-merge-msg.c\n+++ b/builtin/fmt-merge-msg.c\n@@ -31,7 +31,7 @@ struct src_data {\n \tint head_status;\n };\n \n-void init_src_data(struct src_data *data)\n+static void init_src_data(struct src_data *data)\n {\n \tdata->branch.strdup_strings = 1;\n \tdata->tag.strdup_strings = 1;\ndiff --git a/builtin/hash-object.c b/builtin/hash-object.c\nindex c90acdd..b96f46a 100644\n--- a/builtin/hash-object.c\n+++ b/builtin/hash-object.c\n@@ -4,7 +4,7 @@\n  * Copyright (C) Linus Torvalds, 2005\n  * Copyright (C) Junio C Hamano, 2005\n  */\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"blob.h\"\n #include \"quote.h\"\n #include \"parse-options.h\"\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex c7e600d..5a67c81 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -207,7 +207,7 @@ static void parse_pack_header(void)\n static NORETURN void bad_object(unsigned long offset, const char *format,\n \t\t       ...) __attribute__((format (printf, 2, 3)));\n \n-static void bad_object(unsigned long offset, const char *format, ...)\n+static NORETURN void bad_object(unsigned long offset, const char *format, ...)\n {\n \tva_list params;\n \tchar buf[1024];\ndiff --git a/builtin/merge-index.c b/builtin/merge-index.c\nindex 2c4cf5e..2338832 100644\n--- a/builtin/merge-index.c\n+++ b/builtin/merge-index.c\n@@ -1,6 +1,5 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"run-command.h\"\n-#include \"exec_cmd.h\"\n \n static const char *pgm;\n static int one_shot, quiet;\ndiff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c\nindex c33091b..3a64f5d 100644\n--- a/builtin/merge-recursive.c\n+++ b/builtin/merge-recursive.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"commit.h\"\n #include \"tag.h\"\n #include \"merge-recursive.h\"\ndiff --git a/builtin/merge-tree.c b/builtin/merge-tree.c\nindex 9b25ddc..1991742 100644\n--- a/builtin/merge-tree.c\n+++ b/builtin/merge-tree.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"tree-walk.h\"\n #include \"xdiff-interface.h\"\n #include \"blob.h\"\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 1cb0f3f..d0ccbb2 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -1,6 +1,5 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"tag.h\"\n-#include \"exec_cmd.h\"\n \n /*\n  * A signature file has a very simple fixed format: four lines\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 0aab150..a0f310b 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -423,7 +423,7 @@ void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c)\n \tfree(c);\n }\n \n-int notes_copy_from_stdin(int force, const char *rewrite_cmd)\n+static int notes_copy_from_stdin(int force, const char *rewrite_cmd)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct notes_rewrite_cfg *c = NULL;\n@@ -819,7 +819,7 @@ static int merge_commit(struct notes_merge_options *o)\n \tt = xcalloc(1, sizeof(struct notes_tree));\n \tinit_notes(t, \"NOTES_MERGE_PARTIAL\", combine_notes_overwrite, 0);\n \n-\to->local_ref = resolve_ref(\"NOTES_MERGE_REF\", sha1, 0, 0);\n+\to->local_ref = resolve_ref(\"NOTES_MERGE_REF\", sha1, 0, NULL);\n \tif (!o->local_ref)\n \t\tdie(\"Failed to resolve NOTES_MERGE_REF\");\n \ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex 41e1615..f5c6afc 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -6,8 +6,7 @@\n *\n */\n \n-#include \"cache.h\"\n-#include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n #define BLKSIZE 512\n \ndiff --git a/builtin/pack-refs.c b/builtin/pack-refs.c\nindex 091860b..39a9d89 100644\n--- a/builtin/pack-refs.c\n+++ b/builtin/pack-refs.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"parse-options.h\"\n #include \"pack-refs.h\"\n \ndiff --git a/builtin/patch-id.c b/builtin/patch-id.c\nindex 49a0472..f821eb3 100644\n--- a/builtin/patch-id.c\n+++ b/builtin/patch-id.c\n@@ -1,5 +1,4 @@\n-#include \"cache.h\"\n-#include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n static void flush_current_id(int patchlen, unsigned char *id, git_SHA_CTX *c)\n {\n@@ -57,7 +56,7 @@ static int scan_hunk_header(const char *p, int *p_before, int *p_after)\n \treturn 1;\n }\n \n-int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)\n+static int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)\n {\n \tstatic char line[1000];\n \tint patchlen = 0, found_next = 0;\ndiff --git a/builtin/remote-ext.c b/builtin/remote-ext.c\nindex ea71977..23e84e7 100644\n--- a/builtin/remote-ext.c\n+++ b/builtin/remote-ext.c\n@@ -1,3 +1,4 @@\n+#include \"builtin.h\"\n #include \"git-compat-util.h\"\n #include \"transport.h\"\n #include \"run-command.h\"\ndiff --git a/builtin/remote-fd.c b/builtin/remote-fd.c\nindex 1f2467b..b11b211 100644\n--- a/builtin/remote-fd.c\n+++ b/builtin/remote-fd.c\n@@ -1,3 +1,4 @@\n+#include \"builtin.h\"\n #include \"git-compat-util.h\"\n #include \"transport.h\"\n \ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex cb26080..b71ecd2 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"parse-options.h\"\n #include \"transport.h\"\n #include \"remote.h\"\ndiff --git a/builtin/reset.c b/builtin/reset.c\nindex 5de2bce..eb5f98c 100644\n--- a/builtin/reset.c\n+++ b/builtin/reset.c\n@@ -7,7 +7,7 @@\n  *\n  * Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano\n  */\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"tag.h\"\n #include \"object.h\"\n #include \"commit.h\"\ndiff --git a/builtin/send-pack.c b/builtin/send-pack.c\nindex 2cd1c40..8b0911c 100644\n--- a/builtin/send-pack.c\n+++ b/builtin/send-pack.c\n@@ -1,4 +1,4 @@\n-#include \"cache.h\"\n+#include \"builtin.h\"\n #include \"commit.h\"\n #include \"refs.h\"\n #include \"pkt-line.h\"\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex 608590a..1920029 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -1,6 +1,4 @@\n-#include \"cache.h\"\n-#include \"blob.h\"\n-#include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n static char *create_temp_file(unsigned char *sha1)\n {\ndiff --git a/builtin/var.c b/builtin/var.c\nindex 0744bb8..99d068a 100644\n--- a/builtin/var.c\n+++ b/builtin/var.c\n@@ -3,8 +3,7 @@\n  *\n  * Copyright (C) Eric Biederman, 2005\n  */\n-#include \"cache.h\"\n-#include \"exec_cmd.h\"\n+#include \"builtin.h\"\n \n static const char var_usage[] = \"git var (-l | <variable>)\";\n \ndiff --git a/daemon.c b/daemon.c\nindex 347fd0c..4c8346d 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -660,7 +660,7 @@ static void check_dead_children(void)\n static char **cld_argv;\n static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)\n {\n-\tstruct child_process cld = { 0 };\n+\tstruct child_process cld = { NULL };\n \tchar addrbuf[300] = \"REMOTE_ADDR=\", portbuf[300];\n \tchar *env[] = { addrbuf, portbuf, NULL };\n \ndiff --git a/diff.c b/diff.c\nindex 42a107c..9b3eb99 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -628,7 +628,7 @@ struct diff_words_style {\n \tconst char *newline;\n };\n \n-struct diff_words_style diff_words_styles[] = {\n+static struct diff_words_style diff_words_styles[] = {\n \t{ DIFF_WORDS_PORCELAIN, {\"+\", \"\\n\"}, {\"-\", \"\\n\"}, {\" \", \"\\n\"}, \"~\\n\" },\n \t{ DIFF_WORDS_PLAIN, {\"{+\", \"+}\"}, {\"[-\", \"-]\"}, {\"\", \"\"}, \"\\n\" },\n \t{ DIFF_WORDS_COLOR, {\"\", \"\"}, {\"\", \"\"}, {\"\", \"\"}, \"\\n\" }\ndiff --git a/fast-import.c b/fast-import.c\nindex d9f9a3f..65d65bf 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2939,7 +2939,7 @@ static void parse_ls(struct branch *b)\n {\n \tconst char *p;\n \tstruct tree_entry *root = NULL;\n-\tstruct tree_entry leaf = {0};\n+\tstruct tree_entry leaf = {NULL};\n \n \t/* ls SP (<treeish> SP)? <path> */\n \tp = command_buf.buf + strlen(\"ls \");\ndiff --git a/imap-send.c b/imap-send.c\nindex 71506a8..9adf4b9 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -1069,7 +1069,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)\n \n \tif (srvc->tunnel) {\n \t\tconst char *argv[] = { srvc->tunnel, NULL };\n-\t\tstruct child_process tunnel = {0};\n+\t\tstruct child_process tunnel = {NULL};\n \n \t\timap_info(\"Starting tunnel '%s'... \", srvc->tunnel);\n \ndiff --git a/notes-merge.c b/notes-merge.c\nindex 1467ad3..28046a9 100644\n--- a/notes-merge.c\n+++ b/notes-merge.c\n@@ -359,7 +359,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,\n \tread_mmblob(&remote, p->remote);\n \n \tstatus = ll_merge(&result_buf, sha1_to_hex(p->obj), &base, NULL,\n-\t\t\t  &local, o->local_ref, &remote, o->remote_ref, 0);\n+\t\t\t  &local, o->local_ref, &remote, o->remote_ref, NULL);\n \n \tfree(base.ptr);\n \tfree(local.ptr);\ndiff --git a/parse-options.c b/parse-options.c\nindex 42b51ef..73bd28a 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -561,14 +561,14 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n \treturn PARSE_OPT_HELP;\n }\n \n-void usage_with_options(const char * const *usagestr,\n+void NORETURN usage_with_options(const char * const *usagestr,\n \t\t\tconst struct option *opts)\n {\n \tusage_with_options_internal(NULL, usagestr, opts, 0, 1);\n \texit(129);\n }\n \n-void usage_msg_opt(const char *msg,\n+void NORETURN usage_msg_opt(const char *msg,\n \t\t   const char * const *usagestr,\n \t\t   const struct option *options)\n {\ndiff --git a/replace_object.c b/replace_object.c\nindex eb59604..7c6c754 100644\n--- a/replace_object.c\n+++ b/replace_object.c\n@@ -1,6 +1,7 @@\n #include \"cache.h\"\n #include \"sha1-lookup.h\"\n #include \"refs.h\"\n+#include \"commit.h\"\n \n static struct replace_object {\n \tunsigned char sha1[2][20];\ndiff --git a/submodule.c b/submodule.c\nindex e9f2b19..0cb6d18 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -9,9 +9,9 @@\n #include \"refs.h\"\n #include \"string-list.h\"\n \n-struct string_list config_name_for_path;\n-struct string_list config_fetch_recurse_submodules_for_name;\n-struct string_list config_ignore_for_name;\n+static struct string_list config_name_for_path;\n+static struct string_list config_fetch_recurse_submodules_for_name;\n+static struct string_list config_ignore_for_name;\n static int config_fetch_recurse_submodules;\n \n static int add_submodule_odb(const char *path)\ndiff --git a/thread-utils.c b/thread-utils.c\nindex 589f838..7f4b76a 100644\n--- a/thread-utils.c\n+++ b/thread-utils.c\n@@ -1,5 +1,5 @@\n #include \"cache.h\"\n-#include <pthread.h>\n+#include \"thread-utils.h\"\n \n #if defined(hpux) || defined(__hpux) || defined(_hpux)\n #  include <sys/pstat.h>\ndiff --git a/trace.c b/trace.c\nindex 8390bf7..d953416 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -75,7 +75,7 @@ void trace_vprintf(const char *key, const char *fmt, va_list ap)\n \tstrbuf_release(&buf);\n }\n \n-void trace_printf_key(const char *key, const char *fmt, ...)\n+static void trace_printf_key(const char *key, const char *fmt, ...)\n {\n \tva_list ap;\n \tva_start(ap, fmt);\ndiff --git a/transport-helper.c b/transport-helper.c\nindex 0c5b1bd..5846b55 100644\n--- a/transport-helper.c\n+++ b/transport-helper.c\n@@ -76,7 +76,7 @@ static void write_constant(int fd, const char *str)\n \t\tdie_errno(\"Full write to remote helper failed\");\n }\n \n-const char *remove_ext_force(const char *url)\n+static const char *remove_ext_force(const char *url)\n {\n \tif (url) {\n \t\tconst char *colon = strchr(url, ':');\ndiff --git a/transport.c b/transport.c\nindex 0078660..f1c0781 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -192,7 +192,7 @@ static const char *rsync_url(const char *url)\n static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)\n {\n \tstruct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;\n-\tstruct ref dummy = {0}, *tail = &dummy;\n+\tstruct ref dummy = {NULL}, *tail = &dummy;\n \tstruct child_process rsync;\n \tconst char *args[5];\n \tint temp_dir_len;\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex b68ec82..500ebcf 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -16,7 +16,7 @@\n  * situation better.  See how \"git checkout\" and \"git merge\" replaces\n  * them using setup_unpack_trees_porcelain(), for example.\n  */\n-const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {\n+static const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {\n \t/* ERROR_WOULD_OVERWRITE */\n \t\"Entry '%s' would be overwritten by merge. Cannot merge.\",\n \ndiff --git a/url.c b/url.c\nindex 6a54959..3e06fd3 100644\n--- a/url.c\n+++ b/url.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"url.h\"\n \n int is_urlschemechar(int first_flag, int ch)\n {\ndiff --git a/usage.c b/usage.c\nindex ec4cf53..b5e67e3 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -46,7 +46,7 @@ void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list param\n \tdie_routine = routine;\n }\n \n-void usagef(const char *err, ...)\n+void NORETURN usagef(const char *err, ...)\n {\n \tva_list params;\n \n@@ -55,12 +55,12 @@ void usagef(const char *err, ...)\n \tva_end(params);\n }\n \n-void usage(const char *err)\n+void NORETURN usage(const char *err)\n {\n \tusagef(\"%s\", err);\n }\n \n-void die(const char *err, ...)\n+void NORETURN die(const char *err, ...)\n {\n \tva_list params;\n \n@@ -69,7 +69,7 @@ void die(const char *err, ...)\n \tva_end(params);\n }\n \n-void die_errno(const char *fmt, ...)\n+void NORETURN die_errno(const char *fmt, ...)\n {\n \tva_list params;\n \tchar fmt_with_err[1024];\n-- \n1.7.4.1.343.ga91df\n"},{"id":"164062","messageId":"7vwrjrkr9u.fsf@alter.siamese.dyndns.org","threadId":"26813","inReplyTo":"1300780265-5698-1-git-send-email-bebarino@gmail.com","subject":"Re: [PATCHv3 2/2] Fix sparse warnings","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-22T17:18:37Z","receivedAt":"2011-03-22T17:18:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n"}]}