Skip to content

Commit 76a4c8b

Browse files
amaftei-xilinxkuba-moo
authored andcommitted
selftests/ptp: Fix timestamp printf format for PTP_SYS_OFFSET
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]>
1 parent 30134b7 commit 76a4c8b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/testing/selftests/ptp/testptp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,11 @@ int main(int argc, char *argv[])
502502
interval = t2 - t1;
503503
offset = (t2 + t1) / 2 - tp;
504504

505-
printf("system time: %lld.%u\n",
505+
printf("system time: %lld.%09u\n",
506506
(pct+2*i)->sec, (pct+2*i)->nsec);
507-
printf("phc time: %lld.%u\n",
507+
printf("phc time: %lld.%09u\n",
508508
(pct+2*i+1)->sec, (pct+2*i+1)->nsec);
509-
printf("system time: %lld.%u\n",
509+
printf("system time: %lld.%09u\n",
510510
(pct+2*i+2)->sec, (pct+2*i+2)->nsec);
511511
printf("system/phc clock time offset is %" PRId64 " ns\n"
512512
"system clock time delay is %" PRId64 " ns\n",

0 commit comments

Comments
 (0)