Skip to content

Commit 00fb4a4

Browse files
committed
Avoid or make integer precision conversion explicit
1 parent 9d62a4d commit 00fb4a4

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/int_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class BitsInt {
210210
static constexpr inline int TopBits(I val) {
211211
static_assert(Count > 0, "BitsInt::TopBits needs Count > 0");
212212
static_assert(Count <= BITS, "BitsInt::TopBits needs Offset <= BITS");
213-
return val >> (BITS - Count);
213+
return static_cast<int>(val >> (BITS - Count));
214214
}
215215

216216
static inline constexpr I CondXorWith(I val, bool cond, I v) {

src/minisketch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ size_t minisketch_merge(minisketch* sketch, const minisketch* other_sketch) {
468468
ssize_t minisketch_decode(const minisketch* sketch, size_t max_elements, uint64_t* output) {
469469
const Sketch* s = (const Sketch*)sketch;
470470
s->Check();
471-
return s->Decode(max_elements, output);
471+
return s->Decode(static_cast<int>(max_elements), output);
472472
}
473473

474474
void minisketch_set_seed(minisketch* sketch, uint64_t seed) {

src/sketch_impl.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ template<typename F>
9292
void Sqr(std::vector<typename F::Elem>& poly, const F& field) {
9393
if (poly.size() == 0) return;
9494
poly.resize(poly.size() * 2 - 1);
95-
for (int x = poly.size() - 1; x >= 0; --x) {
95+
for (size_t i = 0; i < poly.size(); ++i) {
96+
auto x = poly.size() - i - 1;
9697
poly[x] = (x & 1) ? 0 : field.Sqr(poly[x / 2]);
9798
}
9899
}
@@ -297,7 +298,7 @@ std::vector<typename F::Elem> BerlekampMassey(const std::vector<typename F::Elem
297298
auto discrepancy = syndromes[n];
298299
for (size_t i = 1; i < current.size(); ++i) discrepancy ^= table[n - i](current[i]);
299300
if (discrepancy != 0) {
300-
int x = n + 1 - (current.size() - 1) - (prev.size() - 1);
301+
int x = static_cast<int>(n + 1 - (current.size() - 1) - (prev.size() - 1));
301302
if (!b_have_inv) {
302303
b_inv = field.Inv(b);
303304
b_have_inv = true;
@@ -405,7 +406,7 @@ class SketchImpl final : public Sketch
405406
for (const auto& root : roots) {
406407
*(out++) = m_field.ToUint64(root);
407408
}
408-
return roots.size();
409+
return static_cast<int>(roots.size());
409410
}
410411

411412
size_t Merge(const Sketch* other_sketch) override

0 commit comments

Comments
 (0)