mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-11-02 18:28:45 +05:00
refactor: use localtime_r(...) for thread safety
This commit is contained in:
1 parent
af2d4624b3
commit
9c2e420ec7
1 file changed
+6
-2
+6
-2
@@ -810,9 +810,13 @@ protected:
|
||||
|
||||
static void getFilename(char* filename, size_t maxSizeFilename, const char* type) {
|
||||
const time_t now = time(nullptr);
|
||||
const tm* localNow = localtime(&now);
|
||||
|
||||
tm localNow {};
|
||||
localtime_r(&now, &localNow);
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user