Lint: Initialize variables, log variables on error
Test: th
Change-Id: I47127424de63f708f099b9884f4823366d15a838
diff --git a/payload_consumer/file_descriptor.cc b/payload_consumer/file_descriptor.cc
index da76327..ff27b73 100644
--- a/payload_consumer/file_descriptor.cc
+++ b/payload_consumer/file_descriptor.cc
@@ -77,7 +77,7 @@
uint64_t EintrSafeFileDescriptor::BlockDevSize() {
if (fd_ < 0)
return 0;
- struct stat stbuf;
+ struct stat stbuf {};
if (fstat(fd_, &stbuf) < 0) {
PLOG(ERROR) << "Error stat-ing fd " << fd_;
return 0;
@@ -102,7 +102,7 @@
// On some devices, the BLKDISCARD will actually read back as zeros, instead
// of "undefined" data. The BLKDISCARDZEROES ioctl tells whether that's the
// case, so we issue a BLKDISCARD in those cases to speed up the writes.
- unsigned int arg;
+ unsigned int arg{};
if (request == BLKZEROOUT && ioctl(fd_, BLKDISCARDZEROES, &arg) == 0 && arg)
request = BLKDISCARD;
diff --git a/payload_consumer/verified_source_fd.cc b/payload_consumer/verified_source_fd.cc
index 09ac95b..3f17ad7 100644
--- a/payload_consumer/verified_source_fd.cc
+++ b/payload_consumer/verified_source_fd.cc
@@ -159,7 +159,9 @@
source_fd_ = std::make_shared<EintrSafeFileDescriptor>();
if (source_fd_ == nullptr)
return false;
- TEST_AND_RETURN_FALSE_ERRNO(source_fd_->Open(source_path_.c_str(), O_RDONLY));
+ if (!source_fd_->Open(source_path_.c_str(), O_RDONLY)) {
+ PLOG(ERROR) << "Failed to open " << source_path_;
+ }
return true;
}