diff options
author | Ed Tanous <edtanous@google.com> | 2022-01-06 23:47:59 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-01-12 21:32:29 +0300 |
commit | 6de264cc79f5d0186f0136dbb8af15794e295894 (patch) | |
tree | ea13a49e49852b84322e37e7d5443cbbbf733a68 | |
parent | 24b2fe810e784f04728379f49af54a3ab2252c9b (diff) | |
download | bmcweb-6de264cc79f5d0186f0136dbb8af15794e295894.tar.xz |
Enable bugprone widening checks in clang
Most of the errors we hit are simply places we need to explicitly
increase the width of the integer. Luckily, these are few and far
between.
Tested: Code compiles, unit tests pass.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I617d87f3970ae773e0767bb2f20118fca2e71daa
-rw-r--r-- | .clang-tidy | 1 | ||||
-rw-r--r-- | http/http_connection.hpp | 4 | ||||
-rw-r--r-- | include/kvm_websocket.hpp | 4 | ||||
-rw-r--r-- | redfish-core/include/utils/time_utils.hpp | 3 |
4 files changed, 7 insertions, 5 deletions
diff --git a/.clang-tidy b/.clang-tidy index 3e9d87b2fb..15ade7fb15 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -12,6 +12,7 @@ bugprone-exception-escape, bugprone-fold-init-type, bugprone-forward-declaration-namespace, bugprone-forwarding-reference-overload, +bugprone-implicit-widening-of-multiplication-result, bugprone-inaccurate-erase, bugprone-incorrect-roundings, bugprone-infinite-loop, diff --git a/http/http_connection.hpp b/http/http_connection.hpp index 0f20761b4f..6de2bf7a0a 100644 --- a/http/http_connection.hpp +++ b/http/http_connection.hpp @@ -38,8 +38,8 @@ inline void prettyPrintJson(crow::Response& res) static int connectionCount = 0; // request body limit size set by the bmcwebHttpReqBodyLimitMb option -constexpr unsigned int httpReqBodyLimit = - 1024 * 1024 * bmcwebHttpReqBodyLimitMb; +constexpr uint64_t httpReqBodyLimit = + 1024UL * 1024UL * bmcwebHttpReqBodyLimitMb; constexpr uint64_t loggedOutPostBodyLimit = 4096; diff --git a/include/kvm_websocket.hpp b/include/kvm_websocket.hpp index a9dc8eaf0e..51246aa57f 100644 --- a/include/kvm_websocket.hpp +++ b/include/kvm_websocket.hpp @@ -145,8 +145,8 @@ class KvmSession crow::websocket::Connection& conn; boost::asio::ip::tcp::socket hostSocket; - boost::beast::flat_static_buffer<1024U * 50U> outputBuffer; - boost::beast::flat_static_buffer<1024U> inputBuffer; + boost::beast::flat_static_buffer<1024UL * 50UL> outputBuffer; + boost::beast::flat_static_buffer<1024UL> inputBuffer; bool doingWrite; }; diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp index d4c65de4e9..0df641655c 100644 --- a/redfish-core/include/utils/time_utils.hpp +++ b/redfish-core/include/utils/time_utils.hpp @@ -18,7 +18,8 @@ namespace time_utils namespace details { -using Days = std::chrono::duration<long long, std::ratio<24 * 60 * 60>>; +constexpr intmax_t dayDuration = static_cast<intmax_t>(24 * 60 * 60); +using Days = std::chrono::duration<long long, std::ratio<dayDuration>>; inline void leftZeroPadding(std::string& str, const std::size_t padding) { |