fill_db_function_ptr: fixup formatting changes fallout
[smatch.git] / smatch_scripts / db / fill_db_function_ptr.pl
blobf9c15150b144f4702bb92eb2b51c86a76dcaa5da
1 #!/usr/bin/perl -w
3 use strict;
4 use DBI;
6 my $warns = shift;
8 if (!defined($warns)) {
9 print "usage: $0 <warns.txt>\n";
10 exit(1);
13 my $db = DBI->connect("dbi:SQLite:smatch_db.sqlite", "", "", {RaiseError => 1, AutoCommit => 0});
14 $db->do("PRAGMA synchronous = OFF");
15 $db->do("PRAGMA cache_size = 800000");
17 $db->do("delete from function_ptr;");
19 open(WARNS, "<$warns");
20 while (<WARNS>) {
21 if (!($_ =~ /info: sets_fn_ptr /)) {
22 next;
25 # kernel/ksysfs.c +87 (null)(87) info: sets_fn_ptr '(struct kobj_attribute)->show' 'profiling_show'
27 s/\n//;
29 my ($file_and_line, $file, $dummy, $struct_bit, $func, $ptr);
30 ($file_and_line, $dummy, $dummy, $dummy, $struct_bit, $ptr, $func) = split(/ /, $_);
31 ($file, $dummy) = split(/:/, $file_and_line);
33 if (!defined($func)) {
34 next;
36 if (!($struct_bit =~ /^'\(struct$/)) {
37 next;
39 if (!($func =~ /^'[\w_]+'$/)) {
40 next;
43 $struct_bit =~ s/'//;
44 $ptr =~ s/'//;
45 $func =~ s/'//g;
47 $db->do("insert into function_ptr values ('$file', '$func', '$struct_bit $ptr')\n");
49 $db->commit();
50 $db->disconnect();