public inbox for smatch@vger.kernel.org
 help / color / mirror / Atom feed
From: John Levon <levon@movementarian.org>
To: smatch@vger.kernel.org
Subject: check_signed.c false negative
Date: Mon, 11 Nov 2019 23:21:15 +0000	[thread overview]
Message-ID: <20191111232115.GA19963@movementarian.org> (raw)


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?

thanks
john

             reply	other threads:[~2019-11-12  0:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-11 23:21 John Levon [this message]
2019-11-13 17:39 ` check_signed.c false negative Dan Carpenter
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=20191111232115.GA19963@movementarian.org \
    --to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox