slist: don't allocate so many duplicate ->possible states
commitf4302359baf81d277e1e59ebc8fa38da8c3728f7
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 6 Mar 2019 13:06:43 +0000 (6 16:06 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Wed, 6 Mar 2019 13:06:43 +0000 (6 16:06 +0300)
treefbb1735586447bdc6c6f34e0cd59b90090c44737
parent1846b32372a76182d2ea79ee031d2287db311015
slist: don't allocate so many duplicate ->possible states

Originally state were simple and declared like this:

STATE(null);

In the cmp_possible_sm() we could just compare the pointers to see if we
already had that one in the ->possible list.  But then the started being
allocated dynamically and it became more complicated.  I believe that
actually it looks very complicated with some smatch_extra tests and the
"preserve" flag but really it's just doing the pointer tests still.  In
other words it's totally buggy.

Anyway, it needs to needs to be a little complicated to work correctly and
that's because we use the ->possible list for smatch_extra to split the
return states.  So we want to preserve leaf sm states (ie states that are
not merged).

Then for the rest, if it's a simple state we can just do the pointer
compares and that's very easy.  Otherwise we can just do a strcmp() on
the state->names.

One problem I found is that some states had no name.  That's not useful, so
I have fixed some of those.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
36 files changed:
check_macro_side_effects.c
check_missing_break.c
check_rosenberg.c
check_snprintf.c
check_spectre_second_half.c
check_syscall_arg_type.c
check_testing_index_after_use.c
smatch.c
smatch.h
smatch_assigned_expr.c
smatch_buf_comparison.c
smatch_buf_size.c
smatch_comparison.c
smatch_constraints.c
smatch_constraints_required.c
smatch_container_of.c
smatch_extra.c
smatch_imaginary_absolute.c
smatch_kernel_user_data.c
smatch_links.c
smatch_local_values.c
smatch_modification_hooks.c
smatch_param_compare_limit.c
smatch_param_filter.c
smatch_param_limit.c
smatch_param_set.c
smatch_param_to_mtag_data.c
smatch_parse_call_math.c
smatch_real_absolute.c
smatch_return_to_param.c
smatch_returns.c
smatch_slist.c
smatch_slist.h
smatch_statement_count.c
smatch_stored_conditions.c
smatch_strlen.c