sval: make some more fixes to sval_binop_overflows()
commitd1685cb79a0ab467b4009efe15ecc9d1b558bd5c
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 23 May 2013 14:34:24 +0000 (23 17:34 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Thu, 23 May 2013 14:34:24 +0000 (23 17:34 +0300)
treeacee27bfa4893409c5253fbcc9b192e09eed0be2
parent7296c6e565e196da19fda31a08d5018338149f67
sval: make some more fixes to sval_binop_overflows()

So this is partly Monte Carlo coding where I just keep changing things
until they work.  I don't understand overflows very well...  :/

The code looks like this:

x = a - b;

Obviously if "a" and "b" are unsigned and "b" is larger then that doesn't
work as intended.  So I complain about that.

Otherwise I change the equation into "x = a + (-b)" because I know how to
handle addition overflows.  But sometimes change "b" to negative can
overflow so I check for that.

And finally it turns out that my check for addition overflows was utter
rubbish.  I have looked up how other people test for this on the internet
and tried to copy the normal algorithm.

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