History

checkpatch: enforce sane perl version

I got a bug report from a couple of users who said checkpatch.pl was broken for them. It was erroring out on fairly random lines most commonly with messages like: Nested quantifiers in regex; marked by <--HERE in m/(\((?:[^\(\)]++ <-- HERE |(?-1))*\))/ at ./checkpatch.pl line 340. The bug reporter was running a version of perl 5.8 which was end-of-lifed in 2008: http://www.cpan.org/src/. Versions of perl this old are at _best_ quite untested. At worst, they are crusty and known to be completely broken. If folks have a system _that_ old, then we should have mercy on them and give them a half-decent error message rather than fail with nutty error messages. This patch enforces that checkpatch.pl is run with perl 5.10, which was end-of-lifed in 2009. The new --ignore-perl-version command-line switch will let folks override this if they want.

Dave Hansen committed 13 years ago

Commit d62a2011 parent 7e781f61 file · +12 −0Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+12−0
@@ -37,6 +37,8 @@ my @ignore = (); · 36 unmodified lines
3737 my $help = 0;
3838 my $configuration_file = ".checkpatch.conf";
3939 my $max_line_length = 80;
40+my $ignore_perl_version = 0;
41+my $minimum_perl_version = 5.10.0;
4042
4143 sub help {
4244 my ($exitcode) = @_;
@@ -71,6 +73,8 @@ Options: · 28 unmodified lines
7173 "<inputfile>.EXPERIMENTAL-checkpatch-fixes"
7274 with potential errors corrected to the preferred
7375 checkpatch style
76+ --ignore-perl-version override checking of perl version. expect
77+ runtime errors.
7478 -h, --help, --version display this help and exit
7579
7680 When FILE is - read standard input.
@@ -123,6 +127,7 @@ GetOptions( · 46 unmodified lines
123127 'mailback!' => \$mailback,
124128 'summary-file!' => \$summary_file,
125129 'fix!' => \$fix,
130+ 'ignore-perl-version!' => \$ignore_perl_version,
126131 'debug=s' => \%debug,
127132 'test-only=s' => \$tst_only,
128133 'h|help' => \$help,
@@ -133,6 +138,13 @@ help(0) if ($help); · 4 unmodified lines
133138
134139 my $exit = 0;
135140
141+if ($^V && $^V lt $minimum_perl_version) {
142+ printf "$P: requires at least perl version %vd\n", $minimum_perl_version;
143+ if (!$ignore_perl_version) {
144+ exit(1);
145+ }
146+}
147+
136148 if ($#ARGV < 0) {
137149 print "$P: no input files\n";
138150 exit(1);