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
This commit is contained in:
parent
3168ddf79d
commit
8bd6f455d2
2 changed files with 2 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -392,7 +392,7 @@ int run_fuse_sideload(std::unique_ptr<FuseDataProvider>&& provider, const char*
|
|||
}
|
||||
|
||||
fd.ffd.reset(open("/dev/fuse", O_RDWR));
|
||||
if (!fd.ffd) {
|
||||
if (fd.ffd == -1) {
|
||||
perror("open /dev/fuse");
|
||||
result = -1;
|
||||
goto done;
|
||||
|
|
Loading…
Reference in a new issue