diff --git a/components/esp_eth/src/esp_eth_mac_esp.c b/components/esp_eth/src/esp_eth_mac_esp.c index a7c3b7e543..02df23aed4 100644 --- a/components/esp_eth/src/esp_eth_mac_esp.c +++ b/components/esp_eth/src/esp_eth_mac_esp.c @@ -311,7 +311,7 @@ static esp_err_t emac_config_apll_clock(void) ESP_LOGW(TAG, "APLL is occupied already, it is working at %d Hz", real_freq); } // If the difference of real APLL frequency is not within 50 ppm, i.e. 2500 Hz, the APLL is unavailable - ESP_RETURN_ON_FALSE(abs(real_freq - expt_freq) <= 2500, + ESP_RETURN_ON_FALSE(abs((int)real_freq - (int)expt_freq) <= 2500, ESP_ERR_INVALID_STATE, TAG, "The APLL is working at an unusable frequency"); return ESP_OK; diff --git a/components/esp_timer/src/esp_timer_impl_frc_legacy.c b/components/esp_timer/src/esp_timer_impl_frc_legacy.c index 249ca0c45e..1c8db195c1 100644 --- a/components/esp_timer/src/esp_timer_impl_frc_legacy.c +++ b/components/esp_timer/src/esp_timer_impl_frc_legacy.c @@ -249,7 +249,7 @@ void IRAM_ATTR esp_timer_impl_set_alarm_id(uint64_t timestamp, unsigned alarm_id (the alarm will be less than the counter) and it leads to the infinity loop. To exclude this behavior to the offset was added the delta to have the opportunity to go through it. */ - offset += abs((int)delta) + s_timer_ticks_per_us * 2; + offset += llabs(delta) + s_timer_ticks_per_us * 2; } else { break; } diff --git a/components/esp_timer/src/esp_timer_impl_lac.c b/components/esp_timer/src/esp_timer_impl_lac.c index 3994275593..47f4b89501 100644 --- a/components/esp_timer/src/esp_timer_impl_lac.c +++ b/components/esp_timer/src/esp_timer_impl_lac.c @@ -162,7 +162,7 @@ void IRAM_ATTR esp_timer_impl_set_alarm_id(uint64_t timestamp, unsigned alarm_id int64_t delta = (int64_t)alarm.val - (int64_t)now_time; if (delta <= 0 && REG_GET_FIELD(INT_ST_REG, TIMG_LACT_INT_ST) == 0) { // new alarm is less than the counter and the interrupt flag is not set - offset += abs((int)delta) + TICKS_PER_US * 2; + offset += llabs(delta) + TICKS_PER_US * 2; alarm.val = now_time + offset; } else { // finish if either (alarm > counter) or the interrupt flag is already set. diff --git a/components/hal/i2s_hal.c b/components/hal/i2s_hal.c index 11290226a7..7d396d65c8 100644 --- a/components/hal/i2s_hal.c +++ b/components/hal/i2s_hal.c @@ -27,7 +27,7 @@ static void i2s_hal_mclk_div_decimal_cal(i2s_hal_clock_cfg_t *clk_cfg, i2s_ll_mc cal->a = 1; cal->b = 0; - uint32_t freq_diff = abs(clk_cfg->sclk - clk_cfg->mclk * cal->mclk_div); + uint32_t freq_diff = abs((int)clk_cfg->sclk - (int)(clk_cfg->mclk * cal->mclk_div)); if (!freq_diff) { return; } diff --git a/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_api.c b/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_api.c index 75b24d2588..0cac95583a 100644 --- a/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_api.c +++ b/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_api.c @@ -123,7 +123,7 @@ TEST_CASE("getting the time works", "[test_utils][ccomp_timer]") int64_t t_2 = esp_timer_get_time() - start; // The times should at least be in the same ballpark (at least within 10%) - float diff = (abs(t_1 - t_2)) / ((float)t_2); + float diff = (llabs(t_1 - t_2)) / ((float)t_2); TEST_ASSERT(diff <= 10.0f); // Since the timer was already stopped, test that ccomp_timer_get_time diff --git a/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_data.c b/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_data.c index 07d7da85dc..7c1ddeeca2 100644 --- a/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_data.c +++ b/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_data.c @@ -162,7 +162,7 @@ TEST_CASE("data cache hit rate sweep", "[test_utils][ccomp_timer]") for (int i = 0; i <= 100; i += 5) { t_hr = perform_test_at_hit_rate(i, flash_mem); - float error = (abs(t_ref.ccomp - t_hr.ccomp) / (float)t_ref.ccomp) * 100.0f; + float error = (llabs(t_ref.ccomp - t_hr.ccomp) / (float)t_ref.ccomp) * 100.0f; ESP_LOGI(TAG, "Hit Rate(%%): %d Wall Time(us): %lld Compensated Time(us): %lld Error(%%): %f", i, (long long)t_hr.wall, (long long)t_hr.ccomp, error); diff --git a/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_inst.c b/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_inst.c index f7ce9aeba9..6bc2cc9e0b 100644 --- a/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_inst.c +++ b/tools/unit-test-app/components/test_utils/test/ccomp_timer_test_inst.c @@ -221,7 +221,7 @@ TEST_CASE("instruction cache hit rate sweep test", "[test_utils][ccomp_timer]") for (int i = 0; i <= 100; i += 5) { t_hr = perform_test_at_hit_rate(i); - float error = (abs(t_ref.ccomp - t_hr.ccomp) / (float)t_ref.wall) * 100.0f; + float error = (llabs(t_ref.ccomp - t_hr.ccomp) / (float)t_ref.wall) * 100.0f; ESP_LOGI(TAG, "Hit Rate(%%): %d Wall Time(us): %lld Compensated Time(us): %lld Error(%%): %f", i, (long long)t_hr.wall, (long long)t_hr.ccomp, error);