[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1393767319.13719.23.camel@joe-AO722>
Date: Sun, 02 Mar 2014 05:35:19 -0800
From: Joe Perches <joe@...ches.com>
To: Lars-Peter Clausen <lars@...afoo.de>
Cc: Andy Whitcroft <apw@...dowen.org>,
Fengguang Wu <fengguang.wu@...el.com>,
Jonathan Cameron <jic23@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [iio:togreg 3/3] WARNING: Reusing the krealloc arg is almost
always a bug
That last one doesn't work if the krealloc has a cast like
foo = (struct bar *)krealloc(foo, 1, GFP_KERNEL)
Maybe this one is better...
---
scripts/checkpatch.pl | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 91308be..43914c3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4275,9 +4275,20 @@ sub process {
# check for krealloc arg reuse
if ($^V && $^V ge 5.10.0 &&
- $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) {
- WARN("KREALLOC_ARG_REUSE",
- "Reusing the krealloc arg is almost always a bug\n" . $herecurr);
+ $line =~ /($Lval)\s*\=\s*($balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) {
+ my $cast = $2;
+ my $cast_count = 0;
+ my @line_lvals = $line =~ m/$Lval/g;
+ if (defined $cast) {
+ $cast_count++ while ($cast =~ /$Lval/g);
+ }
+ for my $index (1 + $cast_count .. $#line_lvals - 1) {
+ if ($line_lvals[$index] eq "krealloc" &&
+ $line_lvals[$index - 1 - $cast_count] eq $line_lvals[$index + 1]) {
+ WARN("KREALLOC_ARG_REUSE",
+ "Reusing the krealloc arg is almost always a bug\n" . $herecurr);
+ }
+ }
}
# check for alloc argument mismatch
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists