Skip to content

Commit 85ce429

Browse files
committed
tests: boards: intel_adsp/smoke: fix abs() on unsigned value
Fix complier warning about using abs() with unsigned value. Since it is being used to calculate differences in clock values, they needs to be casted into signed 64-bit first to avoid capping at 32-bit. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
1 parent ae73277 commit 85ce429

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

tests/boards/intel_adsp/smoke/src/cpus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static void core_smoke(void *arg)
120120
clk_ratios[cpu] / 1000, clk_ratios[cpu] % 1000);
121121

122122
for (int i = 0; i < cpu; i++) {
123-
int32_t diff = MAX(1, abs(clk_ratios[i] - clk_ratios[cpu]));
123+
int32_t diff = MAX(1, (uint32_t)llabs((int64_t)clk_ratios[i] - clk_ratios[cpu]));
124124

125125
zassert_true((clk_ratios[cpu] / diff) > 100,
126126
"clocks off by more than 1%%");

tests/boards/intel_adsp/smoke/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ZTEST(intel_adsp, test_clock_calibrate)
3636
printk("CLOCK: %lld Hz\n", (1000000ULL * (cyc1 - cyc0)) / host_dt);
3737

3838
/* Make sure we're within 1% of spec */
39-
diff = abs(hz - CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC);
39+
diff = (uint32_t)llabs((int64_t)hz - CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC);
4040
zassert_true((hz / MIN(1, diff)) > 100, "clock rate wrong");
4141
}
4242

0 commit comments

Comments
 (0)