wifi: use PLOG rather than LOG strerror.
Test: builds
Change-Id: I1a508dbb47fed3a1c1e5166b9b32d33ed0d246fe
diff --git a/wifi/1.2/default/wifi_chip.cpp b/wifi/1.2/default/wifi_chip.cpp
index 3bd0557..8c2d3cb 100644
--- a/wifi/1.2/default/wifi_chip.cpp
+++ b/wifi/1.2/default/wifi_chip.cpp
@@ -113,7 +113,7 @@
const time_t delete_files_before = now - kMaxRingBufferFileAgeSeconds;
DIR* dir_dump = opendir(kTombstoneFolderPath);
if (!dir_dump) {
- LOG(ERROR) << "Failed to open directory: " << strerror(errno);
+ PLOG(ERROR) << "Failed to open directory";
return false;
}
unique_fd dir_auto_closer(dirfd(dir_dump));
@@ -128,8 +128,7 @@
struct stat cur_file_stat;
std::string cur_file_path = kTombstoneFolderPath + cur_file_name;
if (stat(cur_file_path.c_str(), &cur_file_stat) == -1) {
- LOG(ERROR) << "Failed to get file stat for " << cur_file_path
- << ": " << strerror(errno);
+ PLOG(ERROR) << "Failed to get file stat for " << cur_file_path;
success = false;
continue;
}
@@ -144,7 +143,7 @@
if (cur_file_count > kMaxRingBufferFileNum ||
cur_file.first < delete_files_before) {
if (unlink(cur_file.second.c_str()) != 0) {
- LOG(ERROR) << "Error deleting file " << strerror(errno);
+ PLOG(ERROR) << "Error deleting file";
success = false;
}
cur_file_count--;
@@ -168,13 +167,11 @@
major(st.st_dev), minor(st.st_dev), major(st.st_rdev),
minor(st.st_rdev), static_cast<uint32_t>(file_name_len), 0);
if (write(out_fd, read_buf.data(), llen) == -1) {
- LOG(ERROR) << "Error writing cpio header to file " << file_name << " "
- << strerror(errno);
+ PLOG(ERROR) << "Error writing cpio header to file " << file_name;
return false;
}
if (write(out_fd, file_name, file_name_len) == -1) {
- LOG(ERROR) << "Error writing filename to file " << file_name << " "
- << strerror(errno);
+ PLOG(ERROR) << "Error writing filename to file " << file_name;
return false;
}
@@ -183,8 +180,7 @@
if (llen != 0) {
const uint32_t zero = 0;
if (write(out_fd, &zero, 4 - llen) == -1) {
- LOG(ERROR) << "Error padding 0s to file " << file_name << " "
- << strerror(errno);
+ PLOG(ERROR) << "Error padding 0s to file " << file_name;
return false;
}
}
@@ -200,17 +196,17 @@
while (llen > 0) {
ssize_t bytes_read = read(fd_read, read_buf.data(), read_buf.size());
if (bytes_read == -1) {
- LOG(ERROR) << "Error reading file " << strerror(errno);
+ PLOG(ERROR) << "Error reading file";
return ++n_error;
}
llen -= bytes_read;
if (write(out_fd, read_buf.data(), bytes_read) == -1) {
- LOG(ERROR) << "Error writing data to file " << strerror(errno);
+ PLOG(ERROR) << "Error writing data to file";
return ++n_error;
}
if (bytes_read == 0) { // this should never happen, but just in case
// to unstuck from while loop
- LOG(ERROR) << "Unexpected read result for " << strerror(errno);
+ PLOG(ERROR) << "Unexpected read result";
n_error++;
break;
}
@@ -219,7 +215,7 @@
if (llen != 0) {
const uint32_t zero = 0;
if (write(out_fd, &zero, 4 - llen) == -1) {
- LOG(ERROR) << "Error padding 0s to file " << strerror(errno);
+ PLOG(ERROR) << "Error padding 0s to file";
return ++n_error;
}
}
@@ -234,7 +230,7 @@
sprintf(read_buf.data(), "070701%040X%056X%08XTRAILER!!!", 1,
0x0b, 0) +
4) == -1) {
- LOG(ERROR) << "Error writing trailing bytes " << strerror(errno);
+ PLOG(ERROR) << "Error writing trailing bytes";
return false;
}
return true;
@@ -248,7 +244,7 @@
size_t n_error = 0;
DIR* dir_dump = opendir(input_dir);
if (!dir_dump) {
- LOG(ERROR) << "Failed to open directory: " << strerror(errno);
+ PLOG(ERROR) << "Failed to open directory";
return ++n_error;
}
unique_fd dir_auto_closer(dirfd(dir_dump));
@@ -263,15 +259,13 @@
struct stat st;
const std::string cur_file_path = kTombstoneFolderPath + cur_file_name;
if (stat(cur_file_path.c_str(), &st) == -1) {
- LOG(ERROR) << "Failed to get file stat for " << cur_file_path
- << ": " << strerror(errno);
+ PLOG(ERROR) << "Failed to get file stat for " << cur_file_path;
n_error++;
continue;
}
const int fd_read = open(cur_file_path.c_str(), O_RDONLY);
if (fd_read == -1) {
- LOG(ERROR) << "Failed to open file " << cur_file_path << " "
- << strerror(errno);
+ PLOG(ERROR) << "Failed to open file " << cur_file_path;
n_error++;
continue;
}
@@ -1400,14 +1394,14 @@
kTombstoneFolderPath + item.first + "XXXXXXXXXX";
const int dump_fd = mkstemp(makeCharVec(file_path_raw).data());
if (dump_fd == -1) {
- LOG(ERROR) << "create file failed: " << strerror(errno);
+ PLOG(ERROR) << "create file failed";
return false;
}
unique_fd file_auto_closer(dump_fd);
for (const auto& cur_block : cur_buffer.getData()) {
if (write(dump_fd, cur_block.data(),
sizeof(cur_block[0]) * cur_block.size()) == -1) {
- LOG(ERROR) << "Error writing to file " << strerror(errno);
+ PLOG(ERROR) << "Error writing to file";
}
}
}