All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: John Levon <levon@movementarian.org>
Cc: smatch@vger.kernel.org
Subject: Re: check_signed.c false negative
Date: Wed, 13 Nov 2019 20:39:13 +0300	[thread overview]
Message-ID: <20191112055759.GA1959@kadam.lan> (raw)
In-Reply-To: <20191111232115.GA19963@movementarian.org>

On Mon, Nov 11, 2019 at 11:21:15PM +0000, John Levon wrote:
> 
> Given:
> 
> enum ib_qp_state {
>         IB_QPS_RESET,
>         IB_QPS_INIT,
>         IB_QPS_RTR,
>         IB_QPS_RTS,
>         IB_QPS_SQD,
>         IB_QPS_SQE,
>         IB_QPS_ERR
> };
> 
> int p(enum ib_qp_state cur_state, enum ib_qp_state next_state)
> {
> #if 0
>        if (cur_state  < 0 || cur_state > IB_QPS_ERR ||
>          next_state < 0 || next_state > IB_QPS_ERR) {
>                 return (5);
>         }
> #else
>        if (next_state < 0 || next_state > IB_QPS_ERR) {
>                 return (5);
>         }
> #endif
> 
>         return (0);
> }
> 
> current smatch is happy. But "#if 1" above instead, and:
> 
> jlevon@sent:~/src/smatch$ ./smatch a.c
> ./smatch: a.c:15 p() warn: unsigned 'cur_state' is never less than zero.
> 
> Why is "next_state" not reported equally?

My plan was that neither one would print a warning.  When people do

	if (foo < 0 || foo > max)

then normally it's not a real life bug...  Linus said at kernel summit
that he doesn't like when people send patches for those.

The problem is that when I wrote the code to silence the warning then I
hadn't created all the expr_get_parent_expr() function so I couldn't
silence it properly.

regards,
dan carpenter

  reply	other threads:[~2019-11-13 17:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-11 23:21 check_signed.c false negative John Levon
2019-11-13 17:39 ` Dan Carpenter [this message]
2019-11-13 17:52   ` John Levon

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=20191112055759.GA1959@kadam.lan \
    --to=dan.carpenter@oracle.com \
    --cc=levon@movementarian.org \
    --cc=smatch@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.