mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-03 13:20:28 -05:00
Use localtime_r() when available
No effect on the monothread context, but avoid warnings from static analysis.
This commit is contained in:
parent
4653dde7c5
commit
24f746bf82
1 changed files with 14 additions and 0 deletions
|
|
@ -131,13 +131,20 @@ void log_open(const char* file)
|
||||||
char text_D[32];
|
char text_D[32];
|
||||||
time_t t;
|
time_t t;
|
||||||
struct tm* tm;
|
struct tm* tm;
|
||||||
|
#if HAVE_LOCALTIME_R
|
||||||
|
struct tm tm_res;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* leave stdlog at 0 if not specified */
|
/* leave stdlog at 0 if not specified */
|
||||||
if (file == 0)
|
if (file == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
t = time(0);
|
t = time(0);
|
||||||
|
#if HAVE_LOCALTIME_R
|
||||||
|
tm = localtime_r(&t, &tm_res);
|
||||||
|
#else
|
||||||
tm = localtime(&t);
|
tm = localtime(&t);
|
||||||
|
#endif
|
||||||
if (tm) {
|
if (tm) {
|
||||||
strftime(text_T, sizeof(text_T), "%H%M%S", tm);
|
strftime(text_T, sizeof(text_T), "%H%M%S", tm);
|
||||||
strftime(text_D, sizeof(text_T), "%Y%m%d", tm);
|
strftime(text_D, sizeof(text_T), "%Y%m%d", tm);
|
||||||
|
|
@ -552,6 +559,9 @@ int main(int argc, char* argv[])
|
||||||
int period;
|
int period;
|
||||||
time_t t;
|
time_t t;
|
||||||
struct tm* tm;
|
struct tm* tm;
|
||||||
|
#if HAVE_LOCALTIME_R
|
||||||
|
struct tm tm_res;
|
||||||
|
#endif
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
test(argc, argv);
|
test(argc, argv);
|
||||||
|
|
@ -1225,7 +1235,11 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
/* print generic info into the log */
|
/* print generic info into the log */
|
||||||
t = time(0);
|
t = time(0);
|
||||||
|
#if HAVE_LOCALTIME_R
|
||||||
|
tm = localtime_r(&t, &tm_res);
|
||||||
|
#else
|
||||||
tm = localtime(&t);
|
tm = localtime(&t);
|
||||||
|
#endif
|
||||||
log_tag("version:%s\n", PACKAGE_VERSION);
|
log_tag("version:%s\n", PACKAGE_VERSION);
|
||||||
log_tag("unixtime:%" PRIi64 "\n", (int64_t)t);
|
log_tag("unixtime:%" PRIi64 "\n", (int64_t)t);
|
||||||
if (tm) {
|
if (tm) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue