From: "S. Gilles" <sgilles@math.umd.edu>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
linux-kernel@vger.kernel.org
Cc: "S. Gilles" <sgilles@math.umd.edu>
Subject: [PATCH] checkpatch: detect leading * in NULL comparison check
Date: Sun, 13 Dec 2015 12:59:52 -0500 [thread overview]
Message-ID: <1450029592-476-1-git-send-email-sgilles@math.umd.edu> (raw)
Prevent checkpatch.pl from emitting messages like
CHECK: Comparison to NULL could be written "!rx_p"
#51: FILE: drivers/staging/iio/accel/sca3000_ring.c:51:
+ if (*rx_p == NULL) {
by checking for leading * characters in the comparison value.
Signed-off-by: S. Gilles <sgilles@math.umd.edu>
---
I've run this through everything in staging/ as a test, it seems to
work okay.
scripts/checkpatch.pl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d4960f7..e549d59 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4995,10 +4995,10 @@ sub process {
# check for pointer comparisons to NULL
if ($^V && $^V ge 5.10.0) {
- while ($line =~ /\b$LvalOrFunc\s*(==|\!=)\s*NULL\b/g) {
- my $val = $1;
+ while ($line =~ /([\*]*)\b$LvalOrFunc\s*(==|\!=)\s*NULL\b/g) {
+ my $val = $1 . $2;
my $equal = "!";
- $equal = "" if ($4 eq "!=");
+ $equal = "" if ($5 eq "!=");
if (CHK("COMPARISON_TO_NULL",
"Comparison to NULL could be written \"${equal}${val}\"\n" . $herecurr) &&
$fix) {
--
2.6.3
next reply other threads:[~2015-12-13 18:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-13 17:59 S. Gilles [this message]
2015-12-13 20:49 ` Joe Perches
2015-12-13 22:02 ` S. Gilles
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=1450029592-476-1-git-send-email-sgilles@math.umd.edu \
--to=sgilles@math.umd.edu \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
/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®