Skip to content

Commit

Permalink
Fix '-Wbitwise-instead-of-logical' in fbpcf/engine/SecretShareEngine.cpp
Browse files Browse the repository at this point in the history
Summary:
LLVM-15 requires that we differentiate between `&&` and `&` as well as `||` and `|`. Logical operations are done with `&&` and `||` and bitwise operations are done with `&` and `|`. Confusing the two makes code harder to read and may lead to subtle bugs.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Reviewed By: dmm-fb

Differential Revision: D42374505

fbshipit-source-id: c6d8bf44bf99f4c0309e49546365ffc35b1e2610
  • Loading branch information
r-barnes authored and facebook-github-bot committed Jan 7, 2023
1 parent 7c0d5eb commit 159e7ce
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions fbpcf/engine/SecretShareEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,13 +749,13 @@ SecretShareEngine::computeExecutionResultsFromOpenedShares(

for (size_t i = 0; i < ands.size(); i++) {
bool val = normalTuples.at(normalTupleIndex).getC() ^
(openedSecrets.at(2 * normalTupleIndex) &
(openedSecrets.at(2 * normalTupleIndex) &&
normalTuples.at(normalTupleIndex).getB()) ^
(openedSecrets.at(2 * normalTupleIndex + 1) &
(openedSecrets.at(2 * normalTupleIndex + 1) &&
normalTuples.at(normalTupleIndex).getA());
if (myId_ == 0) {
val = val ^
(openedSecrets.at(2 * normalTupleIndex) &
(openedSecrets.at(2 * normalTupleIndex) &&
openedSecrets.at(2 * normalTupleIndex + 1));
}
andResults.push_back(val);
Expand All @@ -768,13 +768,13 @@ SecretShareEngine::computeExecutionResultsFromOpenedShares(
std::vector<bool> rst(batchSize);
for (int j = 0; j < batchSize; j++) {
bool val = normalTuples.at(normalTupleIndex).getC() ^
(openedSecrets.at(2 * normalTupleIndex) &
(openedSecrets.at(2 * normalTupleIndex) &&
normalTuples.at(normalTupleIndex).getB()) ^
(openedSecrets.at(2 * normalTupleIndex + 1) &
(openedSecrets.at(2 * normalTupleIndex + 1) &&
normalTuples.at(normalTupleIndex).getA());
if (myId_ == 0) {
val = val ^
(openedSecrets.at(2 * normalTupleIndex) &
(openedSecrets.at(2 * normalTupleIndex) &&
openedSecrets.at(2 * normalTupleIndex + 1));
}
rst[j] = val;
Expand Down Expand Up @@ -829,7 +829,7 @@ SecretShareEngine::computeExecutionResultsFromOpenedShares(
(openedSecrets.at(secretIndex) && tuple.getA());
if (myId_ == 0) {
val = val ^
(openedSecrets.at(leftSecretIndex) &
(openedSecrets.at(leftSecretIndex) &&
openedSecrets.at(secretIndex));
}
compositeResult[k][j] = val;
Expand Down

0 comments on commit 159e7ce

Please sign in to comment.