From 606a5825d910249094d8d9c78f83d1cabaf5dfb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Gonz=C3=A1lez=20Palomo?= Date: Thu, 19 Jan 2023 15:48:49 +0100 Subject: [PATCH] Make sign conversion explicit. Fix #287. Implicit sign conversions cause warnings when using -Wsign-conversion but that is easy to avoid by making the conversions explicit. --- c/blake3_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c/blake3_impl.h b/c/blake3_impl.h index 46c8fd8..3ba9ceb 100644 --- a/c/blake3_impl.h +++ b/c/blake3_impl.h @@ -87,7 +87,7 @@ static const uint8_t MSG_SCHEDULE[7][16] = { /* x is assumed to be nonzero. */ static unsigned int highest_one(uint64_t x) { #if defined(__GNUC__) || defined(__clang__) - return 63 ^ __builtin_clzll(x); + return 63 ^ (unsigned int)__builtin_clzll(x); #elif defined(_MSC_VER) && defined(IS_X86_64) unsigned long index; _BitScanReverse64(&index, x); @@ -117,7 +117,7 @@ static unsigned int highest_one(uint64_t x) { // Count the number of 1 bits. INLINE unsigned int popcnt(uint64_t x) { #if defined(__GNUC__) || defined(__clang__) - return __builtin_popcountll(x); + return (unsigned int)__builtin_popcountll(x); #else unsigned int count = 0; while (x != 0) {