aboutsummaryrefslogtreecommitdiffstats
path: root/applypatch/applypatch.cpp
diff options
context:
space:
mode:
authorBernie Innocenti <codewiz@google.com>2019-03-28 15:48:08 +0900
committerBernie Innocenti <codewiz@google.com>2019-03-28 17:28:13 +0900
commit8bd6f455d261fa62a20321a426723c491903a82e (patch)
tree0864259080dd9934b15435fe4b3500b45485f895 /applypatch/applypatch.cpp
parent3168ddf79dee2b7256eb43b404dad5c3a0d71af2 (diff)
downloadandroid_bootable_recovery-8bd6f455d261fa62a20321a426723c491903a82e.tar.gz
android_bootable_recovery-8bd6f455d261fa62a20321a426723c491903a82e.tar.bz2
android_bootable_recovery-8bd6f455d261fa62a20321a426723c491903a82e.zip
Fix bogus error checking on unique_fd
The expression "!fd" calls the implicit conversion to int, but comparing the raw fd against 0 does not work, since open() and other POSIX calls returning a file descriptor use -1 to signal an error. Test: m recovery Change-Id: I0847c276f39cb9dd09c7ffb96951276113418fc8
Diffstat (limited to 'applypatch/applypatch.cpp')
-rw-r--r--applypatch/applypatch.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp
index f9383dde..90d8e860 100644
--- a/applypatch/applypatch.cpp
+++ b/applypatch/applypatch.cpp
@@ -76,7 +76,7 @@ static bool ReadPartitionToBuffer(const Partition& partition, FileContents* out,
}
android::base::unique_fd dev(open(partition.name.c_str(), O_RDONLY));
- if (!dev) {
+ if (dev == -1) {
PLOG(ERROR) << "Failed to open eMMC partition \"" << partition << "\"";
} else {
std::vector<unsigned char> buffer(partition.size);