db/fixup_kernel.sh: fix clear_user() handling
[smatch.git] / smatch_scripts / new_bugs.pl
blob875d4ac15d5f691a18f79f15d5b9a18d7d50efaa
1 #!/usr/bin/perl
3 use strict;
5 my $store = 0;
6 my $unstore = 0;
7 my $warns_dir = "old_warnings/";
9 my $warns_file;
11 while (my $arg = shift) {
12 if ($arg =~ /-d/) {
13 $warns_dir = shift;
14 next;
16 if ($arg =~ /--store/) {
17 $store = 1;
18 next;
20 if ($arg =~ /--unstore/) {
21 $unstore = 1;
22 next;
24 $warns_file = $arg;
25 last;
28 my $du = `du $warns_file`;
29 $du =~ s/([0-9]+).*/$1/;
30 $du =~ s/\n//;
32 if (int($du) > 100000) {
33 print "$warns_file is too big\n";
34 exit(1);
37 open(WARNS, $warns_file);
39 my ($orig, $file, $line, $msg);
40 while (<WARNS>) {
42 if (!($_ =~ /(error|warn|info)/)) {
43 next;
46 $orig = $_;
47 ($file, $line, $msg) = split(/[: ]/, $_, 3);
49 $msg =~ s/^.*?:\d+(|:\d+:) .*? //;
50 $msg =~ s/[us](16|32|64)(min|max)//g;
51 $msg =~ s/[01234567890]//g;
52 if ($msg =~ /can't/) {
53 $msg =~ s/(.*can't.*').*?('.*)/$1 $2/;
54 } elsif ($msg =~ /don't/) {
55 $msg =~ s/(.*don't.*').*?('.*)/$1 $2/;
56 } else {
57 $msg =~ s/'.*?'/''/g;
59 $msg =~ s/,//g;
60 $msg =~ s/\(\w+ returns null\)/(... returns null)/;
61 $msg =~ s/dma on the stack \(.*?\)/dma on the stack (...)/;
62 $msg =~ s/possible ERR_PTR '' to .*/possible ERR_PTR '' to .../;
63 $msg =~ s/inconsistent returns ([^ ]+?) locked \(\)/inconsistent returns ... locked ()/;
64 $msg =~ s/(.*) [^ ]* (too large for) [^ ]+ (.*)/$1 $2 $3/;
65 $msg =~ s/\n//;
66 $msg =~ s/ /_/g;
67 $msg =~ s/[\(\)]//g;
69 $file =~ s/\//./g;
70 $msg =~ s/\//./g;
72 if ($store) {
73 unless(-e "$warns_dir/" or mkdir "$warns_dir/") {
74 die "Unable to create $warns_dir";
76 open(TMP, '>', "$warns_dir/$file.$msg") or
77 die "Error opening: $warns_dir/$file.$msg\n";
78 close(TMP);
79 next;
82 if ($unstore) {
83 unlink("$warns_dir/$file.$msg") and
84 print "removed: $warns_dir/$file.$msg\n";
85 next;
88 unless (-e "$warns_dir/$file.$msg") {
89 print "$orig";
93 close(WARNS);