Skip to content

Commit

Permalink
selftests/ptp: Fix timestamp printf format for PTP_SYS_OFFSET
Browse files Browse the repository at this point in the history
Previously, timestamps were printed using "%lld.%u" which is incorrect
for nanosecond values lower than 100,000,000 as they're fractional
digits, therefore leading zeros are meaningful.

This patch changes the format strings to "%lld.%09u" in order to add
leading zeros to the nanosecond value.

Fixes: 568ebc5 ("ptp: add the PTP_SYS_OFFSET ioctl to the testptp program")
Fixes: 4ec54f9 ("ptp: Fix compiler warnings in the testptp utility")
Fixes: 6ab0e47 ("Documentation: fix misc. warnings")
Signed-off-by: Alex Maftei <[email protected]>
Acked-by: Richard Cochran <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
amaftei-xilinx authored and kuba-moo committed Jun 15, 2023
1 parent 30134b7 commit 76a4c8b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/testing/selftests/ptp/testptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,11 @@ int main(int argc, char *argv[])
interval = t2 - t1;
offset = (t2 + t1) / 2 - tp;

printf("system time: %lld.%u\n",
printf("system time: %lld.%09u\n",
(pct+2*i)->sec, (pct+2*i)->nsec);
printf("phc time: %lld.%u\n",
printf("phc time: %lld.%09u\n",
(pct+2*i+1)->sec, (pct+2*i+1)->nsec);
printf("system time: %lld.%u\n",
printf("system time: %lld.%09u\n",
(pct+2*i+2)->sec, (pct+2*i+2)->nsec);
printf("system/phc clock time offset is %" PRId64 " ns\n"
"system clock time delay is %" PRId64 " ns\n",
Expand Down

0 comments on commit 76a4c8b

Please sign in to comment.