Skip to content

Commit

Permalink
fix logic bug in Synchronized test TryLockable
Browse files Browse the repository at this point in the history
Summary: Logical `or` with a non-zero constant is always non-zero, so its use in a boolean test is always true. Looks like this was meant to be logical `and`.

Reviewed By: dmm-fb

Differential Revision: D62498611

fbshipit-source-id: 5f6b272784e2b7df35c2ff00d4c2d62967fde023
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Sep 11, 2024
1 parent 65ea8b0 commit cc627af
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions third-party/folly/src/folly/test/SynchronizedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ class TryLockable {
bool tryLockImpl(int lockableMask) {
// if the lockable type of this instance is one of the possible options as
// expressed in the mask go through the usual test code
if (kLockableType | lockableMask) {
if (kLockableType & lockableMask) {
if (kShouldSucceed) {
onLock();
return true;
Expand All @@ -604,7 +604,7 @@ class TryLockable {
return false;
}
void unlockImpl(int lockableMask) {
if (kLockableType | lockableMask) {
if (kLockableType & lockableMask) {
onUnlock();
return;
}
Expand Down

0 comments on commit cc627af

Please sign in to comment.