From aaedaf5a0c5dff945217f666a90eb27c8595fc5c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 9 Jan 2024 13:30:14 +0300 Subject: [PATCH] or_vs_and: silence some false positives 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 --- check_or_vs_and.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/check_or_vs_and.c b/check_or_vs_and.c index 95936d1eb..c06015d88 100644 --- a/check_or_vs_and.c +++ b/check_or_vs_and.c @@ -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); }