From: Dan Carpenter Date: Mon, 11 Feb 2013 14:52:19 +0000 (+0300) Subject: db: move call_implies to use raw SQL X-Git-Tag: 1.59~352 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/563916adb96867db34a7bbf4f447757230629c30 db: move call_implies to use raw SQL Instead of printing human readable text and parsing it with fill_db_call_implies, just print raw SQL and parse it with fill_db_sql.pl. Signed-off-by: Dan Carpenter --- diff --git a/check_dereferences_param.c b/check_dereferences_param.c index 7f0c3b24..5e479a3d 100644 --- a/check_dereferences_param.c +++ b/check_dereferences_param.c @@ -102,7 +102,7 @@ static void process_states(struct state_list *slist) if (!arg->ident) continue; if (get_state_slist(slist, my_id, arg->ident->name, arg) == &derefed) - sm_msg("info: dereferences_param %d %s", i, global_static()); + sql_insert_call_implies(DEREFERENCE, i, 1); } END_FOR_EACH_PTR(arg); } diff --git a/smatch.h b/smatch.h index 17430d05..d26102db 100644 --- a/smatch.h +++ b/smatch.h @@ -502,6 +502,7 @@ void sql_insert_return_states(int return_id, const char *return_ranges, int type, int param, const char *key, const char *value); void sql_insert_function_ptr(const char *fn, const char *struct_name); void sql_insert_return_values(const char *return_values); +void sql_insert_call_implies(int type, int param, int value); void sql_exec(int (*callback)(void*, int, char**, char**), const char *sql); void open_smatch_db(void); diff --git a/smatch_db.c b/smatch_db.c index 06ebb5bc..6564909b 100644 --- a/smatch_db.c +++ b/smatch_db.c @@ -99,6 +99,12 @@ void sql_insert_return_values(const char *return_values) get_function(), fn_static(), return_values); } +void sql_insert_call_implies(int type, int param, int value) +{ + sql_insert(call_implies, "'%s', '%s', %d, %d, %d, %d", get_filename(), + get_function(), fn_static(), type, param, value); +} + void add_definition_db_callback(void (*callback)(const char *name, struct symbol *sym, char *key, char *value), int type) { struct def_callback *def_callback = __alloc_def_callback(0); diff --git a/smatch_scripts/db/fill_db_call_implies.pl b/smatch_scripts/db/fill_db_call_implies.pl deleted file mode 100755 index 90c071c7..00000000 --- a/smatch_scripts/db/fill_db_call_implies.pl +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use DBI; - -my $warns = shift; - -if (!defined($warns)) { - print "usage: $0 \n"; - exit(1); -} - -my $db = DBI->connect("dbi:SQLite:smatch_db.sqlite", "", "", {AutoCommit => 0}); -$db->do("PRAGMA synchronous = OFF"); -$db->do("PRAGMA cache_size = 800000"); -$db->do("PRAGMA journal_mode = OFF"); - -$db->do("delete from call_implies"); - -my $type = 6; # DEREFERENCE -open(WARNS, "<$warns"); -while () { - if (!($_ =~ /info: dereferences_param /)) { - next; - } - - s/\n//; - - my ($file_and_line, $file, $func, $dummy, $param, $value, $gs); - - # fs/buffer.c:62 list_add() info: dereferences_param 1 static - - $value = 1; - ($file_and_line, $func, $dummy, $dummy, $param, $gs) = split(/ /, $_); - ($file, $dummy) = split(/:/, $file_and_line); - $func =~ s/\(\)//; - - if (!defined($param)) { - next; - } - - my $static = 0; - if ($gs =~ /static/) { - $static = 1; - } - - # print "insert into call_implies values ('$file', '$func', $static, $type, $param, $value)\n"; - $db->do("insert into call_implies values ('$file', '$func', $static, $type, $param, $value)"); -} -close(WARNS); - -$db->commit(); -$db->disconnect();