Skip to contentSkip to conversation

testptp: fix format specifier in nsec print

PATCH New [email protected] 1 participant 1 message May 10, 2023 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 testptp: fix format specifier in nsec print

From: Amit Bernstein <[email protected]>

Fix printf to include leading zeros when the nsec component is less than 9 digits to ensure correct time representation of "sec.nsec".

---
 tools/testing/selftests/ptp/testptp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/ptp/testptp.c +3 -3
index 198ad5f32..cfa9562f3 100644
@@ -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",
Signature · 1 line
2.17.1