Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752196AbbLMSMj (ORCPT ); Sun, 13 Dec 2015 13:12:39 -0500 Received: from ecemailfilter.ece.umd.edu ([129.2.90.4]:36332 "EHLO mailfilter.ece.umd.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751645AbbLMSMi (ORCPT ); Sun, 13 Dec 2015 13:12:38 -0500 X-Greylist: delayed 703 seconds by postgrey-1.27 at vger.kernel.org; Sun, 13 Dec 2015 13:12:37 EST X-ASG-Debug-ID: 1450029651-04739d1535398560001-xx1T2L X-Barracuda-Envelope-From: sgilles@math.umd.edu X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.54 From: "S. Gilles" X-Barracuda-Effective-Source-IP: c-69-143-246-227.hsd1.md.comcast.net[69.143.246.227] X-Barracuda-Apparent-Source-IP: 69.143.246.227 To: Andy Whitcroft , Joe Perches , linux-kernel@vger.kernel.org Cc: "S. Gilles" Subject: [PATCH] checkpatch: detect leading * in NULL comparison check Date: Sun, 13 Dec 2015 12:59:52 -0500 X-ASG-Orig-Subj: [PATCH] checkpatch: detect leading * in NULL comparison check Message-Id: <1450029592-476-1-git-send-email-sgilles@math.umd.edu> X-Mailer: git-send-email 2.6.3 X-Barracuda-Connect: mail-pa0-f54.google.com[209.85.220.54] X-Barracuda-Start-Time: 1450029651 X-Barracuda-URL: https://mailfilter.ece.umd.edu:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 1174 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=7.0 KILL_LEVEL=1000.0 tests=BSF_SC0_MISMATCH_TO X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.25223 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BSF_SC0_MISMATCH_TO Envelope rcpt doesn't match header Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1381 Lines: 43 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/