diff options
author | Andy Whitcroft <apw@shadowen.org> | 2008-10-16 01:02:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:35 -0400 |
commit | 6ecd967444223cea4a02d55fdc0f0510baa69523 (patch) | |
tree | 852a9a63f4dc4f13dd07126c81209d595e51097f /scripts | |
parent | e09dec4831bbb319987215ea0a280b2a620021b7 (diff) |
checkpatch: report any absolute references to kernel source files
Absolute references to kernel source files are generally only useful
locally to the originator of the patch. Check for any such references and
report them.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/checkpatch.pl | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 9e7e9d1d5958..cc61cf7187ef 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -958,6 +958,33 @@ sub CHK { | |||
958 | } | 958 | } |
959 | } | 959 | } |
960 | 960 | ||
961 | sub check_absolute_file { | ||
962 | my ($absolute, $herecurr) = @_; | ||
963 | my $file = $absolute; | ||
964 | |||
965 | ##print "absolute<$absolute>\n"; | ||
966 | |||
967 | # See if any suffix of this path is a path within the tree. | ||
968 | while ($file =~ s@^[^/]*/@@) { | ||
969 | if (-f "$root/$file") { | ||
970 | ##print "file<$file>\n"; | ||
971 | last; | ||
972 | } | ||
973 | } | ||
974 | if (! -f _) { | ||
975 | return 0; | ||
976 | } | ||
977 | |||
978 | # It is, so see if the prefix is acceptable. | ||
979 | my $prefix = $absolute; | ||
980 | substr($prefix, -length($file)) = ''; | ||
981 | |||
982 | ##print "prefix<$prefix>\n"; | ||
983 | if ($prefix ne ".../") { | ||
984 | WARN("use relative pathname instead of absolute in changelog text\n" . $herecurr); | ||
985 | } | ||
986 | } | ||
987 | |||
961 | sub process { | 988 | sub process { |
962 | my $filename = shift; | 989 | my $filename = shift; |
963 | 990 | ||
@@ -1168,6 +1195,20 @@ sub process { | |||
1168 | $herecurr) if (!$emitted_corrupt++); | 1195 | $herecurr) if (!$emitted_corrupt++); |
1169 | } | 1196 | } |
1170 | 1197 | ||
1198 | # Check for absolute kernel paths. | ||
1199 | if ($tree) { | ||
1200 | while ($line =~ m{(?:^|\s)(/\S*)}g) { | ||
1201 | my $file = $1; | ||
1202 | |||
1203 | if ($file =~ m{^(.*?)(?::\d+)+:?$} && | ||
1204 | check_absolute_file($1, $herecurr)) { | ||
1205 | # | ||
1206 | } else { | ||
1207 | check_absolute_file($file, $herecurr); | ||
1208 | } | ||
1209 | } | ||
1210 | } | ||
1211 | |||
1171 | # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php | 1212 | # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php |
1172 | if (($realfile =~ /^$/ || $line =~ /^\+/) && | 1213 | if (($realfile =~ /^$/ || $line =~ /^\+/) && |
1173 | $rawline !~ m/^$UTF8*$/) { | 1214 | $rawline !~ m/^$UTF8*$/) { |