Skip to content

Commit 786fd60

Browse files
authored
Static analysis fixes (#125)
* size_t problems * second fixes
1 parent 6bdbbea commit 786fd60

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

include/countly/countly_configuration.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct CountlyConfiguration {
7272

7373
nlohmann::json metrics;
7474

75-
CountlyConfiguration(std::string appKey, std::string serverUrl) {
75+
CountlyConfiguration(const std::string appKey, std::string serverUrl) {
7676
this->appKey = appKey;
7777
this->serverUrl = serverUrl;
7878
}

src/request_module.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) {
212212
size_t scheme_offset = impl->use_https ? (sizeof("https://") - 1) : (sizeof("http://") - 1);
213213
size_t buffer_size = MultiByteToWideChar(CP_ACP, 0, impl->_configuration->serverUrl.c_str() + scheme_offset, -1, nullptr, 0);
214214
wchar_t *wide_hostname = new wchar_t[buffer_size];
215-
MultiByteToWideChar(CP_ACP, 0, impl->_configuration->serverUrl.c_str() + scheme_offset, -1, wide_hostname, buffer_size);
215+
MultiByteToWideChar(CP_ACP, 0, impl->_configuration->serverUrl.c_str() + scheme_offset, -1, wide_hostname, static_cast<int>(buffer_size));
216216

217217
hConnect = WinHttpConnect(hSession, wide_hostname, impl->_configuration->port, 0);
218218

@@ -227,7 +227,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) {
227227

228228
size_t buffer_size = MultiByteToWideChar(CP_ACP, 0, path.c_str(), -1, nullptr, 0);
229229
wchar_t *wide_path = new wchar_t[buffer_size];
230-
MultiByteToWideChar(CP_ACP, 0, path.c_str(), -1, wide_path, buffer_size);
230+
MultiByteToWideChar(CP_ACP, 0, path.c_str(), -1, wide_path, static_cast<int>(buffer_size));
231231

232232
hRequest = WinHttpOpenRequest(hConnect, use_post ? L"POST" : L"GET", wide_path, NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, impl->use_https ? WINHTTP_FLAG_SECURE : 0);
233233
delete[] wide_path;
@@ -240,7 +240,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) {
240240
ok = WinHttpReceiveResponse(hRequest, NULL);
241241
if (ok) {
242242
DWORD dwStatusCode = 0;
243-
DWORD dwSize = sizeof(dwStatusCode);
243+
DWORD dwSize = static_cast<DWORD>(sizeof(dwStatusCode));
244244
WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, WINHTTP_HEADER_NAME_BY_INDEX, &dwStatusCode, &dwSize, WINHTTP_NO_HEADER_INDEX);
245245
response.success = (dwStatusCode >= 200 && dwStatusCode < 300);
246246
if (response.success) {

tests/event.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <string>
55
using namespace cly;
66

7-
void valideEventParams(nlohmann::json eventJson, std::string key, int count) {
7+
void valideEventParams(nlohmann::json eventJson, const std::string key, int count) {
88
CHECK(eventJson["key"].get<std::string>() == key);
99
CHECK(eventJson["count"].get<int>() == count);
1010
CHECK(std::to_string(eventJson["timestamp"].get<long long>()).size() == 13);

tests/storage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void validateSizes(std::shared_ptr<StorageModuleBase> storageModule, long long s
2121
/**
2222
* Validates request.
2323
*/
24-
void validateDataEntry(std::shared_ptr<DataEntry> testedEntry, long long id, std::string data) {
24+
void validateDataEntry(std::shared_ptr<DataEntry> testedEntry, long long id, const std::string data) {
2525
CHECK(testedEntry->getId() == id);
2626
CHECK(testedEntry->getData() == data);
2727
}

tests/test_utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static HTTPResponse fakeSendHTTP(bool use_post, const std::string &url, const st
123123

124124
if (http_call.url == "/i") {
125125
response.success = true;
126-
} else if (http_call.url == "/o/sdk" && http_call.data["method"] == "fetch_remote_config") {
126+
} else if ((http_call.url == "/o/sdk") && (http_call.data["method"] == "fetch_remote_config")) {
127127
nlohmann::json remote_config = {{"color", "#FF9900"}, {"playerQueueTimeout", 32}, {"isChristmas", true}};
128128

129129
response.success = true;

tests/views.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using namespace std::literals::chrono_literals;
1818
* @param isOpenView: set 'true' if it is a open view.
1919
* @param isFirstView: set 'true' if it is very first view.
2020
*/
21-
void validateViewSegmentation(nlohmann::json e, std::string name, std::string &viewId, double duration, bool isOpenView, bool isFirstView = false) {
21+
void validateViewSegmentation(nlohmann::json e, const std::string name, std::string &viewId, double duration, bool isOpenView, bool isFirstView = false) {
2222
CHECK(e["key"].get<std::string>() == "[CLY]_view");
2323
CHECK(e["count"].get<int>() == 1);
2424
CHECK(e["dur"].get<double>() >= duration);

0 commit comments

Comments
 (0)