summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ca4525)
raw | patch | inline | side by side (parent: 7ca4525)
author | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Fri, 20 May 2005 18:46:10 +0000 (11:46 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Fri, 20 May 2005 18:46:10 +0000 (11:46 -0700) |
Fix various things that sparse complains about:
- use NULL instead of 0
- make sure we declare everything properly, or mark it static
- use proper function declarations ("fn(void)" instead of "fn()")
Sparse is always right.
- use NULL instead of 0
- make sure we declare everything properly, or mark it static
- use proper function declarations ("fn(void)" instead of "fn()")
Sparse is always right.
18 files changed:
date.c | patch | blob | history | |
diff-cache.c | patch | blob | history | |
diff-files.c | patch | blob | history | |
diff-helper.c | patch | blob | history | |
diff-tree.c | patch | blob | history | |
diff.c | patch | blob | history | |
export.c | patch | blob | history | |
init-db.c | patch | blob | history | |
ls-files.c | patch | blob | history | |
ls-tree.c | patch | blob | history | |
merge-base.c | patch | blob | history | |
read-tree.c | patch | blob | history | |
rev-tree.c | patch | blob | history | |
rpush.c | patch | blob | history | |
sha1_file.c | patch | blob | history | |
strbuf.c | patch | blob | history | |
tar-tree.c | patch | blob | history | |
update-cache.c | patch | blob | history |
index b0b83c9da22f8a099cad5616e1ec5e63f2220f54..1f366a67f8b0d282088a26d900a3031fdc3e6012 100644 (file)
--- a/date.c
+++ b/date.c
#include <ctype.h>
#include <time.h>
+#include "cache.h"
+
static time_t my_mktime(struct tm *tm)
{
static const int mdays[] = {
diff --git a/diff-cache.c b/diff-cache.c
index 40fd6b4967a00b8976b2327720c653c7e8b36b6c..ff310ab35798a4e2db0774048fde9c3b6ee0161f 100644 (file)
--- a/diff-cache.c
+++ b/diff-cache.c
diff_setup(detect_rename, diff_score_opt, reverse_diff,
(generate_patch ? -1 : line_termination),
- 0, 0);
+ NULL, 0);
mark_merge_entries();
- tree = read_object_with_reference(tree_sha1, "tree", &size, 0);
+ tree = read_object_with_reference(tree_sha1, "tree", &size, NULL);
if (!tree)
die("bad tree object %s", argv[1]);
if (read_tree(tree, size, 1))
diff --git a/diff-files.c b/diff-files.c
index eb99c3cf097d1628289a988e7c4f858d212ffa88..c36bcf25bcd3b10079d8a2f97c67dea101d79880 100644 (file)
--- a/diff-files.c
+++ b/diff-files.c
diff_setup(detect_rename, diff_score_opt, reverse_diff,
(generate_patch ? -1 : line_termination),
- 0, 0);
+ NULL, 0);
for (i = 0; i < entries; i++) {
struct stat st;
diff --git a/diff-helper.c b/diff-helper.c
index 8d896f856413f5155108aa97be742862802bbeb8..ea9aefab2887f43e6b3c34e5c9d2034996b8e6f2 100644 (file)
--- a/diff-helper.c
+++ b/diff-helper.c
if ((*cp != '\t') && *cp != ' ')
return -1;
strcpy(path, ++cp);
- diff_change(old_mode, new_mode, old_sha1, new_sha1, path, 0);
+ diff_change(old_mode, new_mode, old_sha1, new_sha1, path, NULL);
break;
default:
return -1;
diff --git a/diff-tree.c b/diff-tree.c
index 3bf8899873a3743eae9a541ec7829fdf20c22b19..5aa0d5e94287057eaf8583ed3bbae7ca738ce74c 100644 (file)
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -254,10 +254,10 @@ static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, co
unsigned long size1, size2;
int retval;
- tree1 = read_object_with_reference(old, "tree", &size1, 0);
+ tree1 = read_object_with_reference(old, "tree", &size1, NULL);
if (!tree1)
die("unable to read source tree (%s)", sha1_to_hex(old));
- tree2 = read_object_with_reference(new, "tree", &size2, 0);
+ tree2 = read_object_with_reference(new, "tree", &size2, NULL);
if (!tree2)
die("unable to read destination tree (%s)", sha1_to_hex(new));
retval = diff_tree(tree1, size1, tree2, size2, base);
diff_setup(detect_rename, diff_score_opt, reverse_diff,
(generate_patch ? -1 : line_termination),
- 0, 0);
+ NULL, 0);
ret = diff_tree_sha1(old, new, base);
diff_flush();
return ret;
diff_setup(detect_rename, diff_score_opt, reverse_diff,
(generate_patch ? -1 : line_termination),
- 0, 0);
- tree = read_object_with_reference(new, "tree", &size, 0);
+ NULL, 0);
+ tree = read_object_with_reference(new, "tree", &size, NULL);
if (!tree)
die("unable to read root tree (%s)", sha1_to_hex(new));
retval = diff_tree("", 0, tree, size, base);
index eae2fc36e8504a77a5d1ff360ff11bb925b7e9de..21771e7756a8b42eeacffabe09a92802b0abd135 100644 (file)
--- a/diff.c
+++ b/diff.c
*arg++ = temp[1].mode;
if (other)
*arg++ = other;
- *arg = 0;
+ *arg = NULL;
execvp(pgm, (char *const*) exec_arg);
}
else
else if (s->flags & SHOULD_MUNMAP)
munmap(s->data, s->size);
s->flags &= ~(SHOULD_FREE|SHOULD_MUNMAP);
- s->data = 0;
+ s->data = NULL;
}
static void flush_remaining_diff(struct diff_spec_hold *elem,
return 0;
}
-int estimate_similarity(struct diff_spec_hold *src, struct diff_spec_hold *dst)
+static int estimate_similarity(struct diff_spec_hold *src, struct diff_spec_hold *dst)
{
/* src points at a deleted file and dst points at a created
* file. They may be quite similar, in which case we want to
diff --git a/export.c b/export.c
index b6487177d3cad0de3a5a88b0bd0fd3c9cfc22948..ce10b5a298699897bfefa4a5093f92b8c9501450 100644 (file)
--- a/export.c
+++ b/export.c
/*
* Show one commit
*/
-void show_commit(struct commit *commit)
+static void show_commit(struct commit *commit)
{
char cmdline[400];
char hex[100];
/*
* Show all unseen commits, depth-first
*/
-void show_unseen(struct commit *top)
+static void show_unseen(struct commit *top)
{
struct commit_list *parents;
show_commit(top);
}
-void export(struct commit *top, struct commit *base)
+static void export(struct commit *top, struct commit *base)
{
mark_reachable(&top->object, 1);
if (base)
show_unseen(top);
}
-struct commit *get_commit(unsigned char *sha1)
+static struct commit *get_commit(unsigned char *sha1)
{
struct commit *commit = lookup_commit(sha1);
if (!commit->object.parsed) {
diff --git a/init-db.c b/init-db.c
index b6bb78356762bd28261949da54638f46776e6d4b..a281f302eae9fdcc73273ddbb87e015f7f13b6c8 100644 (file)
--- a/init-db.c
+++ b/init-db.c
*/
#include "cache.h"
-void safe_create_dir(const char *dir)
+static void safe_create_dir(const char *dir)
{
if (mkdir(dir, 0755) < 0) {
if (errno != EEXIST) {
diff --git a/ls-files.c b/ls-files.c
index 214bd4a8d15611ec183191717e5457a6961a77e5..3b93d5e7cc7f7dd4ebed13a5cc1a4ad976fc94d8 100644 (file)
--- a/ls-files.c
+++ b/ls-files.c
e2->name, e2->len);
}
-static void show_killed_files()
+static void show_killed_files(void)
{
int i;
for (i = 0; i < nr_dir; i++) {
diff --git a/ls-tree.c b/ls-tree.c
index 30dfcddf74b2d97d9ee2d54bfbb5bfa5cb3160ee..0f455c2e5486bf1f4755d3656d2af0b6d5270a0d 100644 (file)
--- a/ls-tree.c
+++ b/ls-tree.c
*/
#include "cache.h"
-int line_termination = '\n';
-int recursive = 0;
+static int line_termination = '\n';
+static int recursive = 0;
struct path_prefix {
struct path_prefix *prev;
void *buffer;
unsigned long size;
- buffer = read_object_with_reference(sha1, "tree", &size, 0);
+ buffer = read_object_with_reference(sha1, "tree", &size, NULL);
if (!buffer)
die("unable to read sha1 file");
list_recursive(buffer, "tree", size, NULL);
diff --git a/merge-base.c b/merge-base.c
index 04f40fc8c57b2531393532e9f62de229a07224a4..12ebb95fba51ee9bba9767b25c999bd3de9ebd94 100644 (file)
--- a/merge-base.c
+++ b/merge-base.c
return NULL;
}
-struct commit *common_ancestor(struct commit *rev1, struct commit *rev2)
+static struct commit *common_ancestor(struct commit *rev1, struct commit *rev2)
{
struct commit_list *rev1list = NULL;
struct commit_list *rev2list = NULL;
diff --git a/read-tree.c b/read-tree.c
index c5f26d5f801504f24d734d8cd84d931769bf54c5..283f4d8577261645d0f5e2d85b7f74f13b848f79 100644 (file)
--- a/read-tree.c
+++ b/read-tree.c
unsigned long size;
int ret;
- buffer = read_object_with_reference(sha1, "tree", &size, 0);
+ buffer = read_object_with_reference(sha1, "tree", &size, NULL);
if (!buffer)
return -1;
ret = read_tree(buffer, size, stage);
diff --git a/rev-tree.c b/rev-tree.c
index f7dc98b1aaacacedeef059b3424d0a42259bb9b8..bc190ebc71bbd923f2b728e505408f5e54bd073a 100644 (file)
--- a/rev-tree.c
+++ b/rev-tree.c
return 1;
}
-void process_commit(unsigned char *sha1)
+static void process_commit(unsigned char *sha1)
{
struct commit_list *parents;
struct commit *obj = lookup_commit(sha1);
index 223bdd81f3303f4f6fd7493f94a8f7f39aacffee..17d5ab8a60ab2ec7fa3a7dc927351e8a34de3a89 100644 (file)
--- a/rpush.c
+++ b/rpush.c
#include <sys/socket.h>
#include <errno.h>
-void service(int fd_in, int fd_out) {
+static void service(int fd_in, int fd_out) {
ssize_t size;
int posn;
char unsigned sha1[20];
diff --git a/sha1_file.c b/sha1_file.c
index 83bc38c91fcfb8c6633be2ed1ee987fc41556e95..ece9dff80d5dd0e64508e93bf3bc1611a954cbea 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
return 0;
}
-int get_sha1_file(const char *path, unsigned char *result)
+static int get_sha1_file(const char *path, unsigned char *result)
{
char buffer[60];
int fd = open(path, O_RDONLY);
{
int pass, totlen, i;
const char *cp, *last;
- char *op = 0;
+ char *op = NULL;
const char *alt = gitenv(ALTERNATE_DB_ENVIRONMENT) ? : "";
/* The first pass counts how large an area to allocate to
if (pass)
break;
alt_odb = xmalloc(sizeof(*alt_odb) * (i + 1) + totlen);
- alt_odb[i].base = alt_odb[i].name = 0;
+ alt_odb[i].base = alt_odb[i].name = NULL;
op = (char*)(&alt_odb[i+1]);
}
}
diff --git a/strbuf.c b/strbuf.c
index 672a1e409760d33ad704cec098af3864f06a3a38..9d9d8bed915483abbc2ebb340e0881ae4e296bd4 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
#include "cache.h"
void strbuf_init(struct strbuf *sb) {
- sb->buf = 0;
+ sb->buf = NULL;
sb->eof = sb->alloc = sb->len = 0;
}
diff --git a/tar-tree.c b/tar-tree.c
index ccc39c92a0416fa12a1e261b4a147139dc710b2c..233a25616e39ee40199d12a75cea76c11246385f 100644 (file)
--- a/tar-tree.c
+++ b/tar-tree.c
}
/* get commit time from committer line of commit object */
-time_t commit_time(void * buffer, unsigned long size)
+static time_t commit_time(void * buffer, unsigned long size)
{
time_t result = 0;
char *p = buffer;
diff --git a/update-cache.c b/update-cache.c
index a9569533e12978041100e6013c3c3f3161c002b0..e76fb9b21e91440aba85ba3c039c4e6e9a8980fb 100644 (file)
--- a/update-cache.c
+++ b/update-cache.c
return add_cache_entry(ce, option);
}
-struct cache_file cache_file;
+static struct cache_file cache_file;
int main(int argc, char **argv)
{