Skip to content

Commit

Permalink
Fix -Wbitwise-instead-of-logical in 5 files starting w/ fbpcs/emp_gam…
Browse files Browse the repository at this point in the history
…es/pcf2_attribution/AttributionRule_impl.h

Summary:
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 :-)

Reviewed By: meyering

Differential Revision: D42347735

fbshipit-source-id: 23b5dc52fb4e2014a6f89d90c710b194c21971ec
  • Loading branch information
r-barnes authored and facebook-github-bot committed Jan 5, 2023
1 parent 6e7cbc8 commit f89d7f8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions hphp/runtime/base/runtime-option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1417,11 +1417,11 @@ static std::vector<std::string> getTierOverwrites(IniSetting::Map& ini,
// evaluated; otherwise with multiple patterns, if an earlier
// one fails to match, the later one is reported as unused.
return
Config::matchHdfPattern(hostname, ini, hdf, "machine") &
Config::matchHdfPattern(tier, ini, hdf, "tier") &
Config::matchHdfPattern(task, ini, hdf, "task") &
Config::matchHdfPattern(tiers, ini, hdf, "tiers", "m") &
Config::matchHdfPattern(tags, ini, hdf, "tags", "m") &
Config::matchHdfPattern(hostname, ini, hdf, "machine") &&
Config::matchHdfPattern(tier, ini, hdf, "tier") &&
Config::matchHdfPattern(task, ini, hdf, "task") &&
Config::matchHdfPattern(tiers, ini, hdf, "tiers", "m") &&
Config::matchHdfPattern(tags, ini, hdf, "tags", "m") &&
Config::matchHdfPattern(cpu, ini, hdf, "cpu");
};

Expand All @@ -1442,8 +1442,8 @@ static std::vector<std::string> getTierOverwrites(IniSetting::Map& ini,
// Check the patterns using "&" rather than "&&" so they all get
// evaluated; otherwise with multiple patterns, if an earlier
// one fails to match, the later one is reported as unused.
if (checkPatterns(hdf) &
(!hdf.exists("exclude") || !checkPatterns(hdf["exclude"])) &
if (checkPatterns(hdf) &&
(!hdf.exists("exclude") || !checkPatterns(hdf["exclude"])) &&
matchShard(enableShards, hostname, ini, hdf, messages)) {
messages.emplace_back(folly::sformat(
"Matched tier: {}", hdf.getName()));
Expand Down
10 changes: 5 additions & 5 deletions hphp/runtime/ext/hsl/hsl_locale_libc_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,23 @@ int64_t HSLLocaleLibcOps::strcasecmp(const String& a, const String& b) const {
}

bool HSLLocaleLibcOps::starts_with(const String& str, const String& prefix) const {
assertx(!str.isNull() & !prefix.isNull());
assertx(!str.isNull() && !prefix.isNull());
if (str.size() < prefix.size()) {
return false;
}
return string_ncmp(str.data(), prefix.data(), prefix.size()) == 0;
}

bool HSLLocaleLibcOps::starts_with_ci(const String& str, const String& prefix) const {
assertx(!str.isNull() & !prefix.isNull());
assertx(!str.isNull() && !prefix.isNull());
if (str.size() < prefix.size()) {
return false;
}
return bstrcaseeq(str.data(), prefix.data(), prefix.size());
}

bool HSLLocaleLibcOps::ends_with(const String& str, const String& suffix) const {
assertx(!str.isNull() & !suffix.isNull());
assertx(!str.isNull() && !suffix.isNull());
if (str.size() < suffix.size()) {
return false;
}
Expand All @@ -145,7 +145,7 @@ bool HSLLocaleLibcOps::ends_with(const String& str, const String& suffix) const
}

bool HSLLocaleLibcOps::ends_with_ci(const String& str, const String& suffix) const {
assertx(!str.isNull() & !suffix.isNull());
assertx(!str.isNull() && !suffix.isNull());
if (str.size() < suffix.size()) {
return false;
}
Expand Down Expand Up @@ -331,7 +331,7 @@ String HSLLocaleLibcOps::replace_every_nonrecursive_ci(const String& haystack,
haystack,
replacements,
/* to_t = */ id,
/* from_t = */ id,
/* from_t = */ id,
/* normalize = */ [](String* s) {},
[](String* s) {
*s = HHVM_FN(strtolower)(*s);
Expand Down
2 changes: 1 addition & 1 deletion hphp/util/bloom-filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ template<size_t NBITS> struct BloomFilter {
}
bool test(T x) const {
auto h = hash_int64(intptr_t(x));
return bits_.test(h1(h)) & bits_.test(h2(h));
return bits_.test(h1(h)) && bits_.test(h2(h));
}
void clear() {
bits_.reset();
Expand Down

0 comments on commit f89d7f8

Please sign in to comment.