Remove floating-point time functions from StopWatch
Converting time units between floating-point milliseconds to integral
micros and floating-point seconds is error prone and leads to subtle
rounding bugs. Thus, consolidate all callers on microseconds and delete
the older methods.
Test: cd system/netd && atest .
Change-Id: Ief6ad4dbd21f442bfd65e78d49548677f3172a53
diff --git a/client/NetdClient.cpp b/client/NetdClient.cpp
index bc8d3fc..84f2564 100644
--- a/client/NetdClient.cpp
+++ b/client/NetdClient.cpp
@@ -125,7 +125,7 @@
const int ret = libcConnect(sockfd, addr, addrlen);
// Save errno so it isn't clobbered by sending ON_CONNECT_COMPLETE
const int connectErrno = errno;
- const unsigned latencyMs = lround(s.timeTaken());
+ const auto latencyMs = static_cast<unsigned>(s.timeTakenUs() / 1000);
// Send an ON_CONNECT_COMPLETE command that includes sockaddr and connect latency for reporting
if (shouldSetFwmark && FwmarkClient::shouldReportConnectComplete(addr->sa_family)) {
FwmarkConnectInfo connectInfo(ret == 0 ? 0 : connectErrno, latencyMs, addr);