Rewrite 'keylength < MIN_KEYLENGTH' to avoid -Wtautological-compare

The warning surfaces under earlier Clnag's and GCC's
pull/301/head
Jeffrey Walton 2016-09-21 12:47:26 -04:00
parent caf8aef8fe
commit 08a206f3eb
1 changed files with 2 additions and 1 deletions

View File

@ -215,7 +215,8 @@ public:
// TODO: Figure out how to make this CRYPTOPP_CONSTEXPR // TODO: Figure out how to make this CRYPTOPP_CONSTEXPR
static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength) static size_t CRYPTOPP_API StaticGetValidKeyLength(size_t keylength)
{ {
if (keylength < (size_t)MIN_KEYLENGTH) // Rewrite 'keylength < MIN_KEYLENGTH' to avoid -Wtautological-compare
if ((int)keylength - MIN_KEYLENGTH < 0)
return MIN_KEYLENGTH; return MIN_KEYLENGTH;
else if (keylength > (size_t)MAX_KEYLENGTH) else if (keylength > (size_t)MAX_KEYLENGTH)
return (size_t)MAX_KEYLENGTH; return (size_t)MAX_KEYLENGTH;