sparse cleanup
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.
This commit is contained in:
parent
7ca45252a3
commit
e99d59ff0b
2
date.c
2
date.c
@ -10,6 +10,8 @@
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "cache.h"
|
||||
|
||||
static time_t my_mktime(struct tm *tm)
|
||||
{
|
||||
static const int mdays[] = {
|
||||
|
@ -204,11 +204,11 @@ int main(int argc, char **argv)
|
||||
|
||||
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))
|
||||
|
@ -86,7 +86,7 @@ int main(int argc, char **argv)
|
||||
|
||||
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;
|
||||
|
@ -79,7 +79,7 @@ static int parse_diff_raw_output(const char *buf)
|
||||
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;
|
||||
|
10
diff-tree.c
10
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);
|
||||
@ -273,7 +273,7 @@ static int diff_tree_sha1_top(const unsigned char *old,
|
||||
|
||||
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;
|
||||
@ -287,8 +287,8 @@ static int diff_root_tree(const unsigned char *new, const char *base)
|
||||
|
||||
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);
|
||||
|
6
diff.c
6
diff.c
@ -385,7 +385,7 @@ static void run_external_diff(const char *name,
|
||||
*arg++ = temp[1].mode;
|
||||
if (other)
|
||||
*arg++ = other;
|
||||
*arg = 0;
|
||||
*arg = NULL;
|
||||
execvp(pgm, (char *const*) exec_arg);
|
||||
}
|
||||
else
|
||||
@ -504,7 +504,7 @@ static void free_data(struct diff_spec_hold *s)
|
||||
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,
|
||||
@ -541,7 +541,7 @@ static int is_exact_match(struct diff_spec_hold *src,
|
||||
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
|
||||
|
8
export.c
8
export.c
@ -4,7 +4,7 @@
|
||||
/*
|
||||
* Show one commit
|
||||
*/
|
||||
void show_commit(struct commit *commit)
|
||||
static void show_commit(struct commit *commit)
|
||||
{
|
||||
char cmdline[400];
|
||||
char hex[100];
|
||||
@ -27,7 +27,7 @@ void show_commit(struct commit *commit)
|
||||
/*
|
||||
* Show all unseen commits, depth-first
|
||||
*/
|
||||
void show_unseen(struct commit *top)
|
||||
static void show_unseen(struct commit *top)
|
||||
{
|
||||
struct commit_list *parents;
|
||||
|
||||
@ -42,7 +42,7 @@ void show_unseen(struct commit *top)
|
||||
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)
|
||||
@ -50,7 +50,7 @@ void export(struct commit *top, struct commit *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) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#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) {
|
||||
|
@ -179,7 +179,7 @@ static int cmp_name(const void *p1, const void *p2)
|
||||
e2->name, e2->len);
|
||||
}
|
||||
|
||||
static void show_killed_files()
|
||||
static void show_killed_files(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nr_dir; i++) {
|
||||
|
@ -5,8 +5,8 @@
|
||||
*/
|
||||
#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;
|
||||
@ -73,7 +73,7 @@ static int list(unsigned char *sha1)
|
||||
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);
|
||||
|
@ -15,7 +15,7 @@ static struct commit *process_list(struct commit_list **list_p, int this_mark,
|
||||
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;
|
||||
|
@ -13,7 +13,7 @@ static int unpack_tree(unsigned char *sha1)
|
||||
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);
|
||||
|
@ -46,7 +46,7 @@ static int interesting(struct commit *rev)
|
||||
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);
|
||||
|
2
rpush.c
2
rpush.c
@ -3,7 +3,7 @@
|
||||
#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];
|
||||
|
@ -44,7 +44,7 @@ int get_sha1_hex(const char *hex, unsigned char *sha1)
|
||||
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);
|
||||
@ -199,7 +199,7 @@ static void prepare_alt_odb(void)
|
||||
{
|
||||
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
|
||||
@ -236,7 +236,7 @@ static void prepare_alt_odb(void)
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
2
strbuf.c
2
strbuf.c
@ -4,7 +4,7 @@
|
||||
#include "cache.h"
|
||||
|
||||
void strbuf_init(struct strbuf *sb) {
|
||||
sb->buf = 0;
|
||||
sb->buf = NULL;
|
||||
sb->eof = sb->alloc = sb->len = 0;
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ static void traverse_tree(void *buffer, unsigned long size,
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
@ -292,7 +292,7 @@ static int add_cacheinfo(char *arg1, char *arg2, char *arg3)
|
||||
return add_cache_entry(ce, option);
|
||||
}
|
||||
|
||||
struct cache_file cache_file;
|
||||
static struct cache_file cache_file;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user