From ee85db41a447a5d03237d48e4803bc459c8a2644 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 19 Mar 2009 01:21:25 +0300 Subject: [PATCH] make some vars static. other random sparse stuff. Signed-off-by: Dan Carpenter --- check_locking.c | 2 +- check_memory.c | 2 +- check_null_deref.c | 4 ++-- smatch.c | 4 ++-- smatch_flow.c | 10 +++++----- smatch_ignore.c | 2 +- smatch_implied.c | 4 ++-- smatch_slist.c | 4 +++- smatch_slist.h | 2 +- 9 files changed, 18 insertions(+), 16 deletions(-) diff --git a/check_locking.c b/check_locking.c index eef7a71c..b8802a0f 100644 --- a/check_locking.c +++ b/check_locking.c @@ -330,7 +330,7 @@ static void check_returns_consistently(struct tracker *lock, } -static void clear_lists() +static void clear_lists(void) { struct locks_on_return *tmp; diff --git a/check_memory.c b/check_memory.c index 8d3a3d01..add230c0 100644 --- a/check_memory.c +++ b/check_memory.c @@ -256,7 +256,7 @@ static int possibly_allocated(struct state_list *slist) return 0; } -static void check_for_allocated() +static void check_for_allocated(void) { struct state_list *slist; struct sm_state *tmp; diff --git a/check_null_deref.c b/check_null_deref.c index 2a89843a..e0f3513b 100644 --- a/check_null_deref.c +++ b/check_null_deref.c @@ -14,7 +14,7 @@ /* * TODO: The return_null list of functions should be determined automatically */ -const char *return_null[] = { +static const char *return_null[] = { "kmalloc", }; @@ -402,7 +402,7 @@ static void match_dereferences(struct expression *expr) free_string(deref); } -static void end_file_processing() +static void end_file_processing(void) { struct func_n_param *param1, *param2; diff --git a/smatch.c b/smatch.c index e643edaa..d9f4d0d1 100644 --- a/smatch.c +++ b/smatch.c @@ -22,7 +22,7 @@ void check_frees_argument(int id); /* <- your test goes here */ /* void register_template(int id); */ -const reg_func reg_funcs[] = { +static const reg_func reg_funcs[] = { ®ister_smatch_extra, /* smatch_extra always has to be first */ ®ister_smatch_ignore, &check_null_deref, @@ -38,7 +38,7 @@ const reg_func reg_funcs[] = { NULL }; -void help() +static void help(void) { printf("Usage: smatch [smatch arguments][sparse arguments] file.c\n"); printf("--debug: print lots of debug output.\n"); diff --git a/smatch_flow.c b/smatch_flow.c index 9d09fd2f..fddcc366 100644 --- a/smatch_flow.c +++ b/smatch_flow.c @@ -11,16 +11,16 @@ #include "token.h" #include "smatch.h" -int __smatch_lineno = 0; +static int __smatch_lineno = 0; static char *filename; static char *cur_func; static int line_func_start; -char *get_filename() { return filename; } -char *get_function() { return cur_func; } -int get_lineno() { return __smatch_lineno; } -int get_func_pos() { return __smatch_lineno - line_func_start; } +char *get_filename(void) { return filename; } +char *get_function(void) { return cur_func; } +int get_lineno(void) { return __smatch_lineno; } +int get_func_pos(void) { return __smatch_lineno - line_func_start; } static void split_symlist(struct symbol_list *sym_list); static void split_expr_list(struct expression_list *expr_list); diff --git a/smatch_ignore.c b/smatch_ignore.c index bf866619..cf73a001 100644 --- a/smatch_ignore.c +++ b/smatch_ignore.c @@ -25,7 +25,7 @@ int is_ignored(const char *name, int owner, struct symbol *sym) return 0; } -static void clear_ignores() +static void clear_ignores(void) { __free_ptr_list((struct ptr_list **)&ignored); } diff --git a/smatch_implied.c b/smatch_implied.c index cbb7be83..90bcc4a8 100644 --- a/smatch_implied.c +++ b/smatch_implied.c @@ -102,8 +102,8 @@ static int pool_in_pools(struct state_list_stack *pools, return 0; } -struct state_list *clone_states_in_pool(struct state_list *pool, - struct state_list *cur_slist) +static struct state_list *clone_states_in_pool(struct state_list *pool, + struct state_list *cur_slist) { struct sm_state *state; struct sm_state *cur_state; diff --git a/smatch_slist.c b/smatch_slist.c index d6f0c497..4909014d 100644 --- a/smatch_slist.c +++ b/smatch_slist.c @@ -169,7 +169,7 @@ static void free_all_sm_states(struct allocation_blob *blob) } /* At the end of every function we free all the sm_states */ -void free_every_single_sm_state() +void free_every_single_sm_state(void) { struct allocator_struct *desc = &sm_state_allocator; struct allocation_blob *blob = desc->blobs; @@ -359,6 +359,8 @@ struct sm_state *merge_sm_states(struct sm_state *one, struct sm_state *two) s = merge_states(one->name, one->owner, one->sym, one->state, (two?two->state:NULL)); result = alloc_state(one->name, one->owner, one->sym, s); + if (two && one->line == two->line) + result->line = one->line; add_possible(result, one); add_possible(result, two); copy_pools(result, one); diff --git a/smatch_slist.h b/smatch_slist.h index 490f7fa1..bf0172db 100644 --- a/smatch_slist.h +++ b/smatch_slist.h @@ -16,7 +16,7 @@ struct sm_state *alloc_state(const char *name, int owner, struct symbol *sym, struct smatch_state *state); -void free_every_single_sm_state(); +void free_every_single_sm_state(void); struct sm_state *clone_state(struct sm_state *s); struct state_list *clone_slist(struct state_list *from_slist); struct state_list_stack *clone_stack(struct state_list_stack *from_stack); -- 2.11.4.GIT