From 04f5c018cea46761e16880ea98d1412ba41410cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 1 Jul 2021 14:11:30 +0200 Subject: [PATCH] tree-wide: use FORMAT_TIMESTAMP() --- src/core/execute.c | 6 +-- src/core/main.c | 7 +--- src/core/manager-dump.c | 4 +- src/core/timer.c | 11 ++---- src/core/unit-serialize.c | 16 ++++---- src/coredump/coredumpctl.c | 4 +- src/libsystemd-network/test-ndisc-rs.c | 3 +- .../sd-journal/test-journal-verify.c | 6 +-- src/login/loginctl.c | 6 +-- src/login/logind-utmp.c | 3 +- src/machine/machinectl.c | 8 ++-- src/shared/bus-print-properties.c | 9 ++--- src/shared/user-record-show.c | 39 +++++++------------ src/shared/utmp-wtmp.c | 3 +- src/test/test-boot-timestamps.c | 8 ++-- src/test/test-btrfs.c | 4 +- src/test/test-calendarspec.c | 3 +- src/test/test-xattr-util.c | 4 +- src/timedate/timedatectl.c | 14 +++---- 19 files changed, 58 insertions(+), 100 deletions(-) diff --git a/src/core/execute.c b/src/core/execute.c index f760d6ae07a..bf9ee477f99 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -5963,8 +5963,6 @@ void exec_status_reset(ExecStatus *s) { } void exec_status_dump(const ExecStatus *s, FILE *f, const char *prefix) { - char buf[FORMAT_TIMESTAMP_MAX]; - assert(s); assert(f); @@ -5980,14 +5978,14 @@ void exec_status_dump(const ExecStatus *s, FILE *f, const char *prefix) { if (dual_timestamp_is_set(&s->start_timestamp)) fprintf(f, "%sStart Timestamp: %s\n", - prefix, format_timestamp(buf, sizeof(buf), s->start_timestamp.realtime)); + prefix, FORMAT_TIMESTAMP(s->start_timestamp.realtime)); if (dual_timestamp_is_set(&s->exit_timestamp)) fprintf(f, "%sExit Timestamp: %s\n" "%sExit Code: %s\n" "%sExit Status: %i\n", - prefix, format_timestamp(buf, sizeof(buf), s->exit_timestamp.realtime), + prefix, FORMAT_TIMESTAMP(s->exit_timestamp.realtime), prefix, sigchld_code_to_string(s->code), prefix, s->status); } diff --git a/src/core/main.c b/src/core/main.c index da6c50a1c40..ced6e99c9b5 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1616,12 +1616,9 @@ static void apply_clock_update(void) { if (clock_settime(CLOCK_REALTIME, timespec_store(&ts, arg_clock_usec)) < 0) log_error_errno(errno, "Failed to set system clock to time specified on kernel command line: %m"); - else { - char buf[FORMAT_TIMESTAMP_MAX]; - + else log_info("Set system clock to %s, as specified on the kernel command line.", - format_timestamp(buf, sizeof(buf), arg_clock_usec)); - } + FORMAT_TIMESTAMP(arg_clock_usec)); } static void cmdline_take_random_seed(void) { diff --git a/src/core/manager-dump.c b/src/core/manager-dump.c index dba32464e2b..3669da9f126 100644 --- a/src/core/manager-dump.c +++ b/src/core/manager-dump.c @@ -38,13 +38,13 @@ void manager_dump(Manager *m, FILE *f, const char *prefix) { for (ManagerTimestamp q = 0; q < _MANAGER_TIMESTAMP_MAX; q++) { const dual_timestamp *t = m->timestamps + q; - char buf[CONST_MAX(FORMAT_TIMESPAN_MAX, FORMAT_TIMESTAMP_MAX)]; + char buf[FORMAT_TIMESPAN_MAX]; if (dual_timestamp_is_set(t)) fprintf(f, "%sTimestamp %s: %s\n", strempty(prefix), manager_timestamp_to_string(q), - timestamp_is_set(t->realtime) ? format_timestamp(buf, sizeof buf, t->realtime) : + timestamp_is_set(t->realtime) ? FORMAT_TIMESTAMP(t->realtime) : format_timespan(buf, sizeof buf, t->monotonic, 1)); } diff --git a/src/core/timer.c b/src/core/timer.c index e064ad9a2dc..08a299c6daf 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -546,11 +546,9 @@ static void timer_enter_waiting(Timer *t, bool time_change) { } if (found_realtime) { - char buf[FORMAT_TIMESTAMP_MAX]; - add_random(t, &t->next_elapse_realtime); - log_unit_debug(UNIT(t), "Realtime timer elapses at %s.", format_timestamp(buf, sizeof(buf), t->next_elapse_realtime)); + log_unit_debug(UNIT(t), "Realtime timer elapses at %s.", FORMAT_TIMESTAMP(t->next_elapse_realtime)); if (t->realtime_event_source) { r = sd_event_source_set_time(t->realtime_event_source, t->next_elapse_realtime); @@ -664,12 +662,9 @@ static int timer_start(Unit *u) { ft = timespec_load(&st.st_mtim); if (ft < now(CLOCK_REALTIME)) t->last_trigger.realtime = ft; - else { - char z[FORMAT_TIMESTAMP_MAX]; - + else log_unit_warning(u, "Not using persistent file timestamp %s as it is in the future.", - format_timestamp(z, sizeof(z), ft)); - } + FORMAT_TIMESTAMP(ft)); } else if (errno == ENOENT) /* The timer has never run before, make sure a stamp file exists. */ diff --git a/src/core/unit-serialize.c b/src/core/unit-serialize.c index 689a536549d..f2292ee90f1 100644 --- a/src/core/unit-serialize.c +++ b/src/core/unit-serialize.c @@ -602,7 +602,7 @@ static void print_unit_dependency_mask(FILE *f, const char *kind, UnitDependency void unit_dump(Unit *u, FILE *f, const char *prefix) { char *t, **j; const char *prefix2; - char timestamp[5][FORMAT_TIMESTAMP_MAX], timespan[FORMAT_TIMESPAN_MAX]; + char timespan[FORMAT_TIMESPAN_MAX]; Unit *following; _cleanup_set_free_ Set *following_set = NULL; CGroupMask m; @@ -640,11 +640,11 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { prefix, strna(u->instance), prefix, unit_load_state_to_string(u->load_state), prefix, unit_active_state_to_string(unit_active_state(u)), - prefix, strna(format_timestamp(timestamp[0], sizeof(timestamp[0]), u->state_change_timestamp.realtime)), - prefix, strna(format_timestamp(timestamp[1], sizeof(timestamp[1]), u->inactive_exit_timestamp.realtime)), - prefix, strna(format_timestamp(timestamp[2], sizeof(timestamp[2]), u->active_enter_timestamp.realtime)), - prefix, strna(format_timestamp(timestamp[3], sizeof(timestamp[3]), u->active_exit_timestamp.realtime)), - prefix, strna(format_timestamp(timestamp[4], sizeof(timestamp[4]), u->inactive_enter_timestamp.realtime)), + prefix, strna(FORMAT_TIMESTAMP(u->state_change_timestamp.realtime)), + prefix, strna(FORMAT_TIMESTAMP(u->inactive_exit_timestamp.realtime)), + prefix, strna(FORMAT_TIMESTAMP(u->active_enter_timestamp.realtime)), + prefix, strna(FORMAT_TIMESTAMP(u->active_exit_timestamp.realtime)), + prefix, strna(FORMAT_TIMESTAMP(u->inactive_enter_timestamp.realtime)), prefix, yes_no(unit_may_gc(u)), prefix, yes_no(unit_need_daemon_reload(u)), prefix, yes_no(u->transient), @@ -756,14 +756,14 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) { fprintf(f, "%s\tCondition Timestamp: %s\n" "%s\tCondition Result: %s\n", - prefix, strna(format_timestamp(timestamp[0], sizeof(timestamp[0]), u->condition_timestamp.realtime)), + prefix, strna(FORMAT_TIMESTAMP(u->condition_timestamp.realtime)), prefix, yes_no(u->condition_result)); if (dual_timestamp_is_set(&u->assert_timestamp)) fprintf(f, "%s\tAssert Timestamp: %s\n" "%s\tAssert Result: %s\n", - prefix, strna(format_timestamp(timestamp[0], sizeof(timestamp[0]), u->assert_timestamp.realtime)), + prefix, strna(FORMAT_TIMESTAMP(u->assert_timestamp.realtime)), prefix, yes_no(u->assert_result)); for (UnitDependency d = 0; d < _UNIT_DEPENDENCY_MAX; d++) { diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index def3650bb45..556670468af 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -646,11 +646,11 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) { r = safe_atou64(timestamp, &u); if (r >= 0) { - char absolute[FORMAT_TIMESTAMP_MAX], relative[FORMAT_TIMESPAN_MAX]; + char relative[FORMAT_TIMESPAN_MAX]; fprintf(file, " Timestamp: %s (%s)\n", - format_timestamp(absolute, sizeof(absolute), u), + FORMAT_TIMESTAMP(u), format_timestamp_relative(relative, sizeof(relative), u)); } else diff --git a/src/libsystemd-network/test-ndisc-rs.c b/src/libsystemd-network/test-ndisc-rs.c index ce596bb96ab..c369e6919d0 100644 --- a/src/libsystemd-network/test-ndisc-rs.c +++ b/src/libsystemd-network/test-ndisc-rs.c @@ -31,7 +31,6 @@ static send_ra_t send_ra_function; static void router_dump(sd_ndisc_router *rt) { struct in6_addr addr; - char buf[FORMAT_TIMESTAMP_MAX]; uint8_t hop_limit; uint64_t t, flags; uint32_t mtu; @@ -45,7 +44,7 @@ static void router_dump(sd_ndisc_router *rt) { assert_se(sd_ndisc_router_get_address(rt, &addr) == -ENODATA); assert_se(sd_ndisc_router_get_timestamp(rt, CLOCK_REALTIME, &t) >= 0); - log_info("Timestamp: %s", format_timestamp(buf, sizeof(buf), t)); + log_info("Timestamp: %s", FORMAT_TIMESTAMP(t)); assert_se(sd_ndisc_router_get_timestamp(rt, CLOCK_MONOTONIC, &t) >= 0); log_info("Monotonic: %" PRIu64, t); diff --git a/src/libsystemd/sd-journal/test-journal-verify.c b/src/libsystemd/sd-journal/test-journal-verify.c index e9abfef0fc9..14123c0961c 100644 --- a/src/libsystemd/sd-journal/test-journal-verify.c +++ b/src/libsystemd/sd-journal/test-journal-verify.c @@ -57,8 +57,6 @@ int main(int argc, char *argv[]) { JournalFile *f; const char *verification_key = argv[1]; usec_t from = 0, to = 0, total = 0; - char a[FORMAT_TIMESTAMP_MAX]; - char b[FORMAT_TIMESTAMP_MAX]; char c[FORMAT_TIMESPAN_MAX]; struct stat st; uint64_t p; @@ -105,8 +103,8 @@ int main(int argc, char *argv[]) { if (verification_key && JOURNAL_HEADER_SEALED(f->header)) log_info("=> Validated from %s to %s, %s missing", - format_timestamp(a, sizeof(a), from), - format_timestamp(b, sizeof(b), to), + FORMAT_TIMESTAMP(from), + FORMAT_TIMESTAMP(to), format_timespan(c, sizeof(c), total > to ? total - to : 0, 0)); (void) journal_file_close(f); diff --git a/src/login/loginctl.c b/src/login/loginctl.c index cbb6518f4d2..b4f6548183c 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -451,7 +451,6 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; char since1[FORMAT_TIMESTAMP_RELATIVE_MAX]; - char since2[FORMAT_TIMESTAMP_MAX]; const char *s1, *s2; SessionStatusInfo i = {}; int r; @@ -473,7 +472,7 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li printf("%"PRIu32"\n", i.uid); s1 = format_timestamp_relative(since1, sizeof(since1), i.timestamp.realtime); - s2 = format_timestamp(since2, sizeof(since2), i.timestamp.realtime); + s2 = FORMAT_TIMESTAMP(i.timestamp.realtime); if (s1) printf("\t Since: %s; %s\n", s2, s1); @@ -582,7 +581,6 @@ static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line) _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; char since1[FORMAT_TIMESTAMP_RELATIVE_MAX]; - char since2[FORMAT_TIMESTAMP_MAX]; const char *s1, *s2; _cleanup_(user_status_info_clear) UserStatusInfo i = {}; int r; @@ -602,7 +600,7 @@ static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line) printf("%"PRIu32"\n", i.uid); s1 = format_timestamp_relative(since1, sizeof(since1), i.timestamp.realtime); - s2 = format_timestamp(since2, sizeof(since2), i.timestamp.realtime); + s2 = FORMAT_TIMESTAMP(i.timestamp.realtime); if (s1) printf("\t Since: %s; %s\n", s2, s1); diff --git a/src/login/logind-utmp.c b/src/login/logind-utmp.c index dfbbb641f3b..55338364733 100644 --- a/src/login/logind-utmp.c +++ b/src/login/logind-utmp.c @@ -58,7 +58,6 @@ bool logind_wall_tty_filter(const char *tty, void *userdata) { } static int warn_wall(Manager *m, usec_t n) { - char date[FORMAT_TIMESTAMP_MAX] = {}; _cleanup_free_ char *l = NULL, *username = NULL; usec_t left; int r; @@ -75,7 +74,7 @@ static int warn_wall(Manager *m, usec_t n) { isempty(m->wall_message) ? "" : "\n", m->scheduled_shutdown_type, left ? "at " : "NOW", - left ? format_timestamp(date, sizeof(date), m->scheduled_shutdown_timeout) : ""); + left ? FORMAT_TIMESTAMP(m->scheduled_shutdown_timeout) : ""); if (r < 0) { log_oom(); return 0; diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index beab50e3158..1bae6d88748 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -508,7 +508,6 @@ static void machine_status_info_clear(MachineStatusInfo *info) { static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) { char since1[FORMAT_TIMESTAMP_RELATIVE_MAX]; - char since2[FORMAT_TIMESTAMP_MAX]; _cleanup_free_ char *addresses = NULL; const char *s1, *s2; int ifi = -1; @@ -524,7 +523,7 @@ static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) { putchar('\n'); s1 = format_timestamp_relative(since1, sizeof(since1), i->timestamp.realtime); - s2 = format_timestamp(since2, sizeof(since2), i->timestamp.realtime); + s2 = FORMAT_TIMESTAMP(i->timestamp.realtime); if (s1) printf("\t Since: %s; %s\n", s2, s1); @@ -829,7 +828,6 @@ typedef struct ImageStatusInfo { static void print_image_status_info(sd_bus *bus, ImageStatusInfo *i) { char ts_relative[FORMAT_TIMESTAMP_RELATIVE_MAX]; - char ts_absolute[FORMAT_TIMESTAMP_MAX]; char bs[FORMAT_BYTES_MAX]; char bs_exclusive[FORMAT_BYTES_MAX]; const char *s1, *s2, *s3, *s4; @@ -860,14 +858,14 @@ static void print_image_status_info(sd_bus *bus, ImageStatusInfo *i) { i->read_only ? ansi_normal() : ""); s1 = format_timestamp_relative(ts_relative, sizeof(ts_relative), i->crtime); - s2 = format_timestamp(ts_absolute, sizeof(ts_absolute), i->crtime); + s2 = FORMAT_TIMESTAMP(i->crtime); if (s1 && s2) printf("\t Created: %s; %s\n", s2, s1); else if (s2) printf("\t Created: %s\n", s2); s1 = format_timestamp_relative(ts_relative, sizeof(ts_relative), i->mtime); - s2 = format_timestamp(ts_absolute, sizeof(ts_absolute), i->mtime); + s2 = FORMAT_TIMESTAMP(i->mtime); if (s1 && s2) printf("\tModified: %s; %s\n", s2, s1); else if (s2) diff --git a/src/shared/bus-print-properties.c b/src/shared/bus-print-properties.c index b45921943a8..7bf0bcf737b 100644 --- a/src/shared/bus-print-properties.c +++ b/src/shared/bus-print-properties.c @@ -105,14 +105,11 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b * should it turn out to not be sufficient */ if (endswith(name, "Timestamp") || - STR_IN_SET(name, "NextElapseUSecRealtime", "LastTriggerUSec", "TimeUSec", "RTCTimeUSec")) { - char timestamp[FORMAT_TIMESTAMP_MAX]; - const char *t; + STR_IN_SET(name, "NextElapseUSecRealtime", "LastTriggerUSec", "TimeUSec", "RTCTimeUSec")) - t = format_timestamp(timestamp, sizeof(timestamp), u); - bus_print_property_value(name, expected_value, flags, t); + bus_print_property_value(name, expected_value, flags, FORMAT_TIMESTAMP(u)); - } else if (strstr(name, "USec")) { + else if (strstr(name, "USec")) { char timespan[FORMAT_TIMESPAN_MAX]; (void) format_timespan(timespan, sizeof(timespan), u, 0); diff --git a/src/shared/user-record-show.c b/src/shared/user-record-show.c index 29790282b4e..1d8aa7c5fd8 100644 --- a/src/shared/user-record-show.c +++ b/src/shared/user-record-show.c @@ -43,8 +43,7 @@ void user_record_show(UserRecord *hr, bool show_full_group_info) { printf(" Disposition: %s\n", user_disposition_to_string(user_record_disposition(hr))); if (hr->last_change_usec != USEC_INFINITY) { - char buf[FORMAT_TIMESTAMP_MAX]; - printf(" Last Change: %s\n", format_timestamp(buf, sizeof(buf), hr->last_change_usec)); + printf(" Last Change: %s\n", FORMAT_TIMESTAMP(hr->last_change_usec)); if (hr->last_change_usec > now(CLOCK_REALTIME)) printf(" %sModification time lies in the future, system clock wrong?%s\n", @@ -52,10 +51,8 @@ void user_record_show(UserRecord *hr, bool show_full_group_info) { } if (hr->last_password_change_usec != USEC_INFINITY && - hr->last_password_change_usec != hr->last_change_usec) { - char buf[FORMAT_TIMESTAMP_MAX]; - printf(" Last Passw.: %s\n", format_timestamp(buf, sizeof(buf), hr->last_password_change_usec)); - } + hr->last_password_change_usec != hr->last_change_usec) + printf(" Last Passw.: %s\n", FORMAT_TIMESTAMP(hr->last_password_change_usec)); r = user_record_test_blocked(hr); switch (r) { @@ -238,15 +235,11 @@ void user_record_show(UserRecord *hr, bool show_full_group_info) { if (hr->locked >= 0) printf(" Locked: %s\n", yes_no(hr->locked)); - if (hr->not_before_usec != UINT64_MAX) { - char buf[FORMAT_TIMESTAMP_MAX]; - printf(" Not Before: %s\n", format_timestamp(buf, sizeof(buf), hr->not_before_usec)); - } + if (hr->not_before_usec != UINT64_MAX) + printf(" Not Before: %s\n", FORMAT_TIMESTAMP(hr->not_before_usec)); - if (hr->not_after_usec != UINT64_MAX) { - char buf[FORMAT_TIMESTAMP_MAX]; - printf(" Not After: %s\n", format_timestamp(buf, sizeof(buf), hr->not_after_usec)); - } + if (hr->not_after_usec != UINT64_MAX) + printf(" Not After: %s\n", FORMAT_TIMESTAMP(hr->not_after_usec)); if (hr->umask != MODE_INVALID) printf(" UMask: 0%03o\n", hr->umask); @@ -401,18 +394,14 @@ void user_record_show(UserRecord *hr, bool show_full_group_info) { if (hr->good_authentication_counter != UINT64_MAX) printf(" Good Auth.: %" PRIu64 "\n", hr->good_authentication_counter); - if (hr->last_good_authentication_usec != UINT64_MAX) { - char buf[FORMAT_TIMESTAMP_MAX]; - printf(" Last Good: %s\n", format_timestamp(buf, sizeof(buf), hr->last_good_authentication_usec)); - } + if (hr->last_good_authentication_usec != UINT64_MAX) + printf(" Last Good: %s\n", FORMAT_TIMESTAMP(hr->last_good_authentication_usec)); if (hr->bad_authentication_counter != UINT64_MAX) printf(" Bad Auth.: %" PRIu64 "\n", hr->bad_authentication_counter); - if (hr->last_bad_authentication_usec != UINT64_MAX) { - char buf[FORMAT_TIMESTAMP_MAX]; - printf(" Last Bad: %s\n", format_timestamp(buf, sizeof(buf), hr->last_bad_authentication_usec)); - } + if (hr->last_bad_authentication_usec != UINT64_MAX) + printf(" Last Bad: %s\n", FORMAT_TIMESTAMP(hr->last_bad_authentication_usec)); t = user_record_ratelimit_next_try(hr); if (t != USEC_INFINITY) { @@ -519,10 +508,8 @@ void group_record_show(GroupRecord *gr, bool show_full_user_info) { printf(" Disposition: %s\n", user_disposition_to_string(group_record_disposition(gr))); - if (gr->last_change_usec != USEC_INFINITY) { - char buf[FORMAT_TIMESTAMP_MAX]; - printf(" Last Change: %s\n", format_timestamp(buf, sizeof(buf), gr->last_change_usec)); - } + if (gr->last_change_usec != USEC_INFINITY) + printf(" Last Change: %s\n", FORMAT_TIMESTAMP(gr->last_change_usec)); if (gid_is_valid(gr->gid)) printf(" GID: " GID_FMT "\n", gr->gid); diff --git a/src/shared/utmp-wtmp.c b/src/shared/utmp-wtmp.c index 3eeee24693f..b31cdd679ba 100644 --- a/src/shared/utmp-wtmp.c +++ b/src/shared/utmp-wtmp.c @@ -340,7 +340,6 @@ int utmp_wall( void *userdata) { _cleanup_free_ char *text = NULL, *hn = NULL, *un = NULL, *stdin_tty = NULL; - char date[FORMAT_TIMESTAMP_MAX]; struct utmpx *u; int r; @@ -364,7 +363,7 @@ int utmp_wall( "%s\r\n\r\n", un ?: username, hn, origin_tty ? " on " : "", strempty(origin_tty), - format_timestamp(date, sizeof(date), now(CLOCK_REALTIME)), + FORMAT_TIMESTAMP(now(CLOCK_REALTIME)), message) < 0) return -ENOMEM; diff --git a/src/test/test-boot-timestamps.c b/src/test/test-boot-timestamps.c index ae5b5821f0f..15189df60b5 100644 --- a/src/test/test-boot-timestamps.c +++ b/src/test/test-boot-timestamps.c @@ -51,7 +51,7 @@ static int test_efi_loader(void) { } static int test_boot_timestamps(void) { - char s[MAX(FORMAT_TIMESPAN_MAX, FORMAT_TIMESTAMP_MAX)]; + char s[FORMAT_TIMESPAN_MAX]; dual_timestamp fw, l, k; int r; @@ -67,9 +67,9 @@ static int test_boot_timestamps(void) { log_info("Firmware began %s before kernel.", format_timespan(s, sizeof(s), fw.monotonic, 0)); log_info("Loader began %s before kernel.", format_timespan(s, sizeof(s), l.monotonic, 0)); - log_info("Firmware began %s.", format_timestamp(s, sizeof(s), fw.realtime)); - log_info("Loader began %s.", format_timestamp(s, sizeof(s), l.realtime)); - log_info("Kernel began %s.", format_timestamp(s, sizeof(s), k.realtime)); + log_info("Firmware began %s.", FORMAT_TIMESTAMP(fw.realtime)); + log_info("Loader began %s.", FORMAT_TIMESTAMP(l.realtime)); + log_info("Kernel began %s.", FORMAT_TIMESTAMP(k.realtime)); return 1; } diff --git a/src/test/test-btrfs.c b/src/test/test-btrfs.c index e840536d4b3..829fc24c383 100644 --- a/src/test/test-btrfs.c +++ b/src/test/test-btrfs.c @@ -18,14 +18,14 @@ int main(int argc, char *argv[]) { if (fd < 0) log_error_errno(errno, "Failed to open root directory: %m"); else { - char ts[FORMAT_TIMESTAMP_MAX], bs[FORMAT_BYTES_MAX]; + char bs[FORMAT_BYTES_MAX]; BtrfsSubvolInfo info; r = btrfs_subvol_get_info_fd(fd, 0, &info); if (r < 0) log_error_errno(r, "Failed to get subvolume info: %m"); else { - log_info("otime: %s", format_timestamp(ts, sizeof(ts), info.otime)); + log_info("otime: %s", FORMAT_TIMESTAMP(info.otime)); log_info("read-only (search): %s", yes_no(info.read_only)); } diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c index 4f1d0f64d57..d6ff7b7b218 100644 --- a/src/test/test-calendarspec.c +++ b/src/test/test-calendarspec.c @@ -10,7 +10,6 @@ static void _test_one(int line, const char *input, const char *output) { CalendarSpec *c; _cleanup_free_ char *p = NULL, *q = NULL; usec_t u; - char buf[FORMAT_TIMESTAMP_MAX]; int r; assert_se(calendar_spec_from_string(input, &c) >= 0); @@ -22,7 +21,7 @@ static void _test_one(int line, const char *input, const char *output) { u = now(CLOCK_REALTIME); r = calendar_spec_next_usec(c, u, &u); - log_info("Next: %s", r < 0 ? strerror_safe(r) : format_timestamp(buf, sizeof buf, u)); + log_info("Next: %s", r < 0 ? strerror_safe(r) : FORMAT_TIMESTAMP(u)); calendar_spec_free(c); assert_se(calendar_spec_from_string(p, &c) >= 0); diff --git a/src/test/test-xattr-util.c b/src/test/test-xattr-util.c index 6aa55ba17ef..7017b02ac9b 100644 --- a/src/test/test-xattr-util.c +++ b/src/test/test-xattr-util.c @@ -51,9 +51,7 @@ cleanup: } static void test_getcrtime(void) { - _cleanup_close_ int fd = -1; - char ts[FORMAT_TIMESTAMP_MAX]; const char *vt; usec_t usec, k; int r; @@ -67,7 +65,7 @@ static void test_getcrtime(void) { if (r < 0) log_debug_errno(r, "btime: %m"); else - log_debug("btime: %s", format_timestamp(ts, sizeof(ts), usec)); + log_debug("btime: %s", FORMAT_TIMESTAMP(usec)); k = now(CLOCK_REALTIME); diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index d31f67f4cb3..2332a9808ae 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -717,7 +717,7 @@ static int print_timesync_property(const char *name, const char *expected_value, case SD_BUS_TYPE_STRUCT: if (streq(name, "NTPMessage")) { _cleanup_(ntp_status_info_clear) NTPStatusInfo i = {}; - char ts[FORMAT_TIMESPAN_MAX], stamp[FORMAT_TIMESTAMP_MAX]; + char ts[FORMAT_TIMESPAN_MAX]; r = map_ntp_message(NULL, NULL, m, NULL, &i); if (r < 0) @@ -743,14 +743,10 @@ static int print_timesync_property(const char *name, const char *expected_value, else printf(" Reference=%" PRIX32 ",", be32toh(i.reference.val)); - printf(" OriginateTimestamp=%s,", - format_timestamp(stamp, sizeof(stamp), i.origin)); - printf(" ReceiveTimestamp=%s,", - format_timestamp(stamp, sizeof(stamp), i.recv)); - printf(" TransmitTimestamp=%s,", - format_timestamp(stamp, sizeof(stamp), i.trans)); - printf(" DestinationTimestamp=%s,", - format_timestamp(stamp, sizeof(stamp), i.dest)); + printf(" OriginateTimestamp=%s,", FORMAT_TIMESTAMP(i.origin)); + printf(" ReceiveTimestamp=%s,", FORMAT_TIMESTAMP(i.recv)); + printf(" TransmitTimestamp=%s,", FORMAT_TIMESTAMP(i.trans)); + printf(" DestinationTimestamp=%s,", FORMAT_TIMESTAMP(i.dest)); printf(" Ignored=%s PacketCount=%" PRIu64 ",", yes_no(i.spike), i.packet_count); printf(" Jitter=%s }\n", -- 2.39.2