]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use FORMAT_TIMESTAMP()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 1 Jul 2021 12:11:30 +0000 (14:11 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 9 Jul 2021 09:03:35 +0000 (11:03 +0200)
19 files changed:
src/core/execute.c
src/core/main.c
src/core/manager-dump.c
src/core/timer.c
src/core/unit-serialize.c
src/coredump/coredumpctl.c
src/libsystemd-network/test-ndisc-rs.c
src/libsystemd/sd-journal/test-journal-verify.c
src/login/loginctl.c
src/login/logind-utmp.c
src/machine/machinectl.c
src/shared/bus-print-properties.c
src/shared/user-record-show.c
src/shared/utmp-wtmp.c
src/test/test-boot-timestamps.c
src/test/test-btrfs.c
src/test/test-calendarspec.c
src/test/test-xattr-util.c
src/timedate/timedatectl.c

index f760d6ae07aefbad8adf2b70e588fdfc447be7a5..bf9ee477f99a30d817b42b5ae1ec70baf4c83d13 100644 (file)
@@ -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);
 }
index da6c50a1c40e10933f555f68f8f1bfb1b71f5928..ced6e99c9b5dfdddf3c35cbfdb30d792abc8ac16 100644 (file)
@@ -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) {
index dba32464e2b9063ae86b66c4fcbd2a6d2ca03b0d..3669da9f126e3d440c82a15ec69fb867ed53950b 100644 (file)
@@ -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));
         }
 
index e064ad9a2dc9876ff8a4175feb8766a663cee715..08a299c6daf2c49cb4ccbe22b81634259e674498 100644 (file)
@@ -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. */
index 689a536549df5e2ab216813fbb52baf449a8b895..f2292ee90f1ac5aa5f1748935d392500ef0b83fa 100644 (file)
@@ -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++) {
index def3650bb4588107bba8aea3912660f473dac955..556670468af5d3fa8827f33e95397fb561ca12b1 100644 (file)
@@ -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
index ce596bb96ab6d229f391577c590e9421fe0a8f05..c369e6919d041eb0b5c27ceff1ea5341d602a799 100644 (file)
@@ -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);
index e9abfef0fc9376b2cbc00e87d0bb92076ba42318..14123c0961c0af0f5c402af41209b68dc8d521bb 100644 (file)
@@ -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);
index cbb6518f4d2031d6ac8fed65c5d8ada59162b63b..b4f6548183cf892329f67248d6af62931c96f762 100644 (file)
@@ -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);
index dfbbb641f3ba61d310173b153f66a4e93d0a6850..553383647336a47235d047b495593f06faecd0a3 100644 (file)
@@ -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;
index beab50e3158fd17fe7f90df7b31b6acd4328d9f1..1bae6d887486bd7c7aabcb0a6732a216fb5fe17d 100644 (file)
@@ -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)
index b45921943a8689af1a053ed839a0c56ef01d16f6..7bf0bcf737b96fd2a66a2a416d1249e3a137d5bc 100644 (file)
@@ -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);
index 29790282b4e2c648b231b083e8b287459e7a6a34..1d8aa7c5fd8f4781ee7546cbf8fb7edfc4e93e08 100644 (file)
@@ -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);
index 3eeee24693ff3d87637df0bf1560e67bdafbfab2..b31cdd679ba56ab2c7e4be1c9a8e8f753f11a683 100644 (file)
@@ -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;
 
index ae5b5821f0fa822ba2553939d67fb97579dcca0c..15189df60b5ce015b32b37594745c8ad7138b9ed 100644 (file)
@@ -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;
 }
 
index e840536d4b37273f10e87baf9bb944d68cd36ab6..829fc24c3837669cebb029baccd6e3669a3bfed6 100644 (file)
@@ -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));
                 }
 
index 4f1d0f64d5772f3353aee98b4a87810f2bab0e5d..d6ff7b7b218ab93f84d254a36ac56f24704c2469 100644 (file)
@@ -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);
index 6aa55ba17efe40e3bcd1530067df2cea9e426f95..7017b02ac9b8d481c2e48529cac557520a24f96a 100644 (file)
@@ -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);
 
index d31f67f4cb3e4877c77a60220753b0567088476c..2332a9808ae3067f02607d3499e0871e9cfd4f60 100644 (file)
@@ -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",