summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/checkpatch.pl13
1 files changed, 10 insertions, 3 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b1befa2cec26..d2c074feaa7d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5922,7 +5922,8 @@ sub process {
5922 5922
5923# check for k[mz]alloc with multiplies that could be kmalloc_array/kcalloc 5923# check for k[mz]alloc with multiplies that could be kmalloc_array/kcalloc
5924 if ($^V && $^V ge 5.10.0 && 5924 if ($^V && $^V ge 5.10.0 &&
5925 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)\s*,/) { 5925 defined $stat &&
5926 $stat =~ /^\+\s*($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)\s*,/) {
5926 my $oldfunc = $3; 5927 my $oldfunc = $3;
5927 my $a1 = $4; 5928 my $a1 = $4;
5928 my $a2 = $10; 5929 my $a2 = $10;
@@ -5936,11 +5937,17 @@ sub process {
5936 } 5937 }
5937 if ($r1 !~ /^sizeof\b/ && $r2 =~ /^sizeof\s*\S/ && 5938 if ($r1 !~ /^sizeof\b/ && $r2 =~ /^sizeof\s*\S/ &&
5938 !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*$/)) { 5939 !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*$/)) {
5940 my $ctx = '';
5941 my $herectx = $here . "\n";
5942 my $cnt = statement_rawlines($stat);
5943 for (my $n = 0; $n < $cnt; $n++) {
5944 $herectx .= raw_line($linenr, $n) . "\n";
5945 }
5939 if (WARN("ALLOC_WITH_MULTIPLY", 5946 if (WARN("ALLOC_WITH_MULTIPLY",
5940 "Prefer $newfunc over $oldfunc with multiply\n" . $herecurr) && 5947 "Prefer $newfunc over $oldfunc with multiply\n" . $herectx) &&
5948 $cnt == 1 &&
5941 $fix) { 5949 $fix) {
5942 $fixed[$fixlinenr] =~ s/\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/$1 . ' = ' . "$newfunc(" . trim($r1) . ', ' . trim($r2)/e; 5950 $fixed[$fixlinenr] =~ s/\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/$1 . ' = ' . "$newfunc(" . trim($r1) . ', ' . trim($r2)/e;
5943
5944 } 5951 }
5945 } 5952 }
5946 } 5953 }