commit | 7c706baedbbb0d739c9a231be36b0430faa2fbe6 | [log] [tgz] |
---|---|---|
author | Daniel Colascione <dancol@google.com> | Wed Sep 04 13:46:50 2019 -0700 |
committer | Daniel Colascione <dancol@google.com> | Wed Sep 04 13:46:50 2019 -0700 |
tree | 2d8e09261acc23fbc4b43d7275da4973d62a5146 | |
parent | c3163e7664ccb8b80c6b1078b960f2edbe23646c [diff] |
Improve codegen slightly when doing FD validity checks See https://gcc.godbolt.org/z/hGUZIk Test: inspection Bug: 140506797 Change-Id: I6fe87b16e18c93b7fc3ca28edbbc68c245e7e5e5
diff --git a/base/include/android-base/unique_fd.h b/base/include/android-base/unique_fd.h index 6e11b4e..1605daf 100644 --- a/base/include/android-base/unique_fd.h +++ b/base/include/android-base/unique_fd.h
@@ -120,7 +120,7 @@ // Catch bogus error checks (i.e.: "!fd" instead of "fd != -1"). bool operator!() const = delete; - bool ok() const { return get() != -1; } + bool ok() const { return get() >= 0; } int release() __attribute__((warn_unused_result)) { tag(fd_, this, nullptr);