AP_Periph: use gmtime_r() instead of gmtime()

This commit is contained in:
Andrew Tridgell 2024-02-07 12:22:53 +11:00
parent 3d4dbd0aed
commit 20cb709ca2
1 changed files with 2 additions and 1 deletions

View File

@ -110,7 +110,8 @@ void AP_Periph_FW::send_msp_GPS(void)
} }
uint64_t tepoch_us = gps.time_epoch_usec(0); uint64_t tepoch_us = gps.time_epoch_usec(0);
time_t utc_sec = tepoch_us / (1000U * 1000U); time_t utc_sec = tepoch_us / (1000U * 1000U);
struct tm* tm = gmtime(&utc_sec); struct tm tvd {};
struct tm* tm = gmtime_r(&utc_sec, &tvd);
p.year = tm->tm_year+1900; p.year = tm->tm_year+1900;
p.month = tm->tm_mon; p.month = tm->tm_mon;