Skip to content

Commit

Permalink
or_vs_and: silence some false positives
Browse files Browse the repository at this point in the history
Sizeof(something) ends up being a literal.  So you'd think it would
"sizeof(foo)" it is "4" or whatever.  And then two literals happen to
be the same value and you end up with false positives.

Signed-off-by: Dan Carpenter <[email protected]>
  • Loading branch information
Dan Carpenter committed Jan 9, 2024
1 parent 86bb869 commit aaedaf5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions check_or_vs_and.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ static int does_inc_dec(struct expression *expr)

static int expr_equiv_no_inc_dec(struct expression *one, struct expression *two)
{
sval_t dummy;

if (does_inc_dec(one) || does_inc_dec(two))
return 0;
if (get_value(one, &dummy) &&
get_value(two, &dummy))
return 0;

return expr_equiv(one, two);
}

Expand Down

0 comments on commit aaedaf5

Please sign in to comment.