From: "Dan Carpenter" <error27@gmail.com>
To: Matt <matt@use.net>
Cc: linux-sparse@vger.kernel.org
Subject: Re: inline declaration and assignment
Date: Sat, 15 Nov 2008 15:20:27 +0300 [thread overview]
Message-ID: <a63d67fe0811150420w55ff1c7arabe5e1a1083ea089@mail.gmail.com> (raw)
In-Reply-To: <Pine.NEB.4.64.0811102205210.20411@cesium.clock.org>
The thing is that smatch is pretty much abandon-ware until Christmas
because I'm cycling through Africa and don't have a computer to work
with... :/
On Tue, Nov 11, 2008 at 9:24 AM, Matt <matt@use.net> wrote:
> Hi,
>
> I'm playing with smatch and noticed that an inline assignment doesn't seem
> to get parsed as such. There's a couple of examples, but this one in
> sparse's own parse.c (line 1480) is probably the best:
> struct ident *ident = NULL;
>
>
> sparse doesn't seem to identify this as an assignment, only a declaration.
> as a result, smatch gives this false positive:
> parse.c +1487 undefined param add_expression 1
>
I really wanted to polish smatch up and make it presentable before I left
but I ran out of time.
The message isn't an error message. It's means that "ident" could either
be null or non-null depending on the if statement.
If add_expression() dereferenced the parameter without checking then
a message gets printed out there too.
There was supposed to be a script that made a list of all the functions
that were called with undefined parameters and a list of all the functions
that don't check. If a parameter shows up on both lists then it's
possibly a bug.
cat out.txt | grep "undefined param" | cut -d ' ' -f 5- | sort -u > undefined
cat out.txt | grep unchecked | cut -d ' ' -f 5- | sort -u > unchecked
cat undefined unchecked | sort | uniq -c
As far as declarations go, in sparse the declaration expressions have an
initializer member if the expression is initialized.
The other thing is that you can use:
make C=y CHECK="smatch --debug" foo/bar.o
That will show you the states as they flow.
I guess the last thing is that the test assumes it is probably a bug
if you have:
if (foo) { ... } foo->bar;
But really there are too many macros and asserts that check this.
There are a lot of false positives from this script...
Maybe if we added two states arg_null and arg_non_null and
then changed these lines:
orig:
if (!tmp || tmp == &undefined || tmp == &isnull || tmp == &argument)
set_true_false_states(name, my_id, sym, true_state, false_state);
new:
if (tmp == &undefined || tmp == &isnull)
set_true_false_states(name, my_id, sym, true_state, false_state);
if (tmp == &argument)
set_true_false_states(name, my_id, sym, arg_true, arg_false);
Then in merge_states():
if (s1 == &arg_false && s2 == &arg_true)
return &argument;
There are some other places in the script that are affected...
Or you could just add some other allocator functions to the
return_null array.
Anyway. Sorry again for the poor documentation and the rubbish
check script. I'm probably not going to have email again for 2
weeks but if I can help let me know.
regards,
dan carpenter
bikesafari.net
prev parent reply other threads:[~2008-11-15 12:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-11 6:24 inline declaration and assignment Matt
2008-11-15 12:20 ` Dan Carpenter [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=a63d67fe0811150420w55ff1c7arabe5e1a1083ea089@mail.gmail.com \
--to=error27@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=matt@use.net \
/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).