From dfc5c4f26d12ae871465251751a85de5eb88d724 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sat, 3 Apr 2021 14:46:46 +0100 Subject: 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. --- src/timedate/timedated.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/timedate') 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); } -- cgit v1.2.1