Skip to content

Commit

Permalink
clients/upsstats.c: convert from localtime() to localtime_r() which i…
Browse files Browse the repository at this point in the history
…s thread-safe
  • Loading branch information
jimklimov committed Nov 17, 2020
1 parent acd9b7b commit a9537df
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clients/upsstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,10 @@ static int do_date(const char *buf)
{
char datebuf[SMALLBUF];
time_t tod;
struct tm tmbuf;

time(&tod);
if (strftime(datebuf, sizeof(datebuf), buf, localtime(&tod))) {
if (strftime(datebuf, sizeof(datebuf), buf, localtime_r(&tod, &tmbuf))) {
printf("%s", datebuf);
return 1;
}
Expand Down

0 comments on commit a9537df

Please sign in to comment.