From: Andrei Pavel Date: Thu, 16 May 2024 12:45:54 +0000 (+0300) Subject: [#3256] fix Wtype-limits warnings X-Git-Tag: Kea-2.6.0~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bceff40010e5e9d543abd5b495e249ff41aaef07;p=thirdparty%2Fkea.git [#3256] fix Wtype-limits warnings ``` data.cc:905:21: warning: comparison is always true due to limited range of data type [-Wtype-limits] data.cc:905:48: warning: comparison is always false due to limited range of data type [-Wtype-limits] http_message_parser_base.cc:266:15: warning: comparison is always true due to limited range of data type [-Wtype-limits] http_message_parser_base.cc:271:17: warning: comparison is always true due to limited range of data type [-Wtype-limits] ``` --- diff --git a/src/lib/cc/data.cc b/src/lib/cc/data.cc index 3fb117ac0f..b7bc6c399a 100644 --- a/src/lib/cc/data.cc +++ b/src/lib/cc/data.cc @@ -875,7 +875,7 @@ StringElement::toJSON(std::ostream& ss) const { ss << "\""; const std::string& str = stringValue(); for (size_t i = 0; i < str.size(); ++i) { - const char c = str[i]; + const signed char c = str[i]; // Escape characters as defined in JSON spec // Note that we do not escape forward slash; this // is allowed, but not mandatory. diff --git a/src/lib/http/http_message_parser_base.cc b/src/lib/http/http_message_parser_base.cc index 000e3439de..cbda31a013 100644 --- a/src/lib/http/http_message_parser_base.cc +++ b/src/lib/http/http_message_parser_base.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -261,18 +261,18 @@ HttpMessageParserBase::popNextFromBuffer(std::string& next, const size_t limit) } bool -HttpMessageParserBase::isChar(const char c) const { +HttpMessageParserBase::isChar(const signed char c) const { // was (c >= 0) && (c <= 127) return (c >= 0); } bool -HttpMessageParserBase::isCtl(const char c) const { +HttpMessageParserBase::isCtl(const signed char c) const { return (((c >= 0) && (c <= 31)) || (c == 127)); } bool -HttpMessageParserBase::isSpecial(const char c) const { +HttpMessageParserBase::isSpecial(const signed char c) const { switch (c) { case '(': case ')': diff --git a/src/lib/http/http_message_parser_base.h b/src/lib/http/http_message_parser_base.h index 01f9831e2d..b11e558591 100644 --- a/src/lib/http/http_message_parser_base.h +++ b/src/lib/http/http_message_parser_base.h @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -285,17 +285,17 @@ protected: /// @brief Checks if specified value is a character. /// /// @return true, if specified value is a character. - bool isChar(const char c) const; + bool isChar(const signed char c) const; /// @brief Checks if specified value is a control value. /// /// @return true, if specified value is a control value. - bool isCtl(const char c) const; + bool isCtl(const signed char c) const; /// @brief Checks if specified value is a special character. /// /// @return true, if specified value is a special character. - bool isSpecial(const char c) const; + bool isSpecial(const signed char c) const; /// @brief Reference to the parsed HTTP message. HttpMessage& message_;