Skip to content

Commit 6bd0efc

Browse files
committed
cppcheck and clang-tidy fixes for Fedora43
1 parent a298184 commit 6bd0efc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+377
-388
lines changed

.clang-tidy

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ Checks: '*,
3838
-cppcoreguidelines-avoid-do-while,
3939
-llvmlibc-inline-function-decl,
4040
-altera-struct-pack-align,
41-
-boost-use-ranges
41+
-boost-use-ranges,
42+
-cppcoreguidelines-special-member-functions,
43+
-hicpp-special-member-functions,
44+
-misc-header-include-cycle,
45+
-cppcoreguidelines-avoid-const-or-ref-data-members,
46+
-google-explicit-constructor,
47+
-hicpp-explicit-conversions
4248
'
4349
WarningsAsErrors: '*'
44-
HeaderFilterRegex: 'src\/*.hpp'
50+
HeaderFilterRegex: 'include\/cpr\/.*\.h(pp)?'
4551
FormatStyle: file

cppcheck-suppressions.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@
3939
<suppress>
4040
<id>postfixOperator</id>
4141
</suppress>
42+
<suppress>
43+
<id>syntaxError</id>
44+
<fileName>*/cpr/util.cpp</fileName>
45+
</suppress>
4246
</suppressions>

cpr/async.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
namespace cpr {
44

55
// NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables)
6-
CPR_SINGLETON_IMPL(GlobalThreadPool)
6+
CPR_SINGLETON_IMPL(GlobalThreadPool);
77

88
} // namespace cpr

cpr/callback.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
#include <functional>
44

55
namespace cpr {
6-
76
void CancellationCallback::SetProgressCallback(ProgressCallback& u_cb) {
87
user_cb.emplace(std::reference_wrapper{u_cb});
98
}
9+
1010
bool CancellationCallback::operator()(cpr_pf_arg_t dltotal, cpr_pf_arg_t dlnow, cpr_pf_arg_t ultotal, cpr_pf_arg_t ulnow) const {
11-
const bool cont_operation{!cancellation_state->load()};
12-
return user_cb ? (cont_operation && (*user_cb)(dltotal, dlnow, ultotal, ulnow)) : cont_operation;
11+
const bool const_operation = !(cancellation_state->load());
12+
return user_cb ? (const_operation && (*user_cb)(dltotal, dlnow, ultotal, ulnow)) : const_operation;
1313
}
1414
} // namespace cpr

cpr/connection_pool.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,32 @@ namespace cpr {
77
ConnectionPool::ConnectionPool() {
88
CURLSH* curl_share = curl_share_init();
99
this->connection_mutex_ = std::make_shared<std::mutex>();
10-
10+
1111
auto lock_f = +[](CURL* /*handle*/, curl_lock_data /*data*/, curl_lock_access /*access*/, void* userptr) {
1212
std::mutex* lock = static_cast<std::mutex*>(userptr);
1313
lock->lock(); // cppcheck-suppress localMutex // False positive: mutex is used as callback for libcurl, not local scope
1414
};
15-
15+
1616
auto unlock_f = +[](CURL* /*handle*/, curl_lock_data /*data*/, void* userptr) {
1717
std::mutex* lock = static_cast<std::mutex*>(userptr);
1818
lock->unlock();
1919
};
20-
20+
2121
curl_share_setopt(curl_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
2222
curl_share_setopt(curl_share, CURLSHOPT_USERDATA, this->connection_mutex_.get());
2323
curl_share_setopt(curl_share, CURLSHOPT_LOCKFUNC, lock_f);
2424
curl_share_setopt(curl_share, CURLSHOPT_UNLOCKFUNC, unlock_f);
25-
26-
this->curl_sh_ = std::shared_ptr<CURLSH>(curl_share,
27-
[](CURLSH* ptr) {
28-
// Make sure to reset callbacks before cleanup to avoid deadlocks
29-
curl_share_setopt(ptr, CURLSHOPT_LOCKFUNC, nullptr);
30-
curl_share_setopt(ptr, CURLSHOPT_UNLOCKFUNC, nullptr);
31-
curl_share_cleanup(ptr);
32-
});
25+
26+
this->curl_sh_ = std::shared_ptr<CURLSH>(curl_share, [](CURLSH* ptr) {
27+
// Make sure to reset callbacks before cleanup to avoid deadlocks
28+
curl_share_setopt(ptr, CURLSHOPT_LOCKFUNC, nullptr);
29+
curl_share_setopt(ptr, CURLSHOPT_UNLOCKFUNC, nullptr);
30+
curl_share_cleanup(ptr);
31+
});
3332
}
3433

3534
void ConnectionPool::SetupHandler(CURL* easy_handler) const {
3635
curl_easy_setopt(easy_handler, CURLOPT_SHARE, this->curl_sh_.get());
3736
}
3837

39-
} // namespace cpr
38+
} // namespace cpr

cpr/cprtypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "cpr/cprtypes.h"
2-
32
#include <algorithm>
43
#include <cctype>
54
#include <string>
65

6+
77
namespace cpr {
88
bool CaseInsensitiveCompare::operator()(const std::string& a, const std::string& b) const noexcept {
99
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end(), [](unsigned char ac, unsigned char bc) { return std::tolower(ac) < std::tolower(bc); });

cpr/curlholder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CurlHolder::CurlHolder() {
2222
assert(handle);
2323
}
2424

25-
CurlHolder::CurlHolder(CurlHolder&& old) noexcept : handle(old.handle), chunk(old.chunk), resolveCurlList(old.resolveCurlList), multipart(old.multipart), error(std::move(old.error)) {
25+
CurlHolder::CurlHolder(CurlHolder&& old) noexcept : handle(old.handle), chunk(old.chunk), resolveCurlList(old.resolveCurlList), multipart(old.multipart), error(old.error) {
2626
// Avoid double free
2727
old.handle = nullptr;
2828
old.chunk = nullptr;
@@ -49,7 +49,7 @@ CurlHolder& CurlHolder::operator=(CurlHolder&& old) noexcept {
4949
chunk = old.chunk;
5050
resolveCurlList = old.resolveCurlList;
5151
multipart = old.multipart;
52-
error = std::move(old.error);
52+
error = old.error;
5353

5454
// Avoid double free
5555
old.handle = nullptr;

0 commit comments

Comments
 (0)