extra: fix function comparisons
commit94229e1f057af7069f2a8298c10cc42111b0354d
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 7 Feb 2019 13:47:25 +0000 (7 16:47 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Thu, 7 Feb 2019 13:47:25 +0000 (7 16:47 +0300)
treeffe8f084da5f9976d85ee0f80a2a433ff6cc1300
parenteb00d7452900878c82e5be64c63255b3a91635fb
extra: fix function comparisons

Say you have a comparison like:

if (xxx_variable >= function()) {

What's important is that the function is the constant in this case and the
xxx_variable is what we interested in.  The old code handled this really
badly.

In the old code, if function() returned a single known value then that
was treated like a special case and handled by the comparison code in
Smatch extra.  But if the function set parameters, then that wasn't
recorded.

It should all have been handled in smatch_function_hooks.c.  Unfortunately,
that code was broken on the false side of the comparison, because in
compare_db_return_states_callbacks() then it called set_return_state()
after it had already popped the fake cur_stree.  On the true side, it
called set_return_state() twice but that was a harmless mistake.

The other bug, was that it faked an assignment which is not what we wanted,
but probably also harmless.

Anyway, I did some clearn up to create separate set_return_assign_state()
and set_other_side_state() functions.

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