public inbox for smatch@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Harshvardhan Jha <harshvardhan.jha@oracle.com>
Cc: smatch@vger.kernel.org
Subject: Re: [PATCH 2/2] extra: Fix handle_bit_test so that null set condition is taken care of
Date: Tue, 13 Jul 2021 18:35:28 +0300	[thread overview]
Message-ID: <20210713153527.GS1954@kadam> (raw)
In-Reply-To: <20210713125006.12329-2-harshvardhan.jha@oracle.com>

I have applied the first commit but this one still needs work.  Consider
this test case:

#include "check_debug.h"

unsigned int frob();

void test(void)
{
	unsigned int mask = 0xff0;
        unsigned int x = frob();

	if (frob())
		mask |= 0x2;

	if (x < 0 || x > 11)
		return;

        if ((1 << x) & mask) {
		__smatch_implied(x);
                return;
	}
        __smatch_implied(x);
}

The output is:

test.c:17 test() implied: x = '1-11'
test.c:20 test() implied: x = '0'

The first implied is correct but the second is wrong.  BIT(1) or 0x2 is
*possibly* set or *possibly not* set.  So on the false path the range
list should be 0-1.

regards,
dan carpenter

  reply	other threads:[~2021-07-13 15:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13 12:50 [PATCH 1/2] extra: Fix false output of handle_AND_op and handle_AND_condition Harshvardhan Jha
2021-07-13 12:50 ` [PATCH 2/2] extra: Fix handle_bit_test so that null set condition is taken care of Harshvardhan Jha
2021-07-13 15:35   ` Dan Carpenter [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-07-13 18:05 Harshvardhan Jha

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=20210713153527.GS1954@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=harshvardhan.jha@oracle.com \
    --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