diff options
author | Ed Tanous <edtanous@google.com> | 2021-02-23 23:52:50 +0300 |
---|---|---|
committer | Ed Tanous <edtanous@google.com> | 2021-02-24 00:29:16 +0300 |
commit | b00dcc27587267e18d3abdee82f1ed7b39744d02 (patch) | |
tree | 90d059b0e265fe5b3d5bf36bcd59eec7880d1b3e | |
parent | 738c1e610e3b3e3bf1dd4cc80965dbceefeeddf1 (diff) | |
download | bmcweb-b00dcc27587267e18d3abdee82f1ed7b39744d02.tar.xz |
Fix the build on clang-11
Clang tidy 11 got some really neat checks that do a much better job.
Unfortunately, this, combined with the change in how std::executors has
defined how callbacks should work differently in the past, which we
picked up in 1.73, and now in theory we have recursion in a bunch of our
IO loops that we have to break manually. In practice, this is unlikely
to matter, as there's almost a 0% chance that we go through N thousand
requests without ever starving the IO buffer.
Other changes to make this build include:
1. Adding inline on the appropriate places where declared in a header.
2. Removing an Openssl call that did nothing, as the result was
immediately overwritten.
3. Declaring the subproject dependencies as system dependencies, which
silences the clang-tidy checks for those projects.
Tested:
Code builds again, clang-tidy passes
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ic11b1002408e8ac19a17a955e9477cac6e0d7504
-rw-r--r-- | .clang-tidy | 4 | ||||
-rw-r--r-- | http/http_client.hpp | 1 | ||||
-rw-r--r-- | http/utility.hpp | 2 | ||||
-rw-r--r-- | include/cors_preflight.hpp | 2 | ||||
-rw-r--r-- | include/ssl_key_handler.hpp | 3 | ||||
-rw-r--r-- | meson.build | 5 | ||||
-rw-r--r-- | redfish-core/include/utils/time_utils.hpp | 2 | ||||
-rw-r--r-- | redfish-core/lib/sensors.hpp | 2 |
8 files changed, 14 insertions, 7 deletions
diff --git a/.clang-tidy b/.clang-tidy index 3b34c55254..0122e24b09 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -36,7 +36,7 @@ bugprone-string-constructor, bugprone-string-integer-assignment, bugprone-string-literal-with-embedded-nul, bugprone-suspicious-enum-usage, -bugprone-suspicious-include, +#bugprone-suspicious-include, bugprone-suspicious-memset-usage, bugprone-suspicious-missing-comma, bugprone-suspicious-semicolon, @@ -190,7 +190,7 @@ clang-analyzer-valist.ValistBase, clang-analyzer-webkit.NoUncountedMemberChecker, clang-analyzer-webkit.RefCntblBaseVirtualDtor, misc-misplaced-const, -misc-no-recursion, +#misc-no-recursion, misc-redundant-expression, misc-static-assert, misc-throw-by-value-catch-by-reference, diff --git a/http/http_client.hpp b/http/http_client.hpp index 5c7b13fc1d..1ac890ce7d 100644 --- a/http/http_client.hpp +++ b/http/http_client.hpp @@ -80,6 +80,7 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> BMCWEB_LOG_DEBUG << "Trying to connect to: " << host << ":" << port; // Set a timeout on the operation conn.expires_after(std::chrono::seconds(30)); + conn.async_connect(endpoint, [self(shared_from_this())]( const boost::beast::error_code& ec, const boost::asio::ip::tcp::resolver:: diff --git a/http/utility.hpp b/http/utility.hpp index be506367ca..19ffe9fe66 100644 --- a/http/utility.hpp +++ b/http/utility.hpp @@ -124,6 +124,7 @@ struct computeParameterTagFromArgsList<Arg, Args...> inline bool isParameterTagCompatible(uint64_t a, uint64_t b) { + if (a == 0) { return b == 0; @@ -151,6 +152,7 @@ inline bool isParameterTagCompatible(uint64_t a, uint64_t b) constexpr uint64_t getParameterTag(std::string_view s, unsigned p = 0) { + if (p == s.size()) { return 0; diff --git a/include/cors_preflight.hpp b/include/cors_preflight.hpp index 844fd3862e..4bac265182 100644 --- a/include/cors_preflight.hpp +++ b/include/cors_preflight.hpp @@ -6,7 +6,7 @@ namespace cors_preflight { -void requestRoutes(App& app) +inline void requestRoutes(App& app) { BMCWEB_ROUTE(app, "<str>") .methods(boost::beast::http::verb::options)( diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp index 39e83d7f85..24e40a48af 100644 --- a/include/ssl_key_handler.hpp +++ b/include/ssl_key_handler.hpp @@ -205,8 +205,7 @@ inline X509* loadCert(const std::string& filePath) inline int addExt(X509* cert, int nid, const char* value) { X509_EXTENSION* ex = nullptr; - X509V3_CTX ctx; - X509V3_set_ctx_nodb(&ctx); + X509V3_CTX ctx{}; X509V3_set_ctx(&ctx, cert, cert, nullptr, nullptr, 0); ex = X509V3_EXT_conf_nid(nullptr, &ctx, nid, const_cast<char*>(value)); if (!ex) diff --git a/meson.build b/meson.build index 48f7691389..27f25eca2e 100644 --- a/meson.build +++ b/meson.build @@ -291,6 +291,7 @@ else 'subprojects/nlohmann/single_include/nlohmann', ] ) + nlohmann_json = nlohmann_json.as_system('system') endif bmcweb_dependencies += nlohmann_json @@ -299,6 +300,7 @@ if not boost.found() subproject('boost', required: false) boost_inc = include_directories('subprojects/boost_1_75_0/', is_system:true) boost = declare_dependency(include_directories : boost_inc) + boost = boost.as_system('system') endif bmcweb_dependencies += boost @@ -308,6 +310,7 @@ else subproject('boost-url', required: false) boost_url_inc = include_directories('subprojects/boost-url/include', is_system:true) boost_url= declare_dependency(include_directories : boost_url_inc) + boost_url = boost_url.as_system('system') endif bmcweb_dependencies += boost_url @@ -319,6 +322,8 @@ if get_option('tests').enabled() gtest = gtest_proj.get_variable('gtest_main_dep') gmock = gtest_proj.get_variable('gmock_dep') endif + gtest = gtest.as_system('system') + gmock = gmock.as_system('system') endif # Source files diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp index dd4ea75c48..4a87ba0d6c 100644 --- a/redfish-core/include/utils/time_utils.hpp +++ b/redfish-core/include/utils/time_utils.hpp @@ -26,7 +26,7 @@ inline void leftZeroPadding(std::string& str, const std::size_t padding) * Example output: "P12DT1M5.5S" * Ref: Redfish Specification, Section 9.4.4. Duration values */ -std::string toDurationString(std::chrono::milliseconds ms) +inline std::string toDurationString(std::chrono::milliseconds ms) { if (ms < std::chrono::milliseconds::zero()) { diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp index 5cef3b13bf..35114bfcfb 100644 --- a/redfish-core/lib/sensors.hpp +++ b/redfish-core/lib/sensors.hpp @@ -2691,7 +2691,7 @@ inline bool findSensorNameUsingSensorPath( for (auto& chassisSensor : sensorsList) { sdbusplus::message::object_path path(chassisSensor); - std::string_view thisSensorName = path.filename(); + std::string thisSensorName = path.filename(); if (thisSensorName.empty()) { continue; |