summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a49eb19)
raw | patch | inline | side by side (parent: a49eb19)
author | Linus Torvalds <torvalds@linux-foundation.org> | |
Thu, 18 Jun 2009 17:28:43 +0000 (10:28 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 21 Jun 2009 04:52:55 +0000 (21:52 -0700) |
There are a few remaining ones, but this fixes the trivial ones. It boils
down to two main issues that sparse complains about:
- warning: Using plain integer as NULL pointer
Sparse doesn't like you using '0' instead of 'NULL'. For various good
reasons, not the least of which is just the visual confusion. A NULL
pointer is not an integer, and that whole "0 works as NULL" is a
historical accident and not very pretty.
A few of these remain: zlib is a total mess, and Z_NULL is just a 0.
I didn't touch those.
- warning: symbol 'xyz' was not declared. Should it be static?
Sparse wants to see declarations for any functions you export. A lack
of a declaration tends to mean that you should either add one, or you
should mark the function 'static' to show that it's in file scope.
A few of these remain: I only did the ones that should obviously just
be made static.
That 'wt_status_submodule_summary' one is debatable. It has a few related
flags (like 'wt_status_use_color') which _are_ declared, and are used by
builtin-commit.c. So maybe we'd like to export it at some point, but it's
not declared now, and not used outside of that file, so 'static' it is in
this patch.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
down to two main issues that sparse complains about:
- warning: Using plain integer as NULL pointer
Sparse doesn't like you using '0' instead of 'NULL'. For various good
reasons, not the least of which is just the visual confusion. A NULL
pointer is not an integer, and that whole "0 works as NULL" is a
historical accident and not very pretty.
A few of these remain: zlib is a total mess, and Z_NULL is just a 0.
I didn't touch those.
- warning: symbol 'xyz' was not declared. Should it be static?
Sparse wants to see declarations for any functions you export. A lack
of a declaration tends to mean that you should either add one, or you
should mark the function 'static' to show that it's in file scope.
A few of these remain: I only did the ones that should obviously just
be made static.
That 'wt_status_submodule_summary' one is debatable. It has a few related
flags (like 'wt_status_use_color') which _are_ declared, and are used by
builtin-commit.c. So maybe we'd like to export it at some point, but it's
not declared now, and not used outside of that file, so 'static' it is in
this patch.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
23 files changed:
bisect.c | patch | blob | history | |
builtin-add.c | patch | blob | history | |
builtin-apply.c | patch | blob | history | |
builtin-clone.c | patch | blob | history | |
builtin-fsck.c | patch | blob | history | |
builtin-help.c | patch | blob | history | |
builtin-log.c | patch | blob | history | |
builtin-merge.c | patch | blob | history | |
builtin-remote.c | patch | blob | history | |
builtin-unpack-objects.c | patch | blob | history | |
connect.c | patch | blob | history | |
daemon.c | patch | blob | history | |
http-push.c | patch | blob | history | |
imap-send.c | patch | blob | history | |
index-pack.c | patch | blob | history | |
mailmap.c | patch | blob | history | |
merge-recursive.c | patch | blob | history | |
parse-options.c | patch | blob | history | |
quote.c | patch | blob | history | |
remote.c | patch | blob | history | |
test-parse-options.c | patch | blob | history | |
unpack-trees.c | patch | blob | history | |
wt-status.c | patch | blob | history |
diff --git a/bisect.c b/bisect.c
index 6fdff05722c3afa8e8e4cdcac200697e4116ea8e..dbeb28752adce639d8729fa7cbb003fc31bd240f 100644 (file)
--- a/bisect.c
+++ b/bisect.c
return for_each_ref_in("refs/bisect/", register_ref, NULL);
}
-void read_bisect_paths(struct argv_array *array)
+static void read_bisect_paths(struct argv_array *array)
{
struct strbuf str = STRBUF_INIT;
const char *filename = git_path("BISECT_NAMES");
exit(1);
}
-void handle_skipped_merge_base(const unsigned char *mb)
+static void handle_skipped_merge_base(const unsigned char *mb)
{
char *mb_hex = sha1_to_hex(mb);
char *bad_hex = sha1_to_hex(current_bad_sha1);
diff --git a/builtin-add.c b/builtin-add.c
index 56e522127c3e73fad59d8dc96bdffdb87a3b7a44..4e44148e05843e03befc167f6bdf3a1567d3f8ad 100644 (file)
--- a/builtin-add.c
+++ b/builtin-add.c
return status;
}
-int edit_patch(int argc, const char **argv, const char *prefix)
+static int edit_patch(int argc, const char **argv, const char *prefix)
{
char *file = xstrdup(git_path("ADD_EDIT.patch"));
const char *apply_argv[] = { "apply", "--recount", "--cached",
diff --git a/builtin-apply.c b/builtin-apply.c
index 89a5185cea0449fd4f5110bd6efbf5aebbf68b39..4cf819c7905d5997a6ce2a89b4ecce1176a4b045 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
static void build_fake_ancestor(struct patch *list, const char *filename)
{
struct patch *patch;
- struct index_state result = { 0 };
+ struct index_state result = { NULL };
int fd;
/* Once we start supporting the reverse patch, it may be
diff --git a/builtin-clone.c b/builtin-clone.c
index 5c46496a43a8fe2f91b395563b266e79a8b94429..2ceacb7b3f34c78e64ed047833d8af5a061f065f 100644 (file)
--- a/builtin-clone.c
+++ b/builtin-clone.c
if (is_bare) {
struct strbuf result = STRBUF_INIT;
strbuf_addf(&result, "%.*s.git", (int)(end - start), start);
- dir = strbuf_detach(&result, 0);
+ dir = strbuf_detach(&result, NULL);
} else
dir = xstrndup(start, end - start);
/*
diff --git a/builtin-fsck.c b/builtin-fsck.c
index 7da706cac3bef05f03c09955d41b4e5077558d4f..e077e72dea94892e2f74ddd6be528b02bc6ccea4 100644 (file)
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
static void mark_object_reachable(struct object *obj)
{
- mark_object(obj, OBJ_ANY, 0);
+ mark_object(obj, OBJ_ANY, NULL);
}
static int traverse_one_object(struct object *obj, struct object *parent)
fprintf(stderr, "Checking %s %s\n",
typename(obj->type), sha1_to_hex(obj->sha1));
- if (fsck_walk(obj, mark_used, 0))
+ if (fsck_walk(obj, mark_used, NULL))
objerror(obj, "broken links");
if (fsck_object(obj, check_strict, fsck_error_func))
return -1;
diff --git a/builtin-help.c b/builtin-help.c
index 6e53b23833062249485124b827da348a8be206b0..e1eba778a526f500b0a65a6b112e468f04a3f869 100644 (file)
--- a/builtin-help.c
+++ b/builtin-help.c
* HTML.
*/
#ifndef open_html
-void open_html(const char *path)
+static void open_html(const char *path)
{
execl_git_cmd("web--browse", "-c", "help.browser", path, NULL);
}
diff --git a/builtin-log.c b/builtin-log.c
index 0d34050556855d6bab8b4c4121e833cc326324df..44f9a27daec612db6d0f0e502c99d5e5ecaaf842 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
printf("Final output: %d %s\n", nr, stage);
}
-struct itimerval early_output_timer;
+static struct itimerval early_output_timer;
static void log_show_early(struct rev_info *revs, struct commit_list *list)
{
strbuf_addch(&buf, '\n');
}
- rev.extra_headers = strbuf_detach(&buf, 0);
+ rev.extra_headers = strbuf_detach(&buf, NULL);
if (start_number < 0)
start_number = 1;
diff --git a/builtin-merge.c b/builtin-merge.c
index 793f2f4a189e448fb481c5c1e2886be28fddf2e2..af9adab300de98026b23a58b1d8b40f9395ff11a 100644 (file)
--- a/builtin-merge.c
+++ b/builtin-merge.c
strbuf_addstr(&buf, "refs/heads/");
strbuf_addstr(&buf, remote);
- resolve_ref(buf.buf, branch_head, 0, 0);
+ resolve_ref(buf.buf, branch_head, 0, NULL);
if (!hashcmp(remote_head->sha1, branch_head)) {
strbuf_addf(msg, "%s\t\tbranch '%s' of .\n",
strbuf_addstr(&truname, "refs/heads/");
strbuf_addstr(&truname, remote);
strbuf_setlen(&truname, truname.len - len);
- if (resolve_ref(truname.buf, buf_sha, 0, 0)) {
+ if (resolve_ref(truname.buf, buf_sha, 0, NULL)) {
strbuf_addf(msg,
"%s\t\tbranch '%s'%s of .\n",
sha1_to_hex(remote_head->sha1),
diff --git a/builtin-remote.c b/builtin-remote.c
index 406fb85255f2a1475f9960eee12e04f04c8e4c53..658d578588fed5d9f0c8a9c16808b6182c34f657 100644 (file)
--- a/builtin-remote.c
+++ b/builtin-remote.c
return result;
}
-void clear_push_info(void *util, const char *string)
+static void clear_push_info(void *util, const char *string)
{
struct push_info *info = util;
free(info->dest);
int any_rebase;
};
-int add_remote_to_show_info(struct string_list_item *item, void *cb_data)
+static int add_remote_to_show_info(struct string_list_item *item, void *cb_data)
{
struct show_info *info = cb_data;
int n = strlen(item->string);
return 0;
}
-int show_remote_info_item(struct string_list_item *item, void *cb_data)
+static int show_remote_info_item(struct string_list_item *item, void *cb_data)
{
struct show_info *info = cb_data;
struct ref_states *states = info->states;
return 0;
}
-int add_local_to_show_info(struct string_list_item *branch_item, void *cb_data)
+static int add_local_to_show_info(struct string_list_item *branch_item, void *cb_data)
{
struct show_info *show_info = cb_data;
struct ref_states *states = show_info->states;
return 0;
}
-int show_local_info_item(struct string_list_item *item, void *cb_data)
+static int show_local_info_item(struct string_list_item *item, void *cb_data)
{
struct show_info *show_info = cb_data;
struct branch_info *branch_info = item->util;
return 0;
}
-int add_push_to_show_info(struct string_list_item *push_item, void *cb_data)
+static int add_push_to_show_info(struct string_list_item *push_item, void *cb_data)
{
struct show_info *show_info = cb_data;
struct push_info *push_info = push_item->util;
return cmp ? cmp : strcmp(a_push->dest, b_push->dest);
}
-int show_push_info_item(struct string_list_item *item, void *cb_data)
+static int show_push_info_item(struct string_list_item *item, void *cb_data)
{
struct show_info *show_info = cb_data;
struct push_info *push_info = item->util;
return 0;
}
-struct remote_group {
+static struct remote_group {
const char *name;
struct string_list *list;
} remote_group;
index 8e831be476b71eed151cee1b5f2fc81c4edcb5ff..7e3ea73006ecdc74c03580ac7297be4ebee174b3 100644 (file)
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
#define FLAG_WRITTEN (1u<<21)
static struct obj_info *obj_list;
-unsigned nr_objects;
+static unsigned nr_objects;
/*
* Called only from check_object() after it verified this object
if (fsck_object(obj, 1, fsck_error_function))
die("Error in object");
- if (!fsck_walk(obj, check_object, 0))
+ if (!fsck_walk(obj, check_object, NULL))
die("Error on reachable objects of %s", sha1_to_hex(obj->sha1));
write_cached_object(obj);
return 1;
{
unsigned i;
for (i = 0; i < nr_objects; i++)
- check_object(obj_list[i].obj, OBJ_ANY, 0);
+ check_object(obj_list[i].obj, OBJ_ANY, NULL);
}
static void added_object(unsigned nr, enum object_type type,
diff --git a/connect.c b/connect.c
index 0ce941ef444277957efdd8a359a568775e2b17a4..76e542776abff8d07e7250ecfc8c7ae813302b2d 100644 (file)
--- a/connect.c
+++ b/connect.c
#define MAX_CMD_LEN 1024
-char *get_port(char *host)
+static char *get_port(char *host)
{
char *end;
char *p = strchr(host, ':');
diff --git a/daemon.c b/daemon.c
index b2babcc076de65b53671157115e63e74fec83a3e..366db37b39f7dcfb29dbb4e79ad5bcc985b75bc6 100644 (file)
--- a/daemon.c
+++ b/daemon.c
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
- gai = getaddrinfo(hostname, 0, &hints, &ai);
+ gai = getaddrinfo(hostname, NULL, &hints, &ai);
if (!gai) {
struct sockaddr_in *sin_addr = (void *)ai->ai_addr;
diff --git a/http-push.c b/http-push.c
index e4ea395e029446920f570d888d93ba9ae249f18c..8cc8ee0dfd5c047b2523f63346bf9b30094c1386 100644 (file)
--- a/http-push.c
+++ b/http-push.c
return 0;
}
-void run_request_queue(void)
+static void run_request_queue(void)
{
#ifdef USE_CURL_MULTI
is_running_queue = 1;
diff --git a/imap-send.c b/imap-send.c
index e4c83b9d5b989671c1accc573235479ad77a5ab7..3847fd151df6e9f41fdb0b95573882a7d9ac992a 100644 (file)
--- a/imap-send.c
+++ b/imap-send.c
#ifndef NO_OPENSSL
static void ssl_socket_perror(const char *func)
{
- fprintf(stderr, "%s: %s\n", func, ERR_error_string(ERR_get_error(), 0));
+ fprintf(stderr, "%s: %s\n", func, ERR_error_string(ERR_get_error(), NULL));
}
#endif
diff --git a/index-pack.c b/index-pack.c
index 0c92bafcbb80cc539de9a86305562ff291361db9..c72cbd406a7880361f262f43daff62a9f453628d 100644 (file)
--- a/index-pack.c
+++ b/index-pack.c
die("invalid %s", typename(type));
if (fsck_object(obj, 1, fsck_error_function))
die("Error in object");
- if (fsck_walk(obj, mark_link, 0))
+ if (fsck_walk(obj, mark_link, NULL))
die("Not all child objects of %s are reachable", sha1_to_hex(obj->sha1));
if (obj->type == OBJ_TREE) {
diff --git a/mailmap.c b/mailmap.c
index bb1f2fb711a588d2af0d61decbd4b3eb2f2aebbe..f167c005bf9039f44d21ef5f32ab27db7784d642 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
char **email, int allow_empty_email)
{
char *left, *right, *nstart, *nend;
- *name = *email = 0;
+ *name = *email = NULL;
if ((left = strchr(buffer, '<')) == NULL)
return NULL;
@@ -136,7 +136,7 @@ static int read_single_mailmap(struct string_list *map, const char *filename, ch
if (f == NULL)
return 1;
while (fgets(buffer, sizeof(buffer), f) != NULL) {
- char *name1 = 0, *email1 = 0, *name2 = 0, *email2 = 0;
+ char *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;
if (buffer[0] == '#') {
static const char abbrev[] = "# repo-abbrev:";
int abblen = sizeof(abbrev) - 1;
if (!p) {
/* email passed in might not be wrapped in <>, but end with a \0 */
p = memchr(email, '\0', maxlen_email);
- if (p == 0)
+ if (!p)
return 0;
}
if (p - email + 1 < sizeof(buf))
diff --git a/merge-recursive.c b/merge-recursive.c
index f5df9b961b2999e4824b900d61d28c254b2ef858..c703445a9cdf66f2933c1ffce636bfe3c11a048c 100644 (file)
--- a/merge-recursive.c
+++ b/merge-recursive.c
* A virtual commit has (const char *)commit->util set to the name.
*/
-struct commit *make_virtual_commit(struct tree *tree, const char *comment)
+static struct commit *make_virtual_commit(struct tree *tree, const char *comment)
{
struct commit *commit = xcalloc(1, sizeof(struct commit));
commit->tree = tree;
diff --git a/parse-options.c b/parse-options.c
index 34282adde5a2fd8ebb1413aee6742633b9656db7..f7ce523a615b121b8a0825e459c1b75f24253c85 100644 (file)
--- a/parse-options.c
+++ b/parse-options.c
#define USAGE_OPTS_WIDTH 24
#define USAGE_GAP 2
-int usage_with_options_internal(const char * const *usagestr,
+static int usage_with_options_internal(const char * const *usagestr,
const struct option *opts, int full)
{
if (!usagestr)
index 7a49fcf69671646a0d3ba6de6478cfc6767c31fe..848d174cc56be32483ba6c73f9b06bc398ed6437 100644 (file)
--- a/quote.c
+++ b/quote.c
fputc(terminator, fp);
}
-extern void write_name_quotedpfx(const char *pfx, size_t pfxlen,
- const char *name, FILE *fp, int terminator)
+void write_name_quotedpfx(const char *pfx, size_t pfxlen,
+ const char *name, FILE *fp, int terminator)
{
int needquote = 0;
diff --git a/remote.c b/remote.c
index 9a0397ec570f1794e0f762c2ccc6eee27f77be46..733ba57494715e00427350af4175fe67c390ec34 100644 (file)
--- a/remote.c
+++ b/remote.c
strbuf_addstr(&branch, "HEAD:");
}
add_url_alias(remote, p);
- add_fetch_refspec(remote, strbuf_detach(&branch, 0));
+ add_fetch_refspec(remote, strbuf_detach(&branch, NULL));
/*
* Cogito compatible push: push current HEAD to remote #branch
* (master if missing)
strbuf_addf(&branch, ":refs/heads/%s", frag);
else
strbuf_addstr(&branch, ":refs/heads/master");
- add_push_refspec(remote, strbuf_detach(&branch, 0));
+ add_push_refspec(remote, strbuf_detach(&branch, NULL));
remote->fetch_tags = 1; /* always auto-follow */
}
int send_all = flags & MATCH_REFS_ALL;
int send_mirror = flags & MATCH_REFS_MIRROR;
int errs;
- static const char *default_refspec[] = { ":", 0 };
+ static const char *default_refspec[] = { ":", NULL };
struct ref **dst_tail = tail_ref(dst);
if (!nr_refspec) {
diff --git a/test-parse-options.c b/test-parse-options.c
index a90bc3003d97f86fcc2210e340666106647eb74c..efa734b42e38d7f5a98393cd69ac0ffe10160ffc 100644 (file)
--- a/test-parse-options.c
+++ b/test-parse-options.c
static char *string = NULL;
static char *file = NULL;
-int length_callback(const struct option *opt, const char *arg, int unset)
+static int length_callback(const struct option *opt, const char *arg, int unset)
{
printf("Callback: \"%s\", %d\n",
(arg ? arg : "not set"), unset);
return 0;
}
-int number_callback(const struct option *opt, const char *arg, int unset)
+static int number_callback(const struct option *opt, const char *arg, int unset)
{
*(int *)opt->value = strtol(arg, NULL, 10);
return 0;
diff --git a/unpack-trees.c b/unpack-trees.c
index 8eb3ddb392499a41eaf6587b3ad717bc8a6ba041..05d0bb1f85467a275bb78173d3a045940262abe7 100644 (file)
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -140,7 +140,7 @@ static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_option
return call_unpack_fn(src, o);
}
-int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long df_conflicts, struct name_entry *names, struct traverse_info *info)
+static int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long df_conflicts, struct name_entry *names, struct traverse_info *info)
{
int i;
struct tree_desc t[MAX_UNPACK_TREES];
diff --git a/wt-status.c b/wt-status.c
index 1b6df45450c39c0f456df68485b5735950816ac8..0ca4b13c29ee6a8cebc1db4ec59f543aef299484 100644 (file)
--- a/wt-status.c
+++ b/wt-status.c
int wt_status_relative_paths = 1;
int wt_status_use_color = -1;
-int wt_status_submodule_summary;
+static int wt_status_submodule_summary;
static char wt_status_colors[][COLOR_MAXLEN] = {
GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */
GIT_COLOR_GREEN, /* WT_STATUS_UPDATED */