[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0145d042645da5c802e2f2bac46f847ad1e28587.camel@perches.com>
Date: Thu, 16 May 2019 11:58:49 -0700
From: Joe Perches <joe@...ches.com>
To: Hariprasad Kelam <hariprasad.kelam@...il.com>,
Dan Carpenter <dan.carpenter@...cle.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Hardik Singh Rathore <hardiksingh.k@...il.com>,
devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: rtl8723bs: core: rtw_recv: fix warning
Comparison to NULL
On Thu, 2019-05-16 at 23:55 +0530, Hariprasad Kelam wrote:
> On Thu, May 16, 2019 at 11:00:56AM +0300, Dan Carpenter wrote:
> > On Wed, May 15, 2019 at 11:15:36PM +0530, Hariprasad Kelam wrote:
> > > @@ -1042,7 +1042,7 @@ sint sta2ap_data_frame(
> > > }
> > >
> > > *psta = rtw_get_stainfo(pstapriv, pattrib->src);
> > > - if (*psta == NULL) {
> > > + if (!*psta == NULL) {
> > ^^^^^^^^^^^^^^
> > It's surprising that this didn't cause some kind of warning somewhere...
>
> Thanks for pointing out this error. Here my intention is to write
> if(!*psta)
> but somehow i missed it .
>
> Will resend this patch after correcting the same.Like below
>
> > - if (*psta == NULL) {
> > > + if (!*psta) {
You could run the coccinelle spatch file for bool
comparisons on the files instead. It's much less
error prone.
$ spatch --sp-file scripts/coccinelle/misc/boolconv.cocci --in-place drivers/staging/rtl8723bs/
Or you could use a patch to checkpatch like below and then use
$ git ls-files drivers/staging/rtl8723bs | \
xargs ./scripts/checkpatch.pl -f --fix-inplace --types=bool_comparison
but that definitely would not be as good as the coccinelle
tool use as coccinelle is much better at parsing expressions.
---
scripts/checkpatch.pl | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 1c421ac42b07..fe83aa0b1f97 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6407,11 +6407,13 @@ sub process {
$op = "";
}
- CHK("BOOL_COMPARISON",
- "Using comparison to $otype is error prone\n" . $herecurr);
-
+ if (CHK("BOOL_COMPARISON",
+ "Using comparison to $otype is error prone\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s/\b(?:true|false|$Lval)\s*(?:==|\!=)\s*(?:true|false|$Lval)\b/${op}${arg}/;
+ }
## maybe suggesting a correct construct would better
-## "Using comparison to $otype is error prone. Perhaps use '${lead}${op}${arg}${trail}'\n" . $herecurr);
+## "Using comparison to $otype is error prone. Perhaps use '${lead}${op}${arg}${trail}'\n" . $herecurr);
}
}
Powered by blists - more mailing lists