[PATCH 12/22] commands: ubsan: hide zero division in test
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Mar 13 00:34:35 PDT 2025
clang-analyzer pierces the volatile veil and complains that
test_ubsan_divrem_overflow() does a division by zero.
The division is intentional to exercise UBSAN runtime detection of the
condition, so let's hide the fact that val2 is zero using
OPTIMIZER_HIDE_VAR.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
commands/ubsan.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/commands/ubsan.c b/commands/ubsan.c
index 4a9716139c4b..634ab2bc60b2 100644
--- a/commands/ubsan.c
+++ b/commands/ubsan.c
@@ -43,6 +43,8 @@ static void test_ubsan_divrem_overflow(void)
volatile int val = 16;
volatile int val2 = 0;
+ OPTIMIZER_HIDE_VAR(&val2);
+
val /= val2;
}
--
2.39.5
More information about the barebox
mailing list