diff --git a/components/driver/test/test_ledc.c b/components/driver/test/test_ledc.c index 580b2f65bb..d85cdbc9a9 100644 --- a/components/driver/test/test_ledc.c +++ b/components/driver/test/test_ledc.c @@ -315,8 +315,8 @@ TEST_CASE("LEDC fast switching duty with fade_wait_done", "[ledc]") TEST_ESP_OK(ledc_fade_start(test_speed_mode, LEDC_CHANNEL_0, LEDC_FADE_WAIT_DONE)); TEST_ASSERT_EQUAL_INT32(1000, ledc_get_duty(test_speed_mode, LEDC_CHANNEL_0)); fade_stop = esp_timer_get_time(); - int time_ms = (fade_stop - fade_start) / 1000; - TEST_ASSERT_TRUE(fabs(time_ms - 350) < 20); + int64_t time_ms = (fade_stop - fade_start) / 1000; + TEST_ASSERT_TRUE(llabs(time_ms - 350) < 20); // next duty update will not take place until last fade reaches its target duty TEST_ESP_OK(ledc_set_fade_with_time(test_speed_mode, LEDC_CHANNEL_0, 4000, 200)); @@ -347,8 +347,8 @@ TEST_CASE("LEDC fast switching duty with fade_no_wait", "[ledc]") first_fade_complete = esp_timer_get_time(); // duty should not be too far from first fade target duty TEST_ASSERT_INT32_WITHIN(20, 4000, ledc_get_duty(test_speed_mode, LEDC_CHANNEL_0)); - int time_ms = (first_fade_complete - fade_start) / 1000; - TEST_ASSERT_TRUE(fabs(time_ms - 200) < 20); + int64_t time_ms = (first_fade_complete - fade_start) / 1000; + TEST_ASSERT_TRUE(llabs(time_ms - 200) < 20); vTaskDelay(158 / portTICK_PERIOD_MS); TEST_ASSERT_EQUAL_INT32(1000, ledc_get_duty(test_speed_mode, LEDC_CHANNEL_0)); @@ -372,7 +372,7 @@ TEST_CASE("LEDC fade stop test", "[ledc]") fade_setup(); int64_t fade_start, fade_stop; - int time_ms = 0; + int64_t time_ms = 0; fade_start = esp_timer_get_time(); TEST_ESP_OK(ledc_set_fade_with_time(test_speed_mode, LEDC_CHANNEL_0, 4000, 500)); TEST_ESP_OK(ledc_fade_start(test_speed_mode, LEDC_CHANNEL_0, LEDC_FADE_NO_WAIT)); @@ -383,7 +383,7 @@ TEST_CASE("LEDC fade stop test", "[ledc]") TEST_ESP_OK(ledc_fade_stop(test_speed_mode, LEDC_CHANNEL_0)); fade_stop = esp_timer_get_time(); time_ms = (fade_stop - fade_start) / 1000; - TEST_ASSERT_TRUE(fabs(time_ms - 127) < 20); + TEST_ASSERT_TRUE(llabs(time_ms - 127) < 20); // Get duty value after fade_stop returns (give at least one cycle for the duty set in fade_stop to take effective) uint32_t duty_after_stop = ledc_get_duty(test_speed_mode, LEDC_CHANNEL_0); TEST_ASSERT_INT32_WITHIN(4, duty_before_stop, duty_after_stop); // 4 is the scale for one step in the last fade diff --git a/components/esp_timer/test/test_esp_timer.c b/components/esp_timer/test/test_esp_timer.c index a3a4ac9865..29627e6fed 100644 --- a/components/esp_timer/test/test_esp_timer.c +++ b/components/esp_timer/test/test_esp_timer.c @@ -433,7 +433,7 @@ static void timer_test_monotonic_values_task(void* arg) { /* Allow some difference due to rtos tick interrupting task between * getting 'hs_now' and 'now'. */ - if (abs(diff) > 100) { + if (llabs(diff) > 100) { error_repeat_cnt++; state->error_cnt++; } else { @@ -444,7 +444,7 @@ static void timer_test_monotonic_values_task(void* arg) { state->pass = false; } state->avg_diff += diff; - state->max_error = MAX(state->max_error, abs(diff)); + state->max_error = MAX(state->max_error, llabs(diff)); state->test_cnt++; } state->avg_diff /= state->test_cnt; diff --git a/components/fatfs/test/test_fatfs_common.c b/components/fatfs/test/test_fatfs_common.c index 6b44bf03ce..387985c671 100644 --- a/components/fatfs/test/test_fatfs_common.c +++ b/components/fatfs/test/test_fatfs_common.c @@ -402,7 +402,7 @@ void test_fatfs_stat(const char* filename, const char* root_dir) struct tm mtm; localtime_r(&mtime, &mtm); printf("File time: %s", asctime(&mtm)); - TEST_ASSERT(abs(mtime - t) < 2); // fatfs library stores time with 2 second precision + TEST_ASSERT(llabs(mtime - t) < 2); // fatfs library stores time with 2 second precision TEST_ASSERT(st.st_mode & S_IFREG); TEST_ASSERT_FALSE(st.st_mode & S_IFDIR); diff --git a/components/hal/esp32/include/hal/i2s_ll.h b/components/hal/esp32/include/hal/i2s_ll.h index 0cca009f16..3e791d3e8c 100644 --- a/components/hal/esp32/include/hal/i2s_ll.h +++ b/components/hal/esp32/include/hal/i2s_ll.h @@ -292,7 +292,7 @@ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, uint32_t sclk, uint32_t mcl int denominator = 1; int numerator = 0; - uint32_t freq_diff = abs(sclk - mclk * mclk_div); + uint32_t freq_diff = abs((int)sclk - (int)(mclk * mclk_div)); if (!freq_diff) { goto finish; } diff --git a/components/hal/esp32c3/include/hal/i2s_ll.h b/components/hal/esp32c3/include/hal/i2s_ll.h index 9eb3439813..e97697de9e 100644 --- a/components/hal/esp32c3/include/hal/i2s_ll.h +++ b/components/hal/esp32c3/include/hal/i2s_ll.h @@ -232,7 +232,7 @@ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, uint32_t sclk, uint32_t mcl int denominator = 1; int numerator = 0; - uint32_t freq_diff = abs(sclk - mclk * mclk_div); + uint32_t freq_diff = abs((int)sclk - (int)(mclk * mclk_div)); if (!freq_diff) { goto finish; } @@ -306,7 +306,7 @@ static inline void i2s_ll_rx_set_mclk(i2s_dev_t *hw, uint32_t sclk, uint32_t mcl int denominator = 1; int numerator = 0; - uint32_t freq_diff = abs(sclk - mclk * mclk_div); + uint32_t freq_diff = abs((int)sclk - (int)(mclk * mclk_div)); if (!freq_diff) { goto finish; } diff --git a/components/hal/esp32h2/include/hal/i2s_ll.h b/components/hal/esp32h2/include/hal/i2s_ll.h index fb531cbb24..11a4e93feb 100644 --- a/components/hal/esp32h2/include/hal/i2s_ll.h +++ b/components/hal/esp32h2/include/hal/i2s_ll.h @@ -233,7 +233,7 @@ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, uint32_t sclk, uint32_t mcl int denominator = 1; int numerator = 0; - uint32_t freq_diff = abs(sclk - mclk * mclk_div); + uint32_t freq_diff = abs((int)sclk - (int)(mclk * mclk_div)); if (!freq_diff) { goto finish; } @@ -307,7 +307,7 @@ static inline void i2s_ll_rx_set_mclk(i2s_dev_t *hw, uint32_t sclk, uint32_t mcl int denominator = 1; int numerator = 0; - uint32_t freq_diff = abs(sclk - mclk * mclk_div); + uint32_t freq_diff = abs((int)sclk - (int)(mclk * mclk_div)); if (!freq_diff) { goto finish; } diff --git a/components/hal/esp32s2/include/hal/i2s_ll.h b/components/hal/esp32s2/include/hal/i2s_ll.h index a9ffa641bc..e6dc1c025b 100644 --- a/components/hal/esp32s2/include/hal/i2s_ll.h +++ b/components/hal/esp32s2/include/hal/i2s_ll.h @@ -287,7 +287,7 @@ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, uint32_t sclk, uint32_t mcl int denominator = 1; int numerator = 0; - uint32_t freq_diff = abs(sclk - mclk * mclk_div); + uint32_t freq_diff = abs((int)sclk - (int)(mclk * mclk_div)); if (!freq_diff) { goto finish; } diff --git a/components/hal/esp32s3/include/hal/i2s_ll.h b/components/hal/esp32s3/include/hal/i2s_ll.h index 8d6387e24e..3f76ef07b1 100644 --- a/components/hal/esp32s3/include/hal/i2s_ll.h +++ b/components/hal/esp32s3/include/hal/i2s_ll.h @@ -235,7 +235,7 @@ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, uint32_t sclk, uint32_t mcl int denominator = 1; int numerator = 0; - uint32_t freq_diff = abs(sclk - mclk * mclk_div); + uint32_t freq_diff = abs((int)sclk - (int)(mclk * mclk_div)); if (!freq_diff) { goto finish; } @@ -309,7 +309,7 @@ static inline void i2s_ll_rx_set_mclk(i2s_dev_t *hw, uint32_t sclk, uint32_t mcl int denominator = 1; int numerator = 0; - uint32_t freq_diff = abs(sclk - mclk * mclk_div); + uint32_t freq_diff = abs((int)sclk - (int)(mclk * mclk_div)); if (!freq_diff) { goto finish; }