From a8c2dd02b2ea761791af6c55f7cf1736a5149c88 Mon Sep 17 00:00:00 2001 From: turtledreams Date: Fri, 19 May 2023 17:53:16 +0900 Subject: [PATCH 1/2] size_t problems --- src/request_module.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/request_module.cpp b/src/request_module.cpp index b9180e5..7b23996 100644 --- a/src/request_module.cpp +++ b/src/request_module.cpp @@ -212,7 +212,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) { size_t scheme_offset = impl->use_https ? (sizeof("https://") - 1) : (sizeof("http://") - 1); size_t buffer_size = MultiByteToWideChar(CP_ACP, 0, impl->_configuration->serverUrl.c_str() + scheme_offset, -1, nullptr, 0); wchar_t *wide_hostname = new wchar_t[buffer_size]; - MultiByteToWideChar(CP_ACP, 0, impl->_configuration->serverUrl.c_str() + scheme_offset, -1, wide_hostname, buffer_size); + MultiByteToWideChar(CP_ACP, 0, impl->_configuration->serverUrl.c_str() + scheme_offset, -1, wide_hostname, static_cast(buffer_size)); hConnect = WinHttpConnect(hSession, wide_hostname, impl->_configuration->port, 0); @@ -227,7 +227,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) { size_t buffer_size = MultiByteToWideChar(CP_ACP, 0, path.c_str(), -1, nullptr, 0); wchar_t *wide_path = new wchar_t[buffer_size]; - MultiByteToWideChar(CP_ACP, 0, path.c_str(), -1, wide_path, buffer_size); + MultiByteToWideChar(CP_ACP, 0, path.c_str(), -1, wide_path, static_cast(buffer_size)); 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); delete[] wide_path; @@ -240,7 +240,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) { ok = WinHttpReceiveResponse(hRequest, NULL); if (ok) { DWORD dwStatusCode = 0; - DWORD dwSize = sizeof(dwStatusCode); + DWORD dwSize = static_cast(sizeof(dwStatusCode)); WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, WINHTTP_HEADER_NAME_BY_INDEX, &dwStatusCode, &dwSize, WINHTTP_NO_HEADER_INDEX); response.success = (dwStatusCode >= 200 && dwStatusCode < 300); if (response.success) { From 2fa59e9ae4ed8be025fc3312347921a7f6f34779 Mon Sep 17 00:00:00 2001 From: turtledreams Date: Fri, 19 May 2023 19:15:45 +0900 Subject: [PATCH 2/2] second fixes --- include/countly/countly_configuration.hpp | 2 +- tests/event.cpp | 2 +- tests/storage.cpp | 2 +- tests/test_utils.hpp | 2 +- tests/views.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/countly/countly_configuration.hpp b/include/countly/countly_configuration.hpp index 0fa7ccf..0b4aa4f 100644 --- a/include/countly/countly_configuration.hpp +++ b/include/countly/countly_configuration.hpp @@ -72,7 +72,7 @@ struct CountlyConfiguration { nlohmann::json metrics; - CountlyConfiguration(std::string appKey, std::string serverUrl) { + CountlyConfiguration(const std::string appKey, std::string serverUrl) { this->appKey = appKey; this->serverUrl = serverUrl; } diff --git a/tests/event.cpp b/tests/event.cpp index ee9f47c..9213013 100644 --- a/tests/event.cpp +++ b/tests/event.cpp @@ -4,7 +4,7 @@ #include using namespace cly; -void valideEventParams(nlohmann::json eventJson, std::string key, int count) { +void valideEventParams(nlohmann::json eventJson, const std::string key, int count) { CHECK(eventJson["key"].get() == key); CHECK(eventJson["count"].get() == count); CHECK(std::to_string(eventJson["timestamp"].get()).size() == 13); diff --git a/tests/storage.cpp b/tests/storage.cpp index ead9e8c..13bc1f9 100644 --- a/tests/storage.cpp +++ b/tests/storage.cpp @@ -21,7 +21,7 @@ void validateSizes(std::shared_ptr storageModule, long long s /** * Validates request. */ -void validateDataEntry(std::shared_ptr testedEntry, long long id, std::string data) { +void validateDataEntry(std::shared_ptr testedEntry, long long id, const std::string data) { CHECK(testedEntry->getId() == id); CHECK(testedEntry->getData() == data); } diff --git a/tests/test_utils.hpp b/tests/test_utils.hpp index dadd668..4062db9 100644 --- a/tests/test_utils.hpp +++ b/tests/test_utils.hpp @@ -123,7 +123,7 @@ static HTTPResponse fakeSendHTTP(bool use_post, const std::string &url, const st if (http_call.url == "/i") { response.success = true; - } else if (http_call.url == "/o/sdk" && http_call.data["method"] == "fetch_remote_config") { + } else if ((http_call.url == "/o/sdk") && (http_call.data["method"] == "fetch_remote_config")) { nlohmann::json remote_config = {{"color", "#FF9900"}, {"playerQueueTimeout", 32}, {"isChristmas", true}}; response.success = true; diff --git a/tests/views.cpp b/tests/views.cpp index 3e08440..7e241ff 100644 --- a/tests/views.cpp +++ b/tests/views.cpp @@ -18,7 +18,7 @@ using namespace std::literals::chrono_literals; * @param isOpenView: set 'true' if it is a open view. * @param isFirstView: set 'true' if it is very first view. */ -void validateViewSegmentation(nlohmann::json e, std::string name, std::string &viewId, double duration, bool isOpenView, bool isFirstView = false) { +void validateViewSegmentation(nlohmann::json e, const std::string name, std::string &viewId, double duration, bool isOpenView, bool isFirstView = false) { CHECK(e["key"].get() == "[CLY]_view"); CHECK(e["count"].get() == 1); CHECK(e["dur"].get() >= duration);