Clean up errno logs and sto* conversions
I learned that we should be using PLOG to log errno strings, and we
should be avoiding stoi, stol, etc... conversions and instead use the
built in Android ParseInt/ParseUint functions.
Bug: 150250606
Bug: 150245058
Test: Manual for CLI tools, VTS for everything else
Merged-In: Icdd8a6af8564d5de3bedd1bc934f7928eb5e66e9
Change-Id: Icdd8a6af8564d5de3bedd1bc934f7928eb5e66e9
(cherry picked from commit 1173a7253becba2b548057112372c8a94d9b6a41)
diff --git a/automotive/can/1.0/default/libnetdevice/NetlinkSocket.cpp b/automotive/can/1.0/default/libnetdevice/NetlinkSocket.cpp
index 6a7f506..7817169 100644
--- a/automotive/can/1.0/default/libnetdevice/NetlinkSocket.cpp
+++ b/automotive/can/1.0/default/libnetdevice/NetlinkSocket.cpp
@@ -23,7 +23,7 @@
NetlinkSocket::NetlinkSocket(int protocol) {
mFd.reset(socket(AF_NETLINK, SOCK_RAW, protocol));
if (!mFd.ok()) {
- LOG(ERROR) << "Can't open Netlink socket: " << errno;
+ PLOG(ERROR) << "Can't open Netlink socket";
mFailed = true;
return;
}
@@ -32,7 +32,7 @@
sa.nl_family = AF_NETLINK;
if (bind(mFd.get(), reinterpret_cast<struct sockaddr*>(&sa), sizeof(sa)) < 0) {
- LOG(ERROR) << "Can't bind Netlink socket: " << errno;
+ PLOG(ERROR) << "Can't bind Netlink socket";
mFd.reset();
mFailed = true;
}
@@ -57,7 +57,7 @@
msg.msg_iovlen = 1;
if (sendmsg(mFd.get(), &msg, 0) < 0) {
- LOG(ERROR) << "Can't send Netlink message: " << errno;
+ PLOG(ERROR) << "Can't send Netlink message";
return false;
}
return true;
@@ -79,7 +79,7 @@
const ssize_t status = recvmsg(mFd.get(), &msg, 0);
if (status < 0) {
- LOG(ERROR) << "Failed to receive Netlink message: " << errno;
+ PLOG(ERROR) << "Failed to receive Netlink message";
return false;
}
size_t remainingLen = status;
diff --git a/automotive/can/1.0/default/libnetdevice/can.cpp b/automotive/can/1.0/default/libnetdevice/can.cpp
index 06d45d3..a2a85dc 100644
--- a/automotive/can/1.0/default/libnetdevice/can.cpp
+++ b/automotive/can/1.0/default/libnetdevice/can.cpp
@@ -48,7 +48,7 @@
}
if (setsockopt(sock.get(), SOL_CAN_RAW, CAN_RAW_ERR_FILTER, &kErrMask, sizeof(kErrMask)) < 0) {
- LOG(ERROR) << "Can't receive error frames, CAN setsockpt failed: " << strerror(errno);
+ PLOG(ERROR) << "Can't receive error frames, CAN setsockpt failed";
return {};
}
diff --git a/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp b/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
index aee8205..b051442 100644
--- a/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
+++ b/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
@@ -41,7 +41,7 @@
}
if (ioctl(sock.get(), request, &ifr) < 0) {
- LOG(ERROR) << "ioctl(" << std::hex << request << std::dec << ") failed: " << errno;
+ PLOG(ERROR) << "ioctl(" << std::hex << request << std::dec << ") failed";
return false;
}