Skip to content

Commit b6605ff

Browse files
Enable compiler warnings (#736)
Enable compiler warnings and treat them as errors: * unused parameters * unused functions Updated the psv script to trigger an error on new warnings. Relates-To: OLPEDGE-1728 Signed-off-by: Mykhailo Kuchma <[email protected]>
1 parent d22e85b commit b6605ff

File tree

30 files changed

+555
-591
lines changed

30 files changed

+555
-591
lines changed

olp-cpp-sdk-core/src/client/OlpClient.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ CancellationToken OlpClient::CallApi(
328328
const std::string& path, const std::string& method,
329329
const OlpClient::ParametersType& query_params,
330330
const OlpClient::ParametersType& header_params,
331-
const OlpClient::ParametersType& form_params,
331+
const OlpClient::ParametersType& /*form_params*/,
332332
const OlpClient::RequestBodyType& post_body,
333333
const std::string& content_type,
334334
const NetworkAsyncCallback& callback) const {
@@ -368,7 +368,7 @@ CancellationToken OlpClient::CallApi(
368368
HttpResponse OlpClient::CallApi(std::string path, std::string method,
369369
OlpClient::ParametersType query_params,
370370
OlpClient::ParametersType header_params,
371-
OlpClient::ParametersType forms_params,
371+
OlpClient::ParametersType /*forms_params*/,
372372
OlpClient::RequestBodyType post_body,
373373
std::string content_type,
374374
CancellationContext context) const {

olp-cpp-sdk-core/src/http/curl/NetworkCurl.cpp

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,28 +61,6 @@ namespace {
6161

6262
const char* kLogTag = "CURL";
6363

64-
std::vector<std::pair<std::string, std::string> > GetStatistics(
65-
CURL* handle, std::size_t retryCount) {
66-
std::vector<std::pair<std::string, std::string> > statistics;
67-
double time;
68-
curl_easy_getinfo(handle, CURLINFO_TOTAL_TIME, &time);
69-
statistics.emplace_back("TotalTime", std::to_string(time));
70-
curl_easy_getinfo(handle, CURLINFO_NAMELOOKUP_TIME, &time);
71-
statistics.emplace_back("NameLookupTime", std::to_string(time));
72-
curl_easy_getinfo(handle, CURLINFO_CONNECT_TIME, &time);
73-
statistics.emplace_back("ConnectTime", std::to_string(time));
74-
curl_easy_getinfo(handle, CURLINFO_APPCONNECT_TIME, &time);
75-
statistics.emplace_back("AppConnectTime", std::to_string(time));
76-
curl_easy_getinfo(handle, CURLINFO_PRETRANSFER_TIME, &time);
77-
statistics.emplace_back("PreTransferTime", std::to_string(time));
78-
curl_easy_getinfo(handle, CURLINFO_STARTTRANSFER_TIME, &time);
79-
statistics.emplace_back("StartTransferTime", std::to_string(time));
80-
curl_easy_getinfo(handle, CURLINFO_REDIRECT_TIME, &time);
81-
statistics.emplace_back("RedirectTime", std::to_string(time));
82-
statistics.emplace_back("Retries", std::to_string(retryCount));
83-
return statistics;
84-
}
85-
8664
#ifdef OLP_SDK_NETWORK_HAS_OPENSSL
8765

8866
const auto curl_ca_bundle_name = "ca-bundle.crt";
@@ -179,24 +157,6 @@ int ConvertErrorCode(CURLcode curl_code) {
179157
}
180158

181159
#ifdef OLP_SDK_NETWORK_HAS_OPENSSL
182-
// Lifetime of the mutex table is managed by NetworkCurl object.
183-
static std::mutex* gSslMutexes;
184-
185-
void SslLockingFunction(int mode, int n, const char* file, int line) {
186-
if (gSslMutexes) {
187-
if (mode & CRYPTO_LOCK) {
188-
gSslMutexes[n].lock();
189-
} else {
190-
gSslMutexes[n].unlock();
191-
}
192-
}
193-
}
194-
195-
unsigned long SslIdFunction(void) {
196-
std::hash<std::thread::id> hasher;
197-
return static_cast<unsigned long>(hasher(std::this_thread::get_id()));
198-
}
199-
200160
#ifdef NETWORK_USE_TIMEPROVIDER
201161
static curl_code SslctxFunction(CURL* curl, void* sslctx, void*) {
202162
// get the current time in seconds since epoch
@@ -467,7 +427,6 @@ ErrorCode NetworkCurl::SendImplementation(
467427
handle->transfer_timeout = config.GetTransferTimeout();
468428
handle->max_retries = config.GetRetries();
469429
handle->ignore_offset = false; // request.IgnoreOffset();
470-
handle->get_statistics = false; // request.GetStatistics();
471430
handle->skip_content = false; // config->SkipContentWhenError();
472431

473432
for (const auto& header : request.GetHeaders()) {
@@ -691,7 +650,6 @@ NetworkCurl::RequestHandle* NetworkCurl::GetHandle(
691650
handle.body = std::move(body);
692651
handle.send_time = std::chrono::steady_clock::now();
693652
handle.error_text[0] = 0;
694-
handle.get_statistics = false;
695653
handle.skip_content = false;
696654

697655
return &handle;

olp-cpp-sdk-core/src/http/curl/NetworkCurl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -118,7 +118,6 @@ class NetworkCurl : public olp::http::Network,
118118
bool in_use{};
119119
bool range_out{};
120120
bool cancelled{};
121-
bool get_statistics{};
122121
bool skip_content{};
123122
char error_text[CURL_ERROR_SIZE]{};
124123
};

olp-cpp-sdk-core/src/thread/ThreadPoolTaskScheduler.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,20 @@ constexpr auto kLogTag = "ThreadPoolTaskScheduler";
4343

4444
void SetCurrentThreadName(const std::string& thread_name) {
4545
// Currently only supported for pthread users
46+
CORE_UNUSED(thread_name);
4647

4748
#if defined(PORTING_PLATFORM_MAC)
4849
// Note that in Mac based systems the pthread_setname_np takes 1 argument
4950
// only.
5051
pthread_setname_np(thread_name.c_str());
51-
#elif defined(PORTING_PLATFORM_WINDOWS) || defined(PORTING_PLATFORM_EMSCRIPTEN)
52-
// Unused
53-
CORE_UNUSED(thread_name);
54-
#else // Linux, Android, QNX
55-
#if defined(OLP_SDK_HAVE_PTHREAD_SETNAME_NP)
52+
#elif defined(OLP_SDK_HAVE_PTHREAD_SETNAME_NP) // Linux, Android, QNX
5653
// QNX allows 100 but Linux only 16 so select min value and apply for both.
5754
// If maximum length is exceeded on some systems, e.g. Linux, the name is not
5855
// set at all. So better truncate it to have at least the minimum set.
5956
constexpr size_t kMaxThreadNameLength = 16u;
6057
std::string truncated_name = thread_name.substr(0, kMaxThreadNameLength - 1);
6158
pthread_setname_np(pthread_self(), truncated_name.c_str());
6259
#endif // OLP_SDK_HAVE_PTHREAD_SETNAME_NP
63-
#endif // PORTING_PLATFORM_MAC
6460
}
6561

6662
} // namespace

olp-cpp-sdk-core/tests/cache/InMemoryCacheTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -335,10 +335,10 @@ TEST(InMemoryCacheTest, CustomCost) {
335335
auto oversized_model = "value: " + oversized;
336336

337337
struct MyCacheCost {
338-
std::size_t operator()(const ItemTuple& s) const { return 2; }
338+
std::size_t operator()(const ItemTuple&) const { return 2; }
339339
};
340340

341-
auto cost_func = [](const ItemTuple& tuple) { return 2; };
341+
auto cost_func = [](const ItemTuple&) { return 2; };
342342

343343
olp::cache::InMemoryCache cache(1, MyCacheCost());
344344

0 commit comments

Comments
 (0)