diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-07-15 19:11:16 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-07-15 19:11:16 +0200 |
commit | 08f105df24c562a9c50646a4b35590e5d03ebbda (patch) | |
tree | 74e6c331b61365835cafbc382b1887f895eb94b7 /src/analyze/analyze.c | |
parent | 8b693c634de582e59d4562597fcdc89e8568ade0 (diff) | |
download | systemd-08f105df24c562a9c50646a4b35590e5d03ebbda.tar.gz systemd-08f105df24c562a9c50646a4b35590e5d03ebbda.tar.bz2 systemd-08f105df24c562a9c50646a4b35590e5d03ebbda.zip |
analyze: fix formatting of timestamps with 0 µs
There is a rule that "%.0d" formats 0 as "". There is no such rule for
"%0d" and 0 :(. The output had an extra 0 if usec was 0.
Diffstat (limited to 'src/analyze/analyze.c')
-rw-r--r-- | src/analyze/analyze.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index b7545c08e2..e9e66b3da6 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1859,11 +1859,13 @@ static int test_timestamp_one(const char *p) { if (r < 0) return r; - r = table_add_cell_stringf(table, &cell, "@%"PRI_USEC"%s%0*"PRI_USEC"", - usec / USEC_PER_SEC, - usec % USEC_PER_SEC ? "." : "", - usec % USEC_PER_SEC ? 6 : 0, - usec % USEC_PER_SEC); + if (usec % USEC_PER_SEC == 0) + r = table_add_cell_stringf(table, &cell, "@%"PRI_USEC, + usec / USEC_PER_SEC); + else + r = table_add_cell_stringf(table, &cell, "@%"PRI_USEC".%06"PRI_USEC"", + usec / USEC_PER_SEC, + usec % USEC_PER_SEC); if (r < 0) return r; |