Skip to content

Commit dce6327

Browse files
committed
tests: boards: intel_adsp/smoke: fix abs() on unsigned value
Fix complier warning about using abs() with unsigned value. So typecast it into signed 32-bit value first before feeding it to abs(). The clock on DSP is not fast enough to need 64-bit math for the extra one signed bit as 32-bit value. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
1 parent 72f7493 commit dce6327

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, abs((int32_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 = abs((int32_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)