aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorTobin C. Harding <me@tobin.cc>2018-04-10 19:33:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-11 13:28:35 -0400
commit2a9f9d851c602b6ef0d0a52fb1996772edf218cb (patch)
tree4a1043a371836311629bc80af99b5a229e1b3983 /scripts
parent3d102fc0e7b02d4e16752c15aa92923405b01388 (diff)
checkpatch: add sub routine get_stat_real()
checkpatch currently contains duplicate code. We can define a sub routine and call that instead. This reduces code duplication and line count. Add subroutine get_stat_real() Link: http://lkml.kernel.org/r/1519700648-23108-2-git-send-email-me@tobin.cc Signed-off-by: Tobin C. Harding <me@tobin.cc> Cc: 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')
-rwxr-xr-xscripts/checkpatch.pl32
1 files changed, 16 insertions, 16 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 43322bd8f66a..a0808e46c6fe 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1645,6 +1645,17 @@ sub raw_line {
1645 return $line; 1645 return $line;
1646} 1646}
1647 1647
1648sub get_stat_real {
1649 my ($linenr, $lc) = @_;
1650
1651 my $stat_real = raw_line($linenr, 0);
1652 for (my $count = $linenr + 1; $count <= $lc; $count++) {
1653 $stat_real = $stat_real . "\n" . raw_line($count, 0);
1654 }
1655
1656 return $stat_real;
1657}
1658
1648sub cat_vet { 1659sub cat_vet {
1649 my ($vet) = @_; 1660 my ($vet) = @_;
1650 my ($res, $coded); 1661 my ($res, $coded);
@@ -5821,17 +5832,15 @@ sub process {
5821 } 5832 }
5822 } 5833 }
5823 if ($bad_extension ne "") { 5834 if ($bad_extension ne "") {
5824 my $stat_real = raw_line($linenr, 0); 5835 my $stat_real = get_stat_real($linenr, $lc);
5825 my $ext_type = "Invalid"; 5836 my $ext_type = "Invalid";
5826 my $use = ""; 5837 my $use = "";
5827 for (my $count = $linenr + 1; $count <= $lc; $count++) {
5828 $stat_real = $stat_real . "\n" . raw_line($count, 0);
5829 }
5830 if ($bad_extension =~ /p[Ff]/) { 5838 if ($bad_extension =~ /p[Ff]/) {
5831 $ext_type = "Deprecated"; 5839 $ext_type = "Deprecated";
5832 $use = " - use %pS instead"; 5840 $use = " - use %pS instead";
5833 $use =~ s/pS/ps/ if ($bad_extension =~ /pf/); 5841 $use =~ s/pS/ps/ if ($bad_extension =~ /pf/);
5834 } 5842 }
5843
5835 WARN("VSPRINTF_POINTER_EXTENSION", 5844 WARN("VSPRINTF_POINTER_EXTENSION",
5836 "$ext_type vsprintf pointer extension '$bad_extension'$use\n" . "$here\n$stat_real\n"); 5845 "$ext_type vsprintf pointer extension '$bad_extension'$use\n" . "$here\n$stat_real\n");
5837 } 5846 }
@@ -5946,10 +5955,7 @@ sub process {
5946 $stat !~ /(?:$Compare)\s*\bsscanf\s*$balanced_parens/)) { 5955 $stat !~ /(?:$Compare)\s*\bsscanf\s*$balanced_parens/)) {
5947 my $lc = $stat =~ tr@\n@@; 5956 my $lc = $stat =~ tr@\n@@;
5948 $lc = $lc + $linenr; 5957 $lc = $lc + $linenr;
5949 my $stat_real = raw_line($linenr, 0); 5958 my $stat_real = get_stat_real($linenr, $lc);
5950 for (my $count = $linenr + 1; $count <= $lc; $count++) {
5951 $stat_real = $stat_real . "\n" . raw_line($count, 0);
5952 }
5953 WARN("NAKED_SSCANF", 5959 WARN("NAKED_SSCANF",
5954 "unchecked sscanf return value\n" . "$here\n$stat_real\n"); 5960 "unchecked sscanf return value\n" . "$here\n$stat_real\n");
5955 } 5961 }
@@ -5960,10 +5966,7 @@ sub process {
5960 $line =~ /\bsscanf\b/) { 5966 $line =~ /\bsscanf\b/) {
5961 my $lc = $stat =~ tr@\n@@; 5967 my $lc = $stat =~ tr@\n@@;
5962 $lc = $lc + $linenr; 5968 $lc = $lc + $linenr;
5963 my $stat_real = raw_line($linenr, 0); 5969 my $stat_real = get_stat_real($linenr, $lc);
5964 for (my $count = $linenr + 1; $count <= $lc; $count++) {
5965 $stat_real = $stat_real . "\n" . raw_line($count, 0);
5966 }
5967 if ($stat_real =~ /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) { 5970 if ($stat_real =~ /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) {
5968 my $format = $6; 5971 my $format = $6;
5969 my $count = $format =~ tr@%@%@; 5972 my $count = $format =~ tr@%@%@;
@@ -6397,10 +6400,7 @@ sub process {
6397 6400
6398 my $lc = $stat =~ tr@\n@@; 6401 my $lc = $stat =~ tr@\n@@;
6399 $lc = $lc + $linenr; 6402 $lc = $lc + $linenr;
6400 my $stat_real = raw_line($linenr, 0); 6403 my $stat_real = get_stat_real($linenr, $lc);
6401 for (my $count = $linenr + 1; $count <= $lc; $count++) {
6402 $stat_real = $stat_real . "\n" . raw_line($count, 0);
6403 }
6404 6404
6405 my $skip_args = ""; 6405 my $skip_args = "";
6406 if ($arg_pos > 1) { 6406 if ($arg_pos > 1) {