diff options
author | Bernie Innocenti <codewiz@google.com> | 2019-03-28 20:48:02 +0900 |
---|---|---|
committer | Bernie Innocenti <codewiz@google.com> | 2019-03-28 20:48:02 +0900 |
commit | 94c35d65cef74d6b330410be49dff1f18928f0cc (patch) | |
tree | 57d74137d2d1a12a6560043add8d3be3dfa0fca7 /verity | |
parent | 632a01f74563551d5f2437fde39fa0475166350d (diff) | |
download | extras-94c35d65cef74d6b330410be49dff1f18928f0cc.tar.gz |
Fix incorrect error checking on unique_fd
The expression "!fd" calls the implicit conversion to int, but comparing
the raw fd against 0 won't work, since open() and other POSIX calls
returning file descriptors use -1 to signal an error.
Test: m verity_verifier
Change-Id: Ib117de62ff46c8d3389db54875bfa269fd539b51
Diffstat (limited to 'verity')
-rw-r--r-- | verity/verity_verifier.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/verity/verity_verifier.cpp b/verity/verity_verifier.cpp index 036e85be..e770708f 100644 --- a/verity/verity_verifier.cpp +++ b/verity/verity_verifier.cpp @@ -80,7 +80,7 @@ int main(int argc, char* argv[]) { // Get the raw image. android::base::unique_fd fd(open(argv[1], O_RDONLY)); - if (!fd) { + if (fd == -1) { fprintf(stderr, "failed to open %s: %s\n", argv[1], strerror(errno)); return 1; } |