[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e617ecb8c019a9c4c56540a1bec16c8aed43a4e4.camel@perches.com>
Date: Sun, 22 Jul 2018 10:51:16 -0700
From: Joe Perches <joe@...ches.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Andy Whitcroft <apw@...onical.com>
Cc: anirudh@...inx.com, sgoud@...inx.com, svemula@...inx.com,
Lars-Peter Clausen <lars@...afoo.de>,
Manish Narani <manish.narani@...inx.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] checkpatch: Fix krealloc reuse test
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@...afoo.de>
Signed-off-by: Joe Perches <joe@...ches.com>
CC: Manish Narani <manish.narani@...inx.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);
}
Powered by blists - more mailing lists