From: Luca Boccassi Date: Sat, 3 Apr 2021 13:46:46 +0000 (+0100) Subject: timedated: use format_timestamp instead of ctime X-Git-Tag: v249-rc1~446^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dfc5c4f26d12ae871465251751a85de5eb88d724;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 567244dc244..452c38e0de0 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); }