Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1290661
| From | "S. Gilles" <sgilles@math.umd.edu> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] checkpatch: detect leading * in NULL comparison check |
| Date | 2015-12-13 19:20 +0100 |
| Message-ID | <qFjpw-3nE-7@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
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
--
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/
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] checkpatch: detect leading * in NULL comparison check "S. Gilles" <sgilles@math.umd.edu> - 2015-12-13 19:20 +0100
Re: [PATCH] checkpatch: detect leading * in NULL comparison check Joe Perches <joe@perches.com> - 2015-12-13 21:50 +0100
Re: [PATCH] checkpatch: detect leading * in NULL comparison check "S. Gilles" <sgilles@math.umd.edu> - 2015-12-13 23:10 +0100
csiph-web