diff --git a/src/fields/clmul_common_impl.h b/src/fields/clmul_common_impl.h index 3d179a1..8a5e93a 100644 --- a/src/fields/clmul_common_impl.h +++ b/src/fields/clmul_common_impl.h @@ -33,7 +33,7 @@ template NO_SANITIZE_MEMORY I MulWithClMulReduce(I static constexpr I MASK = Mask(); const __m128i MOD128 = _mm_cvtsi64_si128(MOD); - __m128i product = _mm_clmulepi64_si128(_mm_cvtsi64_si128((uint64_t)a), _mm_cvtsi64_si128((uint64_t)b), 0x00); + __m128i product = _mm_clmulepi64_si128(_mm_cvtsi64_si128(uint64_t{a}), _mm_cvtsi64_si128(uint64_t{b}), 0x00); if (BITS <= 32) { __m128i high1 = _mm_srli_epi64(product, BITS); __m128i red1 = _mm_clmulepi64_si128(high1, MOD128, 0x00); @@ -53,7 +53,7 @@ template NO_SANITIZE_MEMORY I MulWithClMulReduce(I } else { __m128i high1 = _mm_or_si128(_mm_srli_epi64(product, BITS), _mm_srli_si128(_mm_slli_epi64(product, 64 - BITS), 8)); __m128i red1 = _mm_clmulepi64_si128(high1, MOD128, 0x00); - if ((uint64_t(MOD) >> (66 - BITS)) == 0) { + if ((uint64_t{MOD} >> (66 - BITS)) == 0) { __m128i high2 = _mm_srli_epi64(red1, BITS); __m128i red2 = _mm_clmulepi64_si128(high2, MOD128, 0x00); return _mm_cvtsi128_si64(_mm_xor_si128(_mm_xor_si128(product, red1), red2)) & MASK; @@ -69,7 +69,7 @@ template NO_SANITIZE_MEMORY I MulTrinomial(I a, I { static constexpr I MASK = Mask(); - __m128i product = _mm_clmulepi64_si128(_mm_cvtsi64_si128((uint64_t)a), _mm_cvtsi64_si128((uint64_t)b), 0x00); + __m128i product = _mm_clmulepi64_si128(_mm_cvtsi64_si128(uint64_t{a}), _mm_cvtsi64_si128(uint64_t{b}), 0x00); if (BITS <= 32) { __m128i high1 = _mm_srli_epi64(product, BITS); __m128i red1 = _mm_xor_si128(high1, _mm_slli_epi64(high1, POS)); @@ -92,7 +92,7 @@ template NO_SANITIZE_MEMORY I MulTrinomial(I a, I return _mm_cvtsi128_si64(_mm_xor_si128(_mm_xor_si128(product, red1), red2)) & MASK; } } else { - const __m128i MOD128 = _mm_cvtsi64_si128(1 + (((uint64_t)1) << POS)); + const __m128i MOD128 = _mm_cvtsi64_si128(1 + ((uint64_t{1}) << POS)); __m128i red1 = _mm_clmulepi64_si128(high1, MOD128, 0x00); __m128i high2 = _mm_or_si128(_mm_srli_epi64(red1, BITS), _mm_srli_si128(_mm_slli_epi64(red1, 64 - BITS), 8)); __m128i red2 = _mm_xor_si128(high2, _mm_slli_epi64(high2, POS)); @@ -143,7 +143,7 @@ template(SAVE->template Map(val)); } constexpr Elem FromUint64(uint64_t x) const { return LOAD->template Map(O::Mask(I(x))); } - constexpr uint64_t ToUint64(Elem val) const { return uint64_t(SAVE->template Map(val)); } + constexpr uint64_t ToUint64(Elem val) const { return uint64_t{SAVE->template Map(val)}; } }; template diff --git a/src/fields/generic_common_impl.h b/src/fields/generic_common_impl.h index 1d1d030..4c709cc 100644 --- a/src/fields/generic_common_impl.h +++ b/src/fields/generic_common_impl.h @@ -49,7 +49,7 @@ template 1 + max_count) return -1; + if (int(poly.size()) > 1 + max_count) return -1; std::reverse(poly.begin(), poly.end()); auto roots = FindRoots(poly, m_basis, m_field); if (roots.size() == 0) return -1; @@ -422,7 +422,7 @@ class SketchImpl final : public Sketch void SetSeed(uint64_t seed) override { - if (seed == (uint64_t)-1) { + if (seed == std::numeric_limits::max()) { m_basis = 1; } else { m_basis = m_field.FromSeed(seed); diff --git a/src/test.cpp b/src/test.cpp index 417937e..42c3344 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -34,7 +34,7 @@ std::vector CreateSketches(uint32_t bits, size_t capacity) { if (Minisketch::ImplementationSupported(bits, impl)) { CHECK(Minisketch::BitsSupported(bits)); ret.push_back(Minisketch(bits, impl, capacity)); - CHECK((bool)ret.back()); + CHECK(bool{ret.back()}); } else { // implementation 0 must always work unless field size is disabled CHECK(impl != 0 || !Minisketch::BitsSupported(bits)); @@ -274,7 +274,7 @@ int main(int argc, char** argv) { try { test_complexity = 0; long long complexity = std::stoll(arg, &len); - if (complexity >= 1 && len == arg.size() && ((uint64_t)complexity <= std::numeric_limits::max() >> 10)) { + if (complexity >= 1 && len == arg.size() && (uint64_t(complexity) <= std::numeric_limits::max() >> 10)) { test_complexity = complexity; } } catch (const std::logic_error&) {} @@ -289,7 +289,7 @@ int main(int argc, char** argv) { #else const char* mode = ""; #endif - printf("Running libminisketch tests%s with complexity=%llu\n", mode, (unsigned long long)test_complexity); + printf("Running libminisketch tests%s with complexity=%llu\n", mode, (unsigned long long){test_complexity}); TestComputeFunctions();