* [PATCH 0/2] checkpatch: Document --fix capabilities a bit more
@ 2016-04-13 3:50 Joe Perches
2016-04-13 3:50 ` [PATCH 1/2] checkpatch: Advertise the --fix and --fix-inplace options more Joe Perches
2016-04-13 3:50 ` [PATCH 2/2] checkpatch: Add --list-types to show message types to show or ignore Joe Perches
0 siblings, 2 replies; 3+ messages in thread
From: Joe Perches @ 2016-04-13 3:50 UTC (permalink / raw)
To: Andrew Morton, linux-kernel; +Cc: Oleg Drokin, Andy Whitcroft
The --fix option isn't well known so try to make it a bit more obvious.
Joe Perches (2):
checkpatch: Advertise the --fix and --fix-inplace options more
checkpatch: Add --list-types to show message types to show or ignore
scripts/checkpatch.pl | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
--
2.8.0.rc4.16.g56331f8
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] checkpatch: Advertise the --fix and --fix-inplace options more
2016-04-13 3:50 [PATCH 0/2] checkpatch: Document --fix capabilities a bit more Joe Perches
@ 2016-04-13 3:50 ` Joe Perches
2016-04-13 3:50 ` [PATCH 2/2] checkpatch: Add --list-types to show message types to show or ignore Joe Perches
1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2016-04-13 3:50 UTC (permalink / raw)
To: Andrew Morton, Andy Whitcroft; +Cc: Oleg Drokin, linux-kernel
The --fix option is relatively unknown and underutilized.
Add some text to show that it's available when style defects are found.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e3d9c34..c87913f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5940,6 +5940,14 @@ sub process {
}
if ($quiet == 0) {
+ # If there were any defects found and not already fixing them
+ if (!$clean and !$fix) {
+ print << "EOM"
+
+NOTE: For some of the reported defects, checkpatch may be able to
+ mechanically convert to the typical style using --fix or --fix-inplace.
+EOM
+ }
# If there were whitespace errors which cleanpatch can fix
# then suggest that.
if ($rpt_cleaners) {
--
2.8.0.rc4.16.g56331f8
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] checkpatch: Add --list-types to show message types to show or ignore
2016-04-13 3:50 [PATCH 0/2] checkpatch: Document --fix capabilities a bit more Joe Perches
2016-04-13 3:50 ` [PATCH 1/2] checkpatch: Advertise the --fix and --fix-inplace options more Joe Perches
@ 2016-04-13 3:50 ` Joe Perches
1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2016-04-13 3:50 UTC (permalink / raw)
To: Andrew Morton, Andy Whitcroft; +Cc: Oleg Drokin, linux-kernel
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>
---
scripts/checkpatch.pl | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index c87913f..abcafdb 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -33,6 +33,7 @@ my $summary = 1;
my $mailback = 0;
my $summary_file = 0;
my $show_types = 0;
+my $list_types = 0;
my $fix = 0;
my $fix_inplace = 0;
my $root;
@@ -70,11 +71,12 @@ Options:
--showfile emit diffed file position, not input file position
-f, --file treat FILE as regular source file
--subjective, --strict enable more subjective tests
+ --list-types list the possible message types
--types TYPE(,TYPE2...) show only these comma separated message types
--ignore TYPE(,TYPE2...) ignore various comma separated message types
+ --show-types show the specific message type in the output
--max-line-length=n set the maximum line length, if exceeded, warn
--min-conf-desc-length=n set the min description length, if shorter, warn
- --show-types show the message "types" in the output
--root=PATH PATH to the kernel tree root
--no-summary suppress the per-file summary
--mailback only produce a report in case of warnings/errors
@@ -106,6 +108,37 @@ EOM
exit($exitcode);
}
+sub uniq {
+ my %seen;
+ return grep { !$seen{$_}++ } @_;
+}
+
+sub list_types {
+ my ($exitcode) = @_;
+
+ my $count = 0;
+
+ local $/ = undef;
+
+ open(my $script, '<', abs_path($P)) or
+ die "$P: Can't read '$P' $!\n";
+
+ my $text = <$script>;
+ close($script);
+
+ my @types = ();
+ for ($text =~ /\b(?:(?:CHK|WARN|ERROR)\s*\(\s*"([^"]+)")/g) {
+ push (@types, $_);
+ }
+ @types = sort(uniq(@types));
+ print("#\tMessage type\n\n");
+ foreach my $type (@types) {
+ print(++$count . "\t" . $type . "\n");
+ }
+
+ exit($exitcode);
+}
+
my $conf = which_conf($configuration_file);
if (-f $conf) {
my @conf_args;
@@ -146,6 +179,7 @@ GetOptions(
'ignore=s' => \@ignore,
'types=s' => \@use,
'show-types!' => \$show_types,
+ 'list-types!' => \$list_types,
'max-line-length=i' => \$max_line_length,
'min-conf-desc-length=i' => \$min_conf_desc_length,
'root=s' => \$root,
@@ -166,6 +200,8 @@ GetOptions(
help(0) if ($help);
+list_types(0) if ($list_types);
+
$fix = 1 if ($fix_inplace);
$check_orig = $check;
--
2.8.0.rc4.16.g56331f8
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-13 3:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-13 3:50 [PATCH 0/2] checkpatch: Document --fix capabilities a bit more Joe Perches
2016-04-13 3:50 ` [PATCH 1/2] checkpatch: Advertise the --fix and --fix-inplace options more Joe Perches
2016-04-13 3:50 ` [PATCH 2/2] checkpatch: Add --list-types to show message types to show or ignore Joe Perches
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.