0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 use strict;
0011 use warnings;
0012 use POSIX;
0013 use File::Basename;
0014 use Cwd 'abs_path';
0015 use Term::ANSIColor ;
0016 use Encode ;
0017
0018 my $P = $0;
0019 my $D = dirname(abs_path($P));
0020
0021 my $V = '0.32';
0022
0023 use Getopt::Long ;
0024
0025 my $quiet = 0;
0026 my $verbose = 0;
0027 my %verbose_messages = ();
0028 my %verbose_emitted = ();
0029 my $tree = 1;
0030 my $chk_signoff = 1;
0031 my $chk_patch = 1;
0032 my $tst_only;
0033 my $emacs = 0;
0034 my $terse = 0;
0035 my $showfile = 0;
0036 my $file = 0;
0037 my $git = 0;
0038 my %git_commits = ();
0039 my $check = 0;
0040 my $check_orig = 0;
0041 my $summary = 1;
0042 my $mailback = 0;
0043 my $summary_file = 0;
0044 my $show_types = 0;
0045 my $list_types = 0;
0046 my $fix = 0;
0047 my $fix_inplace = 0;
0048 my $root;
0049 my $gitroot = $ENV{'GIT_DIR'};
0050 $gitroot = ".git" if !defined($gitroot);
0051 my %debug;
0052 my %camelcase = ();
0053 my %use_type = ();
0054 my @use = ();
0055 my %ignore_type = ();
0056 my @ignore = ();
0057 my $help = 0;
0058 my $configuration_file = ".checkpatch.conf";
0059 my $max_line_length = 100;
0060 my $ignore_perl_version = 0;
0061 my $minimum_perl_version = 5.10.0;
0062 my $min_conf_desc_length = 4;
0063 my $spelling_file = "$D/spelling.txt";
0064 my $codespell = 0;
0065 my $codespellfile = "/usr/share/codespell/dictionary.txt";
0066 my $user_codespellfile = "";
0067 my $conststructsfile = "$D/const_structs.checkpatch";
0068 my $docsfile = "$D/../Documentation/dev-tools/checkpatch.rst";
0069 my $typedefsfile;
0070 my $color = "auto";
0071 my $allow_c99_comments = 1;
0072
0073 my $git_command ='export LANGUAGE=en_US.UTF-8; git';
0074 my $tabsize = 8;
0075 my ${CONFIG_} = "CONFIG_";
0076
0077 sub help {
0078 my ($exitcode) = @_;
0079
0080 print << "EOM";
0081 Usage: $P [OPTION]... [FILE]...
0082 Version: $V
0083
0084 Options:
0085 -
0086 --verbose verbose mode
0087 --no-tree run without a kernel tree
0088 --no-signoff do not check for 'Signed-off-by' line
0089 --patch treat FILE as patchfile (default)
0090 --emacs emacs compile window format
0091 --terse one line per report
0092 --showfile emit diffed file position, not input file position
0093 -g, --git treat FILE as a single commit or git revision range
0094 single git commit with:
0095 <rev>
0096 <rev>^
0097 <rev>~n
0098 multiple git commits with:
0099 <rev1>..<rev2>
0100 <rev1>...<rev2>
0101 <rev>-<count>
0102 git merges are ignored
0103 -f, --file treat FILE as regular source file
0104 --subjective, --strict enable more subjective tests
0105 --list-types list the possible message types
0106 --types TYPE(,TYPE2...) show only these comma separated message types
0107 --ignore TYPE(,TYPE2...) ignore various comma separated message types
0108 --show-types show the specific message type in the output
0109 --max-line-length=n set the maximum line length, (default $max_line_length)
0110 if exceeded, warn on patches
0111 requires --strict for use with --file
0112 --min-conf-desc-length=n set the min description length, if shorter, warn
0113 --tab-size=n set the number of spaces for tab (default $tabsize)
0114 --root=PATH PATH to the kernel tree root
0115 --no-summary suppress the per-file summary
0116 --mailback only produce a report in case of warnings/errors
0117 --summary-file include the filename in summary
0118 --debug KEY=[0|1] turn on/off debugging of KEY, where KEY is one of
0119 'values', 'possible', 'type', and 'attr' (default
0120 is all off)
0121 --test-only=WORD report only warnings/errors containing WORD
0122 literally
0123 --fix EXPERIMENTAL - may create horrible results
0124 If correctable single-line errors exist, create
0125 " <inputfile