mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-05-17 14:58:14 +05:00
refactor: use localtime_r(...) for thread safety
This commit is contained in:
+6
-2
@@ -810,9 +810,13 @@ protected:
|
|||||||
|
|
||||||
static void getFilename(char* filename, size_t maxSizeFilename, const char* type) {
|
static void getFilename(char* filename, size_t maxSizeFilename, const char* type) {
|
||||||
const time_t now = time(nullptr);
|
const time_t now = time(nullptr);
|
||||||
const tm* localNow = localtime(&now);
|
|
||||||
|
tm localNow {};
|
||||||
|
localtime_r(&now, &localNow);
|
||||||
|
|
||||||
char localNowValue[20];
|
char localNowValue[20];
|
||||||
strftime(localNowValue, sizeof(localNowValue), PSTR("%Y-%m-%d-%H-%M-%S"), localNow);
|
strftime(localNowValue, sizeof(localNowValue), PSTR("%Y-%m-%d-%H-%M-%S"), &localNow);
|
||||||
|
|
||||||
snprintf_P(filename, maxSizeFilename, PSTR("%s_%s_%s.json"), networkSettings.hostname, localNowValue, type);
|
snprintf_P(filename, maxSizeFilename, PSTR("%s_%s_%s.json"), networkSettings.hostname, localNowValue, type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user