summaryrefslogtreecommitdiff
path: root/src/timedate
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2021-04-03 14:46:46 +0100
committerLuca Boccassi <luca.boccassi@microsoft.com>2021-04-08 13:07:31 +0100
commitdfc5c4f26d12ae871465251751a85de5eb88d724 (patch)
tree303348bf54574c55dec9308a29c72b07979f0e0d /src/timedate
parent71d1e58309bb70bb2a014f33c5f9503dcbed020c (diff)
downloadsystemd-dfc5c4f26d12ae871465251751a85de5eb88d724.tar.gz
timedated: use format_timestamp instead of ctime
Some static analyzers (lgtm) warn against using non-re-entrant functions, even though at the moment this code is not multi-threaded, just switch to format_timestamp.
Diffstat (limited to 'src/timedate')
-rw-r--r--src/timedate/timedated.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 567244dc24..452c38e0de 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -801,6 +801,7 @@ static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error
static int method_set_time(sd_bus_message *m, void *userdata, sd_bus_error *error) {
sd_bus *bus = sd_bus_message_get_bus(m);
+ char buf[FORMAT_TIMESTAMP_MAX];
int relative, interactive, r;
Context *c = userdata;
int64_t utc;
@@ -886,7 +887,7 @@ static int method_set_time(sd_bus_message *m, void *userdata, sd_bus_error *erro
log_struct(LOG_INFO,
"MESSAGE_ID=" SD_MESSAGE_TIME_CHANGE_STR,
"REALTIME="USEC_FMT, timespec_load(&ts),
- LOG_MESSAGE("Changed local time to %s", ctime(&ts.tv_sec)));
+ LOG_MESSAGE("Changed local time to %s", strnull(format_timestamp(buf, sizeof(buf), timespec_load(&ts)))));
return sd_bus_reply_method_return(m, NULL);
}