mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 03:34:32 +02:00
Merge branch 'bugfix/usleep_overflow_v5.2' into 'release/v5.2'
fix(newlib): fixed potential overflow in usleep (v5.2) See merge request espressif/esp-idf!33002
This commit is contained in:
@@ -194,7 +194,10 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
||||
|
||||
int usleep(useconds_t us)
|
||||
{
|
||||
const int us_per_tick = portTICK_PERIOD_MS * 1000;
|
||||
/* Even at max tick rate, vTaskDelay can still delay for the max of the us argument,
|
||||
we just need to make sure the tick calculation does not overflow
|
||||
*/
|
||||
const int64_t us_per_tick = portTICK_PERIOD_MS * 1000;
|
||||
if (us < us_per_tick) {
|
||||
esp_rom_delay_us((uint32_t) us);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user