From 08a206f3eb2713a17eda636ebb96ed8142a4036d Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 21 Sep 2016 12:47:26 -0400 Subject: [PATCH] Rewrite 'keylength < MIN_KEYLENGTH' to avoid -Wtautological-compare The warning surfaces under earlier Clnag's and GCC's --- seckey.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seckey.h b/seckey.h index bbf1ea7a..e033c8df 100644 --- a/seckey.h +++ b/seckey.h @@ -215,7 +215,8 @@ public: // TODO: Figure out how to make this CRYPTOPP_CONSTEXPR 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; else if (keylength > (size_t)MAX_KEYLENGTH) return (size_t)MAX_KEYLENGTH;