summaryrefslogtreecommitdiff
path: root/src/journal/journald-syslog.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-06-26 02:55:25 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-06-26 14:26:39 +0900
commite0f691e1fd62e631b1695111d2bed2b73cebfb9a (patch)
treeea23e50759ef02c7b35403ae400a58246192db9c /src/journal/journald-syslog.c
parentad16158c10dfc3258831a9ff2f1a988214f51653 (diff)
downloadsystemd-e0f691e1fd62e631b1695111d2bed2b73cebfb9a.tar.gz
tree-wide: use localtime_r() instead of localtime()
Follow-up for e46acb7950a9f07ac60d772309de842c444ad2bd.
Diffstat (limited to 'src/journal/journald-syslog.c')
-rw-r--r--src/journal/journald-syslog.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
index 9dea116722..01b8bf608d 100644
--- a/src/journal/journald-syslog.c
+++ b/src/journal/journald-syslog.c
@@ -117,7 +117,7 @@ void server_forward_syslog(Server *s, int priority, const char *identifier, cons
header_pid[STRLEN("[]: ") + DECIMAL_STR_MAX(pid_t) + 1];
int n = 0;
time_t t;
- struct tm *tm;
+ struct tm tm;
_cleanup_free_ char *ident_buf = NULL;
assert(s);
@@ -134,10 +134,9 @@ void server_forward_syslog(Server *s, int priority, const char *identifier, cons
/* Second: timestamp */
t = tv ? tv->tv_sec : ((time_t) (now(CLOCK_REALTIME) / USEC_PER_SEC));
- tm = localtime(&t);
- if (!tm)
+ if (!localtime_r(&t, &tm))
return;
- if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0)
+ if (strftime(header_time, sizeof(header_time), "%h %e %T ", &tm) <= 0)
return;
iovec[n++] = IOVEC_MAKE_STRING(header_time);