mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Merge "wifi: use PLOG rather than LOG strerror."
This commit is contained in:
@@ -113,7 +113,7 @@ bool removeOldFilesInternal() {
|
||||
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 @@ bool removeOldFilesInternal() {
|
||||
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 @@ bool removeOldFilesInternal() {
|
||||
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 @@ bool cpioWriteHeader(int out_fd, struct stat& st, const char* file_name,
|
||||
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 @@ bool cpioWriteHeader(int out_fd, struct stat& st, const char* file_name,
|
||||
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 @@ size_t cpioWriteFileContent(int fd_read, int out_fd, struct stat& st) {
|
||||
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 @@ size_t cpioWriteFileContent(int fd_read, int out_fd, struct stat& st) {
|
||||
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 @@ bool cpioWriteFileTrailer(int out_fd) {
|
||||
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 cpioArchiveFilesInDir(int out_fd, const char* input_dir) {
|
||||
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 @@ size_t cpioArchiveFilesInDir(int out_fd, const char* input_dir) {
|
||||
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 @@ bool WifiChip::writeRingbufferFilesInternal() {
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user