All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <natechancellor@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: devel@driverdev.osuosl.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/7] staging: ks7010: Remove unnecessary limit checks
Date: Mon, 14 May 2018 07:06:22 -0700	[thread overview]
Message-ID: <20180514140622.GA13207@flashbox> (raw)
In-Reply-To: <20180514131736.ysftvs3nk552kjnx@mwanda>

On Mon, May 14, 2018 at 04:17:36PM +0300, Dan Carpenter wrote:
> On Sun, May 06, 2018 at 03:03:00PM -0700, Nathan Chancellor wrote:
> > uwrq is an unsigned 32-bit integer, it cannot be less than zero.
> > 
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> >  drivers/staging/ks7010/ks_wlan_net.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
> > index e96477937f65..0c83d6fe270f 100644
> > --- a/drivers/staging/ks7010/ks_wlan_net.c
> > +++ b/drivers/staging/ks7010/ks_wlan_net.c
> > @@ -1928,7 +1928,7 @@ static int ks_wlan_set_beacon_lost(struct net_device *dev,
> >  	if (priv->sleep_mode == SLP_SLEEP)
> >  		return -EPERM;
> >  	/* for SLEEP MODE */
> > -	if (*uwrq < BEACON_LOST_COUNT_MIN || *uwrq > BEACON_LOST_COUNT_MAX)
> > +	if (*uwrq > BEACON_LOST_COUNT_MAX)
> 
> I believe Smatch is supposed to ignore this sort of code because
> comparing "if (foo < 0 || foo > max) " is pretty readable and idiomatic.
> 
> Presumably this was so we could redefine BEACON_LOST_COUNT_MIN, but it's
> fine to unused code.  The define isn't needed at all, so you can
> delete that as well.
> 
> regards,
> dan carpenter
> 

Hi Dan,

Thanks for the suggestion, I just sent a patch.

This warning came from GCC as a -Wtype-limit warning. I should have put
that in the commit message to be more clear. I will keep this in mind
for the future if I come across any more checks like this with defines.

Thanks!
Nathan Chancellor
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  reply	other threads:[~2018-05-14 14:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-06 22:02 [PATCH 1/7] staging: ks7010: Replace license boilerplate with SPDX identifiers Nathan Chancellor
2018-05-06 22:02 ` [PATCH 2/7] staging: ks7010: Remove unused variables Nathan Chancellor
2018-05-07 17:59   ` Nathan Chancellor
2018-05-06 22:03 ` [PATCH 3/7] staging: ks7010: Remove unnecessary limit checks Nathan Chancellor
2018-05-14 13:17   ` Dan Carpenter
2018-05-14 14:06     ` Nathan Chancellor [this message]
2018-05-14 14:15       ` Dan Carpenter
2018-05-06 22:03 ` [PATCH 4/7] staging: ks7010: Adjust spacing around functions and declarations Nathan Chancellor
2018-05-08 11:45   ` Greg Kroah-Hartman
2018-05-06 22:03 ` [PATCH 5/7] staging: ks7010: Remove unnecessary parentheses Nathan Chancellor
2018-05-08 11:44   ` Greg Kroah-Hartman
2018-05-06 22:03 ` [PATCH 6/7] staging: ks7010: Adjust alignment to open parenthesis Nathan Chancellor
2018-05-08 11:45   ` Greg Kroah-Hartman
2018-05-06 22:03 ` [PATCH 7/7] staging: ks7010: Move from bool to int in structs Nathan Chancellor
2018-05-08 11:34   ` Greg Kroah-Hartman
2018-05-08 11:42     ` Nathan Chancellor
2018-05-08 11:43 ` [PATCH 1/7] staging: ks7010: Replace license boilerplate with SPDX identifiers Greg Kroah-Hartman
2018-05-08 11:49   ` Nathan Chancellor

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=20180514140622.GA13207@flashbox \
    --to=natechancellor@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.