db, buf_size, parse_call_math: track the size of returned buffers
commite16063ef865513039265ea70711c0d848a43605d
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 24 Sep 2012 12:35:02 +0000 (24 15:35 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Mon, 24 Sep 2012 12:35:02 +0000 (24 15:35 +0300)
tree7dab6a71758c102646f0e6285bcf278abb2a48d1
parent0f7e541aed4fbb773d8f256596a2cbe5466fe5b7
db, buf_size, parse_call_math: track the size of returned buffers

With this change, we try to be a bit clever about how we track the size of
returned buffers.  There are lots of functions like alloc_foo() where you
pass the number of foos you want and it's allocation nr_foo * sizeof(foo)
and returns a buffer of that size.  This patch tries to calculate that.

First we record in the database when how we allocate the buffer so if we
take 24 bytes * parameter number 2 then we store that in the database.
BUF_SIZE = "24 * <2>"

Then on the second pass if we can calculate the size we use that.

I had to fix some bugs in smatch_function_hooks.c to make this work and
those fixes got merged int this patch.

Originally the return_implies hooks and the return_states hooks were mixed
together, but now I've separated them so they are called separately.

Also there was a problem because the return_states hooks and the
implied_states hooks conflict.  They both try to set SMATCH_EXTRA.  In the
original code, we avoided this by only calling the implied_states hooks
because the implied_states are more important.  In this we call them all
but if there are implied_states they over write the return_states.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Makefile
check_list.h
check_overflow.c
smatch.h
smatch_buf_size.c
smatch_function_hooks.c
smatch_parse_call_math.c [new file with mode: 0644]
smatch_scripts/db/fill_db_return_states.pl