@matheusbsbs / matheus-bagliano / commits / c2e86addb8
Fork 0

Fix sparse warnings

Fix warnings from 'make check'. - These files don't include 'builtin.h' causing sparse to complain that cmd_* isn't declared: builtin/clone.c:364, builtin/fetch-pack.c:797, builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78, builtin/merge-index.c:69, builtin/merge-recursive.c:22 builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426 builtin/notes.c:822, builtin/pack-redundant.c:596, builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149, builtin/remote.c:1512, builtin/remote-ext.c:240, builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384, builtin/unpack-file.c:25, builtin/var.c:75 - These files have symbols which should be marked static since they're only file scope: submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13, submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79, unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123, url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48 - These files redeclare symbols to be different types: builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571, usage.c:49, usage.c:58, usage.c:63, usage.c:72 - These files use a literal integer 0 when they really should use a NULL pointer: daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362 While we're in the area, clean up some unused #includes in builtin files (mostly exec_cmd.h). Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephen Boyd committed Mar 22, 2011 at 00:51 UTC c2e86addb86689306b992065328ec52aa2479658
35 files changed +43 -48
builtin/clone.c
+1 -1
@@ -8,7 +8,7 @@
8 * Clone a repository into a different directory that does not yet exist.
9 */
10
11 -#include "cache.h"
11 +#include "builtin.h"
12 #include "parse-options.h"
13 #include "fetch-pack.h"
14 #include "refs.h"
builtin/fetch-pack.c
+1 -1
@@ -1,4 +1,4 @@
1 -#include "cache.h"
1 +#include "builtin.h"
2 #include "refs.h"
3 #include "pkt-line.h"
4 #include "commit.h"
builtin/fmt-merge-msg.c
+1 -1
@@ -31,7 +31,7 @@ struct src_data {
31 int head_status;
32 };
33
34 -void init_src_data(struct src_data *data)
34 +static void init_src_data(struct src_data *data)
35 {
36 data->branch.strdup_strings = 1;
37 data->tag.strdup_strings = 1;
builtin/hash-object.c
+1 -1
@@ -4,7 +4,7 @@
4 * Copyright (C) Linus Torvalds, 2005
5 * Copyright (C) Junio C Hamano, 2005
6 */
7 -#include "cache.h"
7 +#include "builtin.h"
8 #include "blob.h"
9 #include "quote.h"
10 #include "parse-options.h"
builtin/index-pack.c
+1 -1
@@ -207,7 +207,7 @@ static void parse_pack_header(void)
207 static NORETURN void bad_object(unsigned long offset, const char *format,
208 ...) __attribute__((format (printf, 2, 3)));
209
210 -static void bad_object(unsigned long offset, const char *format, ...)
210 +static NORETURN void bad_object(unsigned long offset, const char *format, ...)
211 {
212 va_list params;
213 char buf[1024];
builtin/merge-index.c
+1 -2
@@ -1,6 +1,5 @@
1 -#include "cache.h"
1 +#include "builtin.h"
2 #include "run-command.h"
3 -#include "exec_cmd.h"
3
4 static const char *pgm;
5 static int one_shot, quiet;
builtin/merge-recursive.c
+1 -1
@@ -1,4 +1,4 @@
1 -#include "cache.h"
1 +#include "builtin.h"
2 #include "commit.h"
3 #include "tag.h"
4 #include "merge-recursive.h"
builtin/merge-tree.c
+1 -1
@@ -1,4 +1,4 @@
1 -#include "cache.h"
1 +#include "builtin.h"
2 #include "tree-walk.h"
3 #include "xdiff-interface.h"
4 #include "blob.h"
builtin/mktag.c
+1 -2
@@ -1,6 +1,5 @@
1 -#include "cache.h"
1 +#include "builtin.h"
2 #include "tag.h"
3 -#include "exec_cmd.h"
3
4 /*
5 * A signature file has a very simple fixed format: four lines
builtin/notes.c
+2 -2
@@ -423,7 +423,7 @@ void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c)
423 free(c);
424 }
425
426 -int notes_copy_from_stdin(int force, const char *rewrite_cmd)
426 +static int notes_copy_from_stdin(int force, const char *rewrite_cmd)
427 {
428 struct strbuf buf = STRBUF_INIT;
429 struct notes_rewrite_cfg *c = NULL;
@@ -819,7 +819,7 @@ static int merge_commit(struct notes_merge_options *o)
819 t = xcalloc(1, sizeof(struct notes_tree));
820 init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
821
822 - o->local_ref = resolve_ref("NOTES_MERGE_REF", sha1, 0, 0);
822 + o->local_ref = resolve_ref("NOTES_MERGE_REF", sha1, 0, NULL);
823 if (!o->local_ref)
824 die("Failed to resolve NOTES_MERGE_REF");
825
builtin/pack-redundant.c
+1 -2
@@ -6,8 +6,7 @@
6 *
7 */
8
9 -#include "cache.h"
10 -#include "exec_cmd.h"
9 +#include "builtin.h"
10
11 #define BLKSIZE 512
12
builtin/pack-refs.c
+1 -1
@@ -1,4 +1,4 @@
1 -#include "cache.h"
1 +#include "builtin.h"
2 #include "parse-options.h"
3 #include "pack-refs.h"
4
builtin/patch-id.c
+2 -3
@@ -1,5 +1,4 @@
1 -#include "cache.h"
2 -#include "exec_cmd.h"
1 +#include "builtin.h"
2
3 static void flush_current_id(int patchlen, unsigned char *id, git_SHA_CTX *c)
4 {
@@ -57,7 +56,7 @@ static int scan_hunk_header(const char *p, int *p_before, int *p_after)
56 return 1;
57 }
58
60 -int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)
59 +static int get_one_patchid(unsigned char *next_sha1, git_SHA_CTX *ctx)
60 {
61 static char line[1000];
62 int patchlen = 0, found_next = 0;
builtin/remote-ext.c
+1 -1
@@ -1,4 +1,4 @@
1 -#include "git-compat-util.h"
1 +#include "builtin.h"
2 #include "transport.h"
3 #include "run-command.h"
4
builtin/remote-fd.c
+1 -1
@@ -1,4 +1,4 @@
1 -#include "git-compat-util.h"
1 +#include "builtin.h"
2 #include "transport.h"
3
4 /*
builtin/remote.c
+1 -1
@@ -1,4 +1,4 @@
1 -#include "cache.h"
1 +#include "builtin.h"
2 #include "parse-options.h"
3 #include "transport.h"
4 #include "remote.h"
builtin/reset.c
+1 -1
@@ -7,7 +7,7 @@
7 *
8 * Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano
9 */
10 -#include "cache.h"
10 +#include "builtin.h"
11 #include "tag.h"
12 #include "object.h"
13 #include "commit.h"
builtin/send-pack.c
+1 -1
@@ -1,4 +1,4 @@
1 -#include "cache.h"
1 +#include "builtin.h"
2 #include "commit.h"
3 #include "refs.h"
4 #include "pkt-line.h"
builtin/unpack-file.c
+1 -3
@@ -1,6 +1,4 @@
1 -#include "cache.h"
2 -#include "blob.h"
3 -#include "exec_cmd.h"
1 +#include "builtin.h"
2
3 static char *create_temp_file(unsigned char *sha1)
4 {
builtin/var.c
+1 -2
@@ -3,8 +3,7 @@
3 *
4 * Copyright (C) Eric Biederman, 2005
5 */
6 -#include "cache.h"
7 -#include "exec_cmd.h"
6 +#include "builtin.h"
7
8 static const char var_usage[] = "git var (-l | <variable>)";
9
daemon.c
+1 -1
@@ -660,7 +660,7 @@ static void check_dead_children(void)
660 static char **cld_argv;
661 static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
662 {
663 - struct child_process cld = { 0 };
663 + struct child_process cld = { NULL };
664 char addrbuf[300] = "REMOTE_ADDR=", portbuf[300];
665 char *env[] = { addrbuf, portbuf, NULL };
666
diff.c
+1 -1
@@ -628,7 +628,7 @@ struct diff_words_style {
628 const char *newline;
629 };
630
631 -struct diff_words_style diff_words_styles[] = {
631 +static struct diff_words_style diff_words_styles[] = {
632 { DIFF_WORDS_PORCELAIN, {"+", "\n"}, {"-", "\n"}, {" ", "\n"}, "~\n" },
633 { DIFF_WORDS_PLAIN, {"{+", "+}"}, {"[-", "-]"}, {"", ""}, "\n" },
634 { DIFF_WORDS_COLOR, {"", ""}, {"", ""}, {"", ""}, "\n" }
fast-import.c
+1 -1
@@ -2939,7 +2939,7 @@ static void parse_ls(struct branch *b)
2939 {
2940 const char *p;
2941 struct tree_entry *root = NULL;
2942 - struct tree_entry leaf = {0};
2942 + struct tree_entry leaf = {NULL};
2943
2944 /* ls SP (<treeish> SP)? <path> */
2945 p = command_buf.buf + strlen("ls ");
imap-send.c
+1 -1
@@ -1069,7 +1069,7 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
1069
1070 if (srvc->tunnel) {
1071 const char *argv[] = { srvc->tunnel, NULL };
1072 - struct child_process tunnel = {0};
1072 + struct child_process tunnel = {NULL};
1073
1074 imap_info("Starting tunnel '%s'... ", srvc->tunnel);
1075
notes-merge.c
+1 -1
@@ -359,7 +359,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,
359 read_mmblob(&remote, p->remote);
360
361 status = ll_merge(&result_buf, sha1_to_hex(p->obj), &base, NULL,
362 - &local, o->local_ref, &remote, o->remote_ref, 0);
362 + &local, o->local_ref, &remote, o->remote_ref, NULL);
363
364 free(base.ptr);
365 free(local.ptr);
parse-options.c
+2 -2
@@ -561,14 +561,14 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
561 return PARSE_OPT_HELP;
562 }
563
564 -void usage_with_options(const char * const *usagestr,
564 +void NORETURN usage_with_options(const char * const *usagestr,
565 const struct option *opts)
566 {
567 usage_with_options_internal(NULL, usagestr, opts, 0, 1);
568 exit(129);
569 }
570
571 -void usage_msg_opt(const char *msg,
571 +void NORETURN usage_msg_opt(const char *msg,
572 const char * const *usagestr,
573 const struct option *options)
574 {
replace_object.c
+1
@@ -1,6 +1,7 @@
1 #include "cache.h"
2 #include "sha1-lookup.h"
3 #include "refs.h"
4 +#include "commit.h"
5
6 static struct replace_object {
7 unsigned char sha1[2][20];
submodule.c
+3 -3
@@ -9,9 +9,9 @@
9 #include "refs.h"
10 #include "string-list.h"
11
12 -struct string_list config_name_for_path;
13 -struct string_list config_fetch_recurse_submodules_for_name;
14 -struct string_list config_ignore_for_name;
12 +static struct string_list config_name_for_path;
13 +static struct string_list config_fetch_recurse_submodules_for_name;
14 +static struct string_list config_ignore_for_name;
15 static int config_fetch_recurse_submodules;
16
17 static int add_submodule_odb(const char *path)
thread-utils.c
+1 -1
@@ -1,5 +1,5 @@
1 #include "cache.h"
2 -#include <pthread.h>
2 +#include "thread-utils.h"
3
4 #if defined(hpux) || defined(__hpux) || defined(_hpux)
5 # include <sys/pstat.h>
trace.c
+1 -1
@@ -75,7 +75,7 @@ void trace_vprintf(const char *key, const char *fmt, va_list ap)
75 strbuf_release(&buf);
76 }
77
78 -void trace_printf_key(const char *key, const char *fmt, ...)
78 +static void trace_printf_key(const char *key, const char *fmt, ...)
79 {
80 va_list ap;
81 va_start(ap, fmt);
transport-helper.c
+1 -1
@@ -76,7 +76,7 @@ static void write_constant(int fd, const char *str)
76 die_errno("Full write to remote helper failed");
77 }
78
79 -const char *remove_ext_force(const char *url)
79 +static const char *remove_ext_force(const char *url)
80 {
81 if (url) {
82 const char *colon = strchr(url, ':');
transport.c
+1 -1
@@ -192,7 +192,7 @@ static const char *rsync_url(const char *url)
192 static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
193 {
194 struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
195 - struct ref dummy = {0}, *tail = &dummy;
195 + struct ref dummy = {NULL}, *tail = &dummy;
196 struct child_process rsync;
197 const char *args[5];
198 int temp_dir_len;
unpack-trees.c
+1 -1
@@ -16,7 +16,7 @@
16 * situation better. See how "git checkout" and "git merge" replaces
17 * them using setup_unpack_trees_porcelain(), for example.
18 */
19 -const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {
19 +static const char *unpack_plumbing_errors[NB_UNPACK_TREES_ERROR_TYPES] = {
20 /* ERROR_WOULD_OVERWRITE */
21 "Entry '%s' would be overwritten by merge. Cannot merge.",
22
url.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "url.h"
3
4 int is_urlschemechar(int first_flag, int ch)
5 {
usage.c
+4 -4
@@ -46,7 +46,7 @@ void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list param
46 die_routine = routine;
47 }
48
49 -void usagef(const char *err, ...)
49 +void NORETURN usagef(const char *err, ...)
50 {
51 va_list params;
52
@@ -55,12 +55,12 @@ void usagef(const char *err, ...)
55 va_end(params);
56 }
57
58 -void usage(const char *err)
58 +void NORETURN usage(const char *err)
59 {
60 usagef("%s", err);
61 }
62
63 -void die(const char *err, ...)
63 +void NORETURN die(const char *err, ...)
64 {
65 va_list params;
66
@@ -69,7 +69,7 @@ void die(const char *err, ...)
69 va_end(params);
70 }
71
72 -void die_errno(const char *fmt, ...)
72 +void NORETURN die_errno(const char *fmt, ...)
73 {
74 va_list params;
75 char fmt_with_err[1024];