Messages in this thread Patch in this message | | | Subject | [PATCH] checkpatch: Fix krealloc reuse test | From | Joe Perches <> | Date | Sun, 22 Jul 2018 10:51:16 -0700 |
| |
The current krealloc test does not function correctly when the temporary pointer return name contains the original pointer name.
Fix that by maximally matching the return pointer name and the original pointer name and doing a separate comparison of the both names.
Reported-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Joe Perches <joe@perches.com> CC: Manish Narani <manish.narani@xilinx.com> --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index ed4fa986e8da..59eaaede757a 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6149,7 +6149,8 @@ sub process { # check for krealloc arg reuse if ($perl_version_ok && - $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) { + $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*($Lval)\s*,/ && + $1 eq $3) { WARN("KREALLOC_ARG_REUSE", "Reusing the krealloc arg is almost always a bug\n" . $herecurr); }
| |