capped: fix handling of assignmentsmaster
commit0c39991447cadf6e4ccae9de335e0f03840cec73
authorDan Carpenter <dan.carpenter@linaro.org>
Mon, 16 Sep 2024 14:35:19 +0000 (16 17:35 +0300)
committerDan Carpenter <dan.carpenter@linaro.org>
Mon, 16 Sep 2024 14:35:19 +0000 (16 17:35 +0300)
tree585913b6789e9edddfe1f92f2545775202c1f2a6
parent889471a3bbcc45b96e7587a3bad153758e82a97c
capped: fix handling of assignments

The problem that this change tries to address is:

if (x > foo)
return;
// x is now capped
if (x < 0)
x = 0;  // <- this assignement makes it uncapped

When we're handling this assignment the modification hook first sets it
to uncapped.  Then this assignment can set things back to capped.  The
!is_capped() condition makes no sense, because it won't be capped.

If it's a += assignment then that's uncapped.  If the right hand side is
capped then it's capped.  If we had a state and we're setting it to a
partial range then set it to capped.  (If we don't have a state then forget
about it).

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
smatch_capped.c