Skip to content

Commit

Permalink
Fix CodeQL C++ issues (#2178)
Browse files Browse the repository at this point in the history
Summary:
CodeQL found some issues via static analysis. See microsoft/react-native-windows#12703

Pull Request resolved: #2178

Reviewed By: ilvokhin

Differential Revision: D56591460

Pulled By: Orvid

fbshipit-source-id: a0af3171a4076ff1131baf6ee53a40ade55667d3
  • Loading branch information
marlenecota authored and facebook-github-bot committed May 16, 2024
1 parent eb58eb3 commit a182aa6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions folly/ConstexprMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ constexpr auto& constexpr_iterated_squares_desc_2_v =
template <typename T, typename... Ts>
constexpr T constexpr_max(T a, Ts... ts) {
T list[] = {ts..., a}; // 0-length arrays are illegal
for (auto i = 0u; i < sizeof...(Ts); ++i) {
for (size_t i = 0; i < sizeof...(Ts); ++i) {
a = list[i] < a ? a : list[i];
}
return a;
Expand All @@ -260,7 +260,7 @@ constexpr T constexpr_max(T a, Ts... ts) {
template <typename T, typename... Ts>
constexpr T constexpr_min(T a, Ts... ts) {
T list[] = {ts..., a}; // 0-length arrays are illegal
for (auto i = 0u; i < sizeof...(Ts); ++i) {
for (size_t i = 0; i < sizeof...(Ts); ++i) {
a = list[i] < a ? list[i] : a;
}
return a;
Expand Down
2 changes: 1 addition & 1 deletion folly/json/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ struct Input {
}

void skipWhitespace() {
unsigned index = 0;
std::size_t index = 0;
while (true) {
while (index < range_.size() && range_[index] == ' ') {
index++;
Expand Down
12 changes: 6 additions & 6 deletions folly/lang/ToAscii.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ using to_ascii_alphabet_upper = to_ascii_alphabet<true>;

namespace detail {

template <uint64_t Base, typename Alphabet>
template <size_t Base, typename Alphabet>
struct to_ascii_array {
using data_type_ = c_array<uint8_t, Base>;
static constexpr data_type_ data_() {
Expand All @@ -70,7 +70,7 @@ struct to_ascii_array {
return data.data[index];
}
};
template <uint64_t Base, typename Alphabet>
template <size_t Base, typename Alphabet>
alignas(kIsMobile ? sizeof(size_t) : hardware_constructive_interference_size)
typename to_ascii_array<Base, Alphabet>::data_type_ const
to_ascii_array<Base, Alphabet>::data =
Expand All @@ -89,7 +89,7 @@ extern template to_ascii_array<10, to_ascii_alphabet_upper>::data_type_ const
extern template to_ascii_array<16, to_ascii_alphabet_upper>::data_type_ const
to_ascii_array<16, to_ascii_alphabet_upper>::data;

template <uint64_t Base, typename Alphabet>
template <size_t Base, typename Alphabet>
struct to_ascii_table {
using data_type_ = c_array<uint16_t, Base * Base>;
static constexpr data_type_ data_() {
Expand All @@ -105,7 +105,7 @@ struct to_ascii_table {
// @lint-ignore CLANGTIDY
static data_type_ const data;
};
template <uint64_t Base, typename Alphabet>
template <size_t Base, typename Alphabet>
alignas(hardware_constructive_interference_size)
typename to_ascii_table<Base, Alphabet>::data_type_ const
to_ascii_table<Base, Alphabet>::data =
Expand All @@ -124,7 +124,7 @@ extern template to_ascii_table<10, to_ascii_alphabet_upper>::data_type_ const
extern template to_ascii_table<16, to_ascii_alphabet_upper>::data_type_ const
to_ascii_table<16, to_ascii_alphabet_upper>::data;

template <uint64_t Base, typename Int>
template <size_t Base, typename Int>
struct to_ascii_powers {
static constexpr size_t size_(Int v) {
return 1 + (v < Base ? 0 : size_(v / Base));
Expand All @@ -141,7 +141,7 @@ struct to_ascii_powers {
// @lint-ignore CLANGTIDY
static data_type_ const data;
};
template <uint64_t Base, typename Int>
template <size_t Base, typename Int>
alignas(hardware_constructive_interference_size)
typename to_ascii_powers<Base, Int>::data_type_ const
to_ascii_powers<Base, Int>::data = to_ascii_powers<Base, Int>::data_();
Expand Down

0 comments on commit a182aa6

Please sign in to comment.