linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Hariprasad Kelam <hariprasad.kelam@gmail.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Hardik Singh Rathore <hardiksingh.k@gmail.com>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8723bs: core: rtw_recv: fix warning Comparison to NULL
Date: Thu, 16 May 2019 11:58:49 -0700	[thread overview]
Message-ID: <0145d042645da5c802e2f2bac46f847ad1e28587.camel@perches.com> (raw)
In-Reply-To: <20190516182538.GA4025@hari-Inspiron-1545>

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



      reply	other threads:[~2019-05-16 18:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15 17:45 [PATCH] staging: rtl8723bs: core: rtw_recv: fix warning Comparison to NULL Hariprasad Kelam
2019-05-16  8:00 ` Dan Carpenter
2019-05-16 18:25   ` Hariprasad Kelam
2019-05-16 18:58     ` 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=0145d042645da5c802e2f2bac46f847ad1e28587.camel@perches.com \
    --to=joe@perches.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hardiksingh.k@gmail.com \
    --cc=hariprasad.kelam@gmail.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;
as well as URLs for NNTP newsgroup(s).