From 36bb393d7a7fa541bcdfc0a9181d8cc0305fa55a Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 27 Oct 2021 09:47:52 +0100 Subject: [PATCH] Fix compiler warnings --- include/etl/binary.h | 6 +++--- include/etl/hash.h | 14 +++++++------- include/etl/integral_limits.h | 4 +++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/etl/binary.h b/include/etl/binary.h index e9f83696..d4850155 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -870,7 +870,7 @@ namespace etl count = ((count >> 4U) + count) & 0x0F0FU; count = ((count >> 8U) + count) & 0x00FFU; - return count; + return static_cast(count); } inline ETL_CONSTEXPR14 uint_least8_t count_bits(int16_t value) @@ -892,7 +892,7 @@ namespace etl count = ((count >> 8U) + count) & 0x00FF00FFUL; count = ((count >> 16U) + count) & 0x0000FFUL; - return uint_least8_t(count); + return static_cast(count);; } inline ETL_CONSTEXPR14 uint_least8_t count_bits(int32_t value) @@ -916,7 +916,7 @@ namespace etl count = ((count >> 16U) + count) & 0x0000FFFF0000FFFFULL; count = ((count >> 32U) + count) & 0x00000000FFFFFFFFULL; - return uint_least8_t(count); + return static_cast(count); } inline ETL_CONSTEXPR14 uint_least8_t count_bits(int64_t value) diff --git a/include/etl/hash.h b/include/etl/hash.h index 1e21b5f4..0c0385e1 100644 --- a/include/etl/hash.h +++ b/include/etl/hash.h @@ -237,7 +237,7 @@ namespace etl size_t operator ()(long v) const { // If it's the same size as a size_t. - if (sizeof(size_t) >= sizeof(v)) + if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v)) { return static_cast(v); } @@ -259,7 +259,7 @@ namespace etl size_t operator ()(long long v) const { // If it's the same size as a size_t. - if (sizeof(size_t) >= sizeof(v)) + if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v)) { return static_cast(v); } @@ -281,7 +281,7 @@ namespace etl size_t operator ()(unsigned long v) const { // If it's the same size as a size_t. - if (sizeof(size_t) >= sizeof(v)) + if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v)) { return static_cast(v); } @@ -303,7 +303,7 @@ namespace etl size_t operator ()(unsigned long long v) const { // If it's the same size as a size_t. - if (sizeof(size_t) >= sizeof(v)) + if ETL_IF_CONSTEXPR(sizeof(size_t) >= sizeof(v)) { return static_cast(v); } @@ -325,7 +325,7 @@ namespace etl size_t operator ()(float v) const { // If it's the same size as a size_t. - if (sizeof(size_t) == sizeof(v)) + if ETL_IF_CONSTEXPR(sizeof(size_t) == sizeof(v)) { union { @@ -355,7 +355,7 @@ namespace etl size_t operator ()(double v) const { // If it's the same size as a size_t. - if (sizeof(size_t) == sizeof(v)) + if ETL_IF_CONSTEXPR(sizeof(size_t) == sizeof(v)) { union { @@ -385,7 +385,7 @@ namespace etl size_t operator ()(long double v) const { // If it's the same size as a size_t. - if (sizeof(size_t) == sizeof(v)) + if ETL_IF_CONSTEXPR(sizeof(size_t) == sizeof(v)) { union { diff --git a/include/etl/integral_limits.h b/include/etl/integral_limits.h index bfd54ce3..f54b83bb 100644 --- a/include/etl/integral_limits.h +++ b/include/etl/integral_limits.h @@ -92,14 +92,16 @@ namespace etl //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** +#pragma warning( disable : 4309 ) template <> struct integral_limits { static ETL_CONSTANT char min = (etl::is_signed::value) ? SCHAR_MIN : 0; - static ETL_CONSTANT char max = (etl::is_signed::value) ? SCHAR_MAX : char(UCHAR_MAX); + static ETL_CONSTANT char max = (etl::is_signed::value) ? SCHAR_MAX : static_cast(UCHAR_MAX); static ETL_CONSTANT int bits = CHAR_BIT; static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; +#pragma warning( default : 4309 ) //*************************************************************************** ///\ingroup integral_limits