8 if (!defined($warns)) {
9 print "usage: $0 <warns.txt>\n";
13 my $db = DBI
->connect("dbi:SQLite:smatch_db.sqlite", "", "", {AutoCommit
=> 0});
14 $db->do("PRAGMA synchronous = OFF");
15 $db->do("PRAGMA cache_size = 800000");
16 $db->do("PRAGMA journal_mode = OFF");
18 $db->do("delete from return_states;");
22 my ($file_and_line, $file, $dummy, $func, $return_id, $return_value, $key, $value, $gs);
25 open(WARNS
, "<$warns");
28 if ($_ =~ /info: return_marker/) {
29 # net/ipv4/inet_diag.c:363 bitstring_match() info: return_marker 1 '1' static
32 ($file_and_line, $func, $dummy, $dummy, $return_id, $return_value, $gs) = split(/ /, $_);
35 } elsif ($_ =~ /info: returns_locked/) {
36 # net/ipv4/inet_diag.c:363 bitstring_match() info: returns_locked 1 '0' 'spin_lock:lock' static
37 $type = 9; # LOCK_HELD
39 ($file_and_line, $func, $dummy, $dummy, $return_id, $return_value, $key, $gs) = split(/ /, $_);
41 } elsif ($_ =~ /info: returns_released/) {
42 # net/ipv4/inet_diag.c:363 bitstring_match() info: returns_locked 1 '0' 'spin_lock:lock' static
43 $type = 10; # LOCK_RELEASED
45 ($file_and_line, $func, $dummy, $dummy, $return_id, $return_value, $key, $gs) = split(/ /, $_);
47 } elsif ($_ =~ /info: returns_user_data/) {
48 # net/netfilter/ipset/ip_set_hash_netiface.c:402 ip_set_get_h32() info: returns_user_data 1 '' static
49 $type = 3; # USER_DATA
52 ($file_and_line, $func, $dummy, $dummy, $return_id, $return_value, $gs) = split(/ /, $_);
54 } elsif ($_ =~ /info: return_allocation /) {
55 # drivers/net/usb/hso.c:2374 hso_create_device() info: return_allocation 2 'min-max' '456' static
58 ($file_and_line, $func, $dummy, $dummy, $return_id, $dummy) = split(/ /, $_);
59 ($dummy, $return_value, $dummy, $value, $gs) = split(/'/, $_);
65 ($file, $dummy) = split(/:/, $file_and_line);
68 $return_value =~ s/'//g;
73 if ($gs =~ /static/) {
77 $db->do("insert into return_states values ('$file', '$func', $return_id, '$return_value', $static, $type, $param, '$key', '$value')\n");