diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2024-08-06 16:18:37 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-08-07 09:16:10 +0200 |
commit | b91bae1ded2822484085239eaba7823ac7434d69 (patch) | |
tree | 5609ba77a8127961540a5dbdbbbc5321366426eb /test/nstool.c | |
parent | 95569e4aa4da405c0df152956a58a119e248143c (diff) | |
download | passt-b91bae1ded2822484085239eaba7823ac7434d69.tar passt-b91bae1ded2822484085239eaba7823ac7434d69.tar.gz passt-b91bae1ded2822484085239eaba7823ac7434d69.tar.bz2 passt-b91bae1ded2822484085239eaba7823ac7434d69.tar.lz passt-b91bae1ded2822484085239eaba7823ac7434d69.tar.xz passt-b91bae1ded2822484085239eaba7823ac7434d69.tar.zst passt-b91bae1ded2822484085239eaba7823ac7434d69.zip |
log: Correct formatting of timestamps
logtime_fmt_and_arg() is a rather odd macro, producing both a format
string and an argument, which can only be used in quite specific printf()
like formulations. It also has a significant bug: it tries to display 4
digits after the decimal point (so down to tenths of milliseconds) using
%04i. But the field width in printf() is always a *minimum* not maximum
field width, so this will not truncate the given value, but will redisplay
the entire tenth-of-milliseconds difference again after the decimal point.
Replace the macro with an snprintf() like function which will format the
timestamp, and use an explicit % to correct the display.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[sbrivio: Make logtime_fmt() static]
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'test/nstool.c')
0 files changed, 0 insertions, 0 deletions