summaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2016-05-20 20:04:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-20 20:58:30 -0400
commit3beb42eced39c00011ba4d608d52718af765e5d4 (patch)
tree2f4638780f72ca9e6f6120fe31b88a698f04fc36 /scripts/checkpatch.pl
parentef212196369cbc2e694eab39261f9785ec252028 (diff)
checkpatch: add --list-types to show message types to show or ignore
The message types are not currently knowable without reading the code. Add a mechanism to see what they are. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl38
1 files changed, 37 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f09c3f28b0fe..c5a3c9513419 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -33,6 +33,7 @@ my $summary = 1;
33my $mailback = 0; 33my $mailback = 0;
34my $summary_file = 0; 34my $summary_file = 0;
35my $show_types = 0; 35my $show_types = 0;
36my $list_types = 0;
36my $fix = 0; 37my $fix = 0;
37my $fix_inplace = 0; 38my $fix_inplace = 0;
38my $root; 39my $root;
@@ -70,11 +71,12 @@ Options:
70 --showfile emit diffed file position, not input file position 71 --showfile emit diffed file position, not input file position
71 -f, --file treat FILE as regular source file 72 -f, --file treat FILE as regular source file
72 --subjective, --strict enable more subjective tests 73 --subjective, --strict enable more subjective tests
74 --list-types list the possible message types
73 --types TYPE(,TYPE2...) show only these comma separated message types 75 --types TYPE(,TYPE2...) show only these comma separated message types
74 --ignore TYPE(,TYPE2...) ignore various comma separated message types 76 --ignore TYPE(,TYPE2...) ignore various comma separated message types
77 --show-types show the specific message type in the output
75 --max-line-length=n set the maximum line length, if exceeded, warn 78 --max-line-length=n set the maximum line length, if exceeded, warn
76 --min-conf-desc-length=n set the min description length, if shorter, warn 79 --min-conf-desc-length=n set the min description length, if shorter, warn
77 --show-types show the message "types" in the output
78 --root=PATH PATH to the kernel tree root 80 --root=PATH PATH to the kernel tree root
79 --no-summary suppress the per-file summary 81 --no-summary suppress the per-file summary
80 --mailback only produce a report in case of warnings/errors 82 --mailback only produce a report in case of warnings/errors
@@ -106,6 +108,37 @@ EOM
106 exit($exitcode); 108 exit($exitcode);
107} 109}
108 110
111sub uniq {
112 my %seen;
113 return grep { !$seen{$_}++ } @_;
114}
115
116sub list_types {
117 my ($exitcode) = @_;
118
119 my $count = 0;
120
121 local $/ = undef;
122
123 open(my $script, '<', abs_path($P)) or
124 die "$P: Can't read '$P' $!\n";
125
126 my $text = <$script>;
127 close($script);
128
129 my @types = ();
130 for ($text =~ /\b(?:(?:CHK|WARN|ERROR)\s*\(\s*"([^"]+)")/g) {
131 push (@types, $_);
132 }
133 @types = sort(uniq(@types));
134 print("#\tMessage type\n\n");
135 foreach my $type (@types) {
136 print(++$count . "\t" . $type . "\n");
137 }
138
139 exit($exitcode);
140}
141
109my $conf = which_conf($configuration_file); 142my $conf = which_conf($configuration_file);
110if (-f $conf) { 143if (-f $conf) {
111 my @conf_args; 144 my @conf_args;
@@ -146,6 +179,7 @@ GetOptions(
146 'ignore=s' => \@ignore, 179 'ignore=s' => \@ignore,
147 'types=s' => \@use, 180 'types=s' => \@use,
148 'show-types!' => \$show_types, 181 'show-types!' => \$show_types,
182 'list-types!' => \$list_types,
149 'max-line-length=i' => \$max_line_length, 183 'max-line-length=i' => \$max_line_length,
150 'min-conf-desc-length=i' => \$min_conf_desc_length, 184 'min-conf-desc-length=i' => \$min_conf_desc_length,
151 'root=s' => \$root, 185 'root=s' => \$root,
@@ -166,6 +200,8 @@ GetOptions(
166 200
167help(0) if ($help); 201help(0) if ($help);
168 202
203list_types(0) if ($list_types);
204
169$fix = 1 if ($fix_inplace); 205$fix = 1 if ($fix_inplace);
170$check_orig = $check; 206$check_orig = $check;
171 207