Skip to content

Commit eb09896

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix -Wbitwise-instead-of-logical in 5 files starting w/ fbpcs/emp_games/pcf2_attribution/AttributionRule_impl.h (#9310)
Summary: X-link: facebook/hhvm#9310 X-link: facebookincubator/dynolog#89 X-link: facebookresearch/fbpcf#462 Pull Request resolved: facebookresearch#2016 With LLVM-15, `&&` and `||` are required for boolean operands, rather than `&` and `|` which can be confused for bitwise operations. Fixing such ambiguity helps makes our code more readable. - If you approve of this diff, please use the "Accept & Ship" button :-) Differential Revision: D42347735 fbshipit-source-id: 6e377b3c27cc1fe341e3dfd7d1b4a0adbf236889
1 parent 2fb6a8e commit eb09896

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

fbpcs/emp_games/pcf2_attribution/AttributionRule_impl.h

+14-14
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ class LastClickRule
4141
ConditionalVector<uint32_t, usingBatch> thresholdNDaysClick;
4242
if constexpr (usingBatch) {
4343
for (size_t i = 0; i < tp.ts.size(); ++i) {
44-
bool isValidClick = tp.isClick.at(i) & (tp.ts.at(i) > 0);
44+
bool isValidClick = tp.isClick.at(i) && (tp.ts.at(i) > 0);
4545
uint32_t thresholdNDays = tp.ts.at(i) + threshold_.count();
4646
thresholdNDaysClick.push_back(isValidClick ? thresholdNDays : 0);
4747
}
4848
} else {
49-
bool isValidClick = tp.isClick & (tp.ts > 0);
49+
bool isValidClick = tp.isClick && (tp.ts > 0);
5050
uint32_t thresholdNDays = tp.ts + threshold_.count();
5151
thresholdNDaysClick = isValidClick ? thresholdNDays : 0;
5252
}
@@ -106,9 +106,9 @@ class LastTouch_ClickNDays_ImpressionMDays
106106
const PrivateConversion<schedulerId, usingBatch, inputEncryption>& conv,
107107
const std::vector<SecTimestamp<schedulerId, usingBatch>>& thresholds)
108108
const override {
109-
auto validConv = tp.ts < conv.ts;
110-
auto touchWithinMDays = conv.ts <= thresholds.at(0);
111-
auto clickWithinNDays = conv.ts <= thresholds.at(1);
109+
const auto validConv = tp.ts < conv.ts;
110+
const auto touchWithinMDays = conv.ts <= thresholds.at(0);
111+
const auto clickWithinNDays = conv.ts <= thresholds.at(1);
112112

113113
return validConv & (touchWithinMDays | clickWithinNDays);
114114
}
@@ -120,7 +120,7 @@ class LastTouch_ClickNDays_ImpressionMDays
120120
if constexpr (usingBatch) {
121121
for (size_t i = 0; i < tp.ts.size(); ++i) {
122122
bool isValid = tp.ts.at(i) > 0;
123-
bool isValidClick = tp.isClick.at(i) & isValid;
123+
bool isValidClick = tp.isClick.at(i) && isValid;
124124

125125
auto thresholdMDays = tp.ts.at(i) + impressionThreshold_.count();
126126
thresholdMDaysTouch.push_back(isValid ? thresholdMDays : 0);
@@ -130,7 +130,7 @@ class LastTouch_ClickNDays_ImpressionMDays
130130
}
131131
} else {
132132
bool isValid = tp.ts > 0;
133-
bool isValidClick = tp.isClick & isValid;
133+
bool isValidClick = tp.isClick && isValid;
134134

135135
auto thresholdMDays = tp.ts + impressionThreshold_.count();
136136
thresholdMDaysTouch = isValid ? thresholdMDays : 0;
@@ -221,7 +221,7 @@ class LastClick_2_7Days
221221

222222
if constexpr (usingBatch) {
223223
for (size_t i = 0; i < tp.ts.size(); ++i) {
224-
bool isValidClick = tp.isClick.at(i) & (tp.ts.at(i) > 0);
224+
bool isValidClick = tp.isClick.at(i) && (tp.ts.at(i) > 0);
225225
uint32_t lowerBoundOneDay = tp.ts.at(i) + kSecondsInOneDay;
226226
uint32_t upperBoundSevenDays = tp.ts.at(i) + kSecondsInSevenDays;
227227

@@ -230,7 +230,7 @@ class LastClick_2_7Days
230230
isValidClick ? upperBoundSevenDays : 0);
231231
}
232232
} else {
233-
bool isValidClick = tp.isClick & (tp.ts > 0);
233+
bool isValidClick = tp.isClick && (tp.ts > 0);
234234
uint32_t lowerBoundOneDay = tp.ts + kSecondsInOneDay;
235235
uint32_t upperBoundSevenDays = tp.ts + kSecondsInSevenDays;
236236

@@ -322,7 +322,7 @@ class LastTouch_2_7Days
322322
if constexpr (usingBatch) {
323323
for (size_t i = 0; i < tp.ts.size(); ++i) {
324324
bool isValid = tp.ts.at(i) > 0;
325-
bool isValidClick = tp.isClick.at(i) & isValid;
325+
bool isValidClick = tp.isClick.at(i) && isValid;
326326
uint32_t lowerBoundAndUpperBoundOneDay = tp.ts.at(i) + kSecondsInOneDay;
327327
uint32_t upperBoundSevenDays = tp.ts.at(i) + kSecondsInSevenDays;
328328

@@ -335,14 +335,14 @@ class LastTouch_2_7Days
335335
}
336336
} else {
337337
bool isValid = tp.ts > 0;
338-
bool isValidClick = tp.isClick & isValid;
338+
bool isValidClick = tp.isClick && isValid;
339339
uint32_t lowerBoundAndUpperBoundOneDay = tp.ts + kSecondsInOneDay;
340340
uint32_t upperBoundSevenDays = tp.ts + kSecondsInSevenDays;
341341

342342
lowerBoundOneDayClick = isValidClick ? lowerBoundAndUpperBoundOneDay : 0;
343343
upperBoundSevenDaysClick = isValidClick ? upperBoundSevenDays : 0;
344344
upperBoundOneDayTouch =
345-
(isValid & !isValidClick) ? lowerBoundAndUpperBoundOneDay : 0;
345+
(isValid && !isValidClick) ? lowerBoundAndUpperBoundOneDay : 0;
346346
}
347347

348348
return std::vector<SecTimestamp<schedulerId, usingBatch>>{
@@ -421,12 +421,12 @@ class LastClick_1Day_TargetId
421421
ConditionalVector<uint32_t, usingBatch> thresholdOneDayClick;
422422
if constexpr (usingBatch) {
423423
for (size_t i = 0; i < tp.ts.size(); ++i) {
424-
bool isValidClick = tp.isClick.at(i) & (tp.ts.at(i) > 0);
424+
bool isValidClick = tp.isClick.at(i) && (tp.ts.at(i) > 0);
425425
uint32_t thresholdOneDay = tp.ts.at(i) + kSecondsInOneDay;
426426
thresholdOneDayClick.push_back(isValidClick ? thresholdOneDay : 0);
427427
}
428428
} else {
429-
bool isValidClick = tp.isClick & (tp.ts > 0);
429+
bool isValidClick = tp.isClick && (tp.ts > 0);
430430
uint32_t thresholdOneDay = tp.ts + kSecondsInOneDay;
431431
thresholdOneDayClick = isValidClick ? thresholdOneDay : 0;
432432
}

0 commit comments

Comments
 (0)