131eab47db42bf575068631c764dad47ef9405ab
5 use Scalar
::Util
qw(looks_like_number);
9 print "usage: $0 <warns.txt>\n";
14 sub get_too_common_functions
($)
18 open(FUNCS
, "cat $warns | grep 'SQL_caller_info: ' | grep '%call_marker%' | cut -d \"'\" -f 6 | sort | uniq -c | ");
21 if ($_ =~ /(\d+) (.*)/) {
23 $too_common_funcs{$2} = 1;
33 if (!defined($warns)) {
37 get_too_common_functions
($warns);
39 my $db = DBI
->connect("dbi:SQLite:smatch_db.sqlite", "", "", {AutoCommit
=> 0});
40 $db->do("PRAGMA synchronous = OFF");
41 $db->do("PRAGMA cache_size = 800000");
42 $db->do("PRAGMA journal_mode = OFF");
45 my ($fn, $dummy, $sql);
47 open(WARNS
, "<$warns");
49 # test.c:11 frob() SQL_caller_info: insert into caller_info values ('test.c', 'frob', '__smatch_buf_size', %CALL_ID%, 1, 0, -1, '', ');
51 if (!($_ =~ /^.*? \w+\(\) SQL_caller_info: /)) {
54 ($dummy, $dummy, $dummy, $dummy, $dummy, $fn, $dummy) = split(/'/);
56 if ($fn =~ /__builtin_/) {
59 if ($fn =~ /(printk|memset|memcpy|kfree|printf|dev_err|writel)/) {
63 if (defined($too_common_funcs{$fn})) {
67 ($dummy, $dummy, $sql) = split(/:/);
69 $sql =~ s/%CALL_ID%/$call_id/;
70 if ($sql =~ /%call_marker%/) {
71 $sql =~ s/%call_marker%//; # don't need this taking space in the db.