From 7c78c678069ffd424460cb7a555c8569251c9549 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Mon, 19 Jul 2021 12:50:44 +0200 Subject: code-style: change gmtime to the reentrant/thread-safe gmtime_r No functional or performance difference (intended) because these programs are not threaded. --- sfeed_atom.c | 4 ++-- sfeed_mbox.c | 4 ++-- sfeed_twtxt.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sfeed_atom.c b/sfeed_atom.c index 66698e8..96376a8 100644 --- a/sfeed_atom.c +++ b/sfeed_atom.c @@ -38,7 +38,7 @@ static void printfeed(FILE *fp, const char *feedname) { char *fields[FieldLast]; - struct tm *tm; + struct tm parsedtm, *tm; time_t parsedtime; ssize_t linelen; @@ -75,7 +75,7 @@ printfeed(FILE *fp, const char *feedname) parsedtime = 0; if (strtotime(fields[FieldUnixTimestamp], &parsedtime) || - !(tm = gmtime(&parsedtime))) + !(tm = gmtime_r(&parsedtime, &parsedtm))) tm = &tmnow; fprintf(stdout, "\t%04d-%02d-%02dT%02d:%02d:%02dZ\n", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, diff --git a/sfeed_mbox.c b/sfeed_mbox.c index 5803cea..d16b8d3 100644 --- a/sfeed_mbox.c +++ b/sfeed_mbox.c @@ -57,7 +57,7 @@ static void printfeed(FILE *fp, const char *feedname) { char *fields[FieldLast], timebuf[32]; - struct tm *tm; + struct tm parsedtm, *tm; time_t parsedtime; unsigned long hash; ssize_t linelen; @@ -74,7 +74,7 @@ printfeed(FILE *fp, const char *feedname) parsedtime = 0; if (!strtotime(fields[FieldUnixTimestamp], &parsedtime) && - (tm = gmtime(&parsedtime)) && + (tm = gmtime_r(&parsedtime, &parsedtm)) && strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S +0000", tm)) { printf("Date: %s\n", timebuf); } else { diff --git a/sfeed_twtxt.c b/sfeed_twtxt.c index b7d7fc4..231ad1f 100644 --- a/sfeed_twtxt.c +++ b/sfeed_twtxt.c @@ -13,7 +13,7 @@ static void printfeed(FILE *fp, const char *feedname) { char *fields[FieldLast]; - struct tm *tm; + struct tm parsedtm, *tm; time_t parsedtime; ssize_t linelen; @@ -24,7 +24,7 @@ printfeed(FILE *fp, const char *feedname) parsedtime = 0; if (!strtotime(fields[FieldUnixTimestamp], &parsedtime) && - (tm = gmtime(&parsedtime))) { + (tm = gmtime_r(&parsedtime, &parsedtm))) { fprintf(stdout, "%04d-%02d-%02dT%02d:%02d:%02dZ\t", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); -- cgit v1.2.3