extra: re-write get_long_name_sym()
commit54f00fb24794d3251875bc5e1c0ca4013a27e20b
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 30 Jun 2021 14:41:10 +0000 (30 17:41 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Wed, 30 Jun 2021 14:41:10 +0000 (30 17:41 +0300)
tree720dac5da5db41f997f456680b987aceabd9521e
parent300acd02cf35602f605feff829f464ce030a1684
extra: re-write get_long_name_sym()

The old code was pretty complicated and slightly buggy.  The bug is that
it broke out of the loop the first time it found a matching symbol.
Another bug is that it doesn't swap the name properly when converting from
p = &whatever to p->foo means whatever.foo.

When I was thinking about it, what I realized is that probably the most
like like thing is that we have:

struct whatever *p = some->really->long->thing;

So something is assigned to "p" which is also the symbol.  So we can
look up the symbol and get the long name from that.  If p->foo is set to
3 that means some->really->long->thing->foo is set to 3.

We can use swap_name() from smatch_param_key.c to simplify the code and
because it understands addresses etc.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch.h
smatch_extra.c
smatch_param_key.c