mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Andy Whitcroft <apw@canonical.com>
Cc: anirudh@xilinx.com, sgoud@xilinx.com, svemula@xilinx.com,
	Lars-Peter Clausen <lars@metafoo.de>,
	Manish Narani <manish.narani@xilinx.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] checkpatch: Fix krealloc reuse test
Date: Sun, 22 Jul 2018 10:51:16 -0700	[thread overview]
Message-ID: <e617ecb8c019a9c4c56540a1bec16c8aed43a4e4.camel@perches.com> (raw)
In-Reply-To: <1531922148-7423-1-git-send-email-manish.narani@xilinx.com>

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);
 		}

      parent reply	other threads:[~2018-07-22 17:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-18 13:55 [PATCH] checkpatch: Resolve improper warning for krealloc arg reuse Manish Narani
2018-07-18 15:50 ` Joe Perches
2018-07-18 17:46 ` Joe Perches
2018-07-22 17:51 ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e617ecb8c019a9c4c56540a1bec16c8aed43a4e4.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=anirudh@xilinx.com \
    --cc=apw@canonical.com \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manish.narani@xilinx.com \
    --cc=sgoud@xilinx.com \
    --cc=svemula@xilinx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®