Skip to content

Commit 9715057

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

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ 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 x = poly.size() - 1; x != 0; --x) {
9696
poly[x] = (x & 1) ? 0 : field.Sqr(poly[x / 2]);
9797
}
9898
}
@@ -297,7 +297,7 @@ std::vector<typename F::Elem> BerlekampMassey(const std::vector<typename F::Elem
297297
auto discrepancy = syndromes[n];
298298
for (size_t i = 1; i < current.size(); ++i) discrepancy ^= table[n - i](current[i]);
299299
if (discrepancy != 0) {
300-
int x = n + 1 - (current.size() - 1) - (prev.size() - 1);
300+
int x = static_cast<int>(n + 1 - (current.size() - 1) - (prev.size() - 1));
301301
if (!b_have_inv) {
302302
b_inv = field.Inv(b);
303303
b_have_inv = true;
@@ -405,7 +405,7 @@ class SketchImpl final : public Sketch
405405
for (const auto& root : roots) {
406406
*(out++) = m_field.ToUint64(root);
407407
}
408-
return roots.size();
408+
return static_cast<int>(roots.size());
409409
}
410410

411411
size_t Merge(const Sketch* other_sketch) override

0 commit comments

Comments
 (0)