From 9dba021f90725bd3c961f8a2ff4fc19bc6c2c3c1 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 17 Apr 2013 19:23:39 +0300 Subject: [PATCH] db: store "too common" functions in the database When I query the database, it's annoying that the most common functions are not in there. With this change, it creates an entry for the common functions to show that we do know that they are called. Signed-off-by: Dan Carpenter --- smatch_data/db/create_db.sh | 2 +- smatch_data/db/fill_db_caller_info.pl | 23 ++++++++++++++++++++--- smatch_data/db/fill_db_sql.pl | 3 ++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/smatch_data/db/create_db.sh b/smatch_data/db/create_db.sh index b9a64323..f62edeb5 100755 --- a/smatch_data/db/create_db.sh +++ b/smatch_data/db/create_db.sh @@ -22,7 +22,7 @@ for i in ${bin_dir}/*.schema ; do done for i in ${bin_dir}/fill_* ; do - $i $info_file + $i "$PROJ" $info_file done if [ "$PROJ" != "" ] ; then diff --git a/smatch_data/db/fill_db_caller_info.pl b/smatch_data/db/fill_db_caller_info.pl index 78f92c21..3a708e10 100755 --- a/smatch_data/db/fill_db_caller_info.pl +++ b/smatch_data/db/fill_db_caller_info.pl @@ -6,13 +6,15 @@ use Scalar::Util qw(looks_like_number); sub usage() { - print "usage: $0 \n"; + print "usage: $0 \n"; exit(1); } my %too_common_funcs; -sub get_too_common_functions($) +sub get_too_common_functions($$$) { + my $path = shift; + my $project = shift; my $warns = shift; open(FUNCS, "cat $warns | grep 'SQL_caller_info: ' | grep '%call_marker%' | cut -d \"'\" -f 6 | sort | uniq -c | "); @@ -26,15 +28,26 @@ sub get_too_common_functions($) } close(FUNCS); + + open(FILE, "$path/../$project.common_functions"); + while () { + s/\n//; + $too_common_funcs{$_} = 1; + } + close(FILE); } +my $exec_name = $0; +my $path = $exec_name; +$path =~ s/(.*)\/.*/$1/; +my $project = shift; my $warns = shift; if (!defined($warns)) { usage(); } -get_too_common_functions($warns); +get_too_common_functions($path, $project, $warns); my $db = DBI->connect("dbi:SQLite:smatch_db.sqlite", "", "", {AutoCommit => 0}); $db->do("PRAGMA synchronous = OFF"); @@ -44,6 +57,10 @@ $db->do("PRAGMA count_changes = OFF"); $db->do("PRAGMA temp_store = MEMORY"); $db->do("PRAGMA locking = EXCLUSIVE"); +foreach my $func (keys %too_common_funcs) { + $db->do("insert into caller_info values ('unknown', 'too common', '$func', 0, 0, 0, -1, '', '');"); +} + my $call_id = 0; my ($fn, $dummy, $sql); diff --git a/smatch_data/db/fill_db_sql.pl b/smatch_data/db/fill_db_sql.pl index 92877a85..c4d4deb2 100755 --- a/smatch_data/db/fill_db_sql.pl +++ b/smatch_data/db/fill_db_sql.pl @@ -3,10 +3,11 @@ use strict; use DBI; +my $project = shift; my $warns = shift; if (!defined($warns)) { - print "usage: $0 \n"; + print "usage: $0 \n"; exit(1); } -- 2.11.4.GIT