summaryrefslogtreecommitdiff
path: root/src/cdf_time.c
diff options
context:
space:
mode:
authorChristos Zoulas <christos@zoulas.com>2012-05-15 17:14:36 +0000
committerChristos Zoulas <christos@zoulas.com>2012-05-15 17:14:36 +0000
commita5faca599f63db734dc0b43b0105d5a57246e6d9 (patch)
treeb4f04f23e4cd1b6d5d24656e9ea0e8201fc44ba7 /src/cdf_time.c
parentffa3cb799e0d79ed40b06385d96ce66502db6ddb (diff)
downloadfile-git-a5faca599f63db734dc0b43b0105d5a57246e6d9.tar.gz
use ctime_r, asctime_r.
Diffstat (limited to 'src/cdf_time.c')
-rw-r--r--src/cdf_time.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/cdf_time.c b/src/cdf_time.c
index 8ace09e5..03e3cc93 100644
--- a/src/cdf_time.c
+++ b/src/cdf_time.c
@@ -27,7 +27,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: cdf_time.c,v 1.10 2011/02/10 17:03:16 christos Exp $")
+FILE_RCSID("@(#)$File: cdf_time.c,v 1.11 2011/12/13 13:48:41 christos Exp $")
#endif
#include <time.h>
@@ -166,15 +166,13 @@ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts)
}
char *
-cdf_ctime(const time_t *sec)
+cdf_ctime(const time_t *sec, char *buf)
{
- static char ctbuf[26];
- char *ptr = ctime(sec);
+ char *ptr = ctime_r(sec, buf);
if (ptr != NULL)
- return ptr;
- (void)snprintf(ctbuf, sizeof(ctbuf), "*Bad* 0x%16.16llx\n",
- (long long)*sec);
- return ctbuf;
+ return buf;
+ (void)snprintf(buf, 26, "*Bad* 0x%16.16llx\n", (long long)*sec);
+ return buf;
}
@@ -183,12 +181,13 @@ int
main(int argc, char *argv[])
{
struct timespec ts;
+ char buf[25];
static const cdf_timestamp_t tst = 0x01A5E403C2D59C00ULL;
static const char *ref = "Sat Apr 23 01:30:00 1977";
char *p, *q;
cdf_timestamp_to_timespec(&ts, tst);
- p = cdf_ctime(&ts.tv_sec);
+ p = cdf_ctime(&ts.tv_sec, buf);
if ((q = strchr(p, '\n')) != NULL)
*q = '\0';
if (strcmp(ref, p) != 0)