From 225e76c45f603681e83eaf2b9cbe5a5d69daa8a0 Mon Sep 17 00:00:00 2001 From: Sergey Yakubov <sergey.yakubov@desy.de> Date: Wed, 30 Jun 2021 18:36:40 +0200 Subject: [PATCH] fix some warnings --- .../server/task/fabric_handshake_accepting_task.h | 2 +- common/cpp/src/system_io/system_io.cpp | 3 ++- .../producer/dummy-data-producer/dummy_data_producer.cpp | 7 ++++--- producer/event_monitor_producer/src/inotify_event.cpp | 2 +- .../src/system_folder_watch_linux.cpp | 2 +- .../unittests/test_system_folder_watch_linux.cpp | 4 ++-- receiver/src/data_cache.cpp | 2 +- receiver/unittests/test_datacache.cpp | 4 ++-- tests/automatic/consumer/consumer_api/consumer_api.c | 2 +- .../next_multithread_broker/next_multithread_broker.cpp | 2 +- .../manual/performance_broker_receiver/getlast_broker.cpp | 2 +- 11 files changed, 17 insertions(+), 15 deletions(-) diff --git a/common/cpp/src/asapo_fabric/server/task/fabric_handshake_accepting_task.h b/common/cpp/src/asapo_fabric/server/task/fabric_handshake_accepting_task.h index dedf61822..92ebd232a 100644 --- a/common/cpp/src/asapo_fabric/server/task/fabric_handshake_accepting_task.h +++ b/common/cpp/src/asapo_fabric/server/task/fabric_handshake_accepting_task.h @@ -12,7 +12,7 @@ class FabricServerImpl; class FabricHandshakeAcceptingTask : public FabricSelfRequeuingTask { private: - FabricHandshakePayload handshake_payload_{}; + FabricHandshakePayload handshake_payload_; public: explicit FabricHandshakeAcceptingTask(FabricServerImpl* server); diff --git a/common/cpp/src/system_io/system_io.cpp b/common/cpp/src/system_io/system_io.cpp index 0d8ddcb43..6b35e0491 100644 --- a/common/cpp/src/system_io/system_io.cpp +++ b/common/cpp/src/system_io/system_io.cpp @@ -8,7 +8,8 @@ #include <mutex> #ifdef _WIN32 -# include <winsock2.h> +typedef long suseconds_t; +typedef short sa_family_t; #endif #if defined(__linux__) || defined (__APPLE__) diff --git a/examples/producer/dummy-data-producer/dummy_data_producer.cpp b/examples/producer/dummy-data-producer/dummy_data_producer.cpp index 1cf0e65af..24eacdb33 100644 --- a/examples/producer/dummy-data-producer/dummy_data_producer.cpp +++ b/examples/producer/dummy-data-producer/dummy_data_producer.cpp @@ -211,9 +211,10 @@ std::unique_ptr<asapo::Producer> CreateProducer(const Args& args) { void PrintOutput(const Args& args, const system_clock::time_point& start) { system_clock::time_point t2 = system_clock::now(); - double duration_sec = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - start ).count() / 1000.0; - double size_gb = double(args.number_of_bytes) * args.iterations / 1000.0 / 1000.0 / 1000.0 * 8.0; - double rate = args.iterations / duration_sec; + double duration_sec = static_cast<double>(std::chrono::duration_cast<std::chrono::milliseconds>(t2 - start).count()) + / 1000.0; + double size_gb = static_cast<double>(args.number_of_bytes*args.iterations) / 1000.0 / 1000.0 / 1000.0 * 8.0; + double rate = static_cast<double>(args.iterations) / duration_sec; std::cout << "Rate: " << rate << " Hz" << std::endl; std::cout << "Bandwidth " << size_gb / duration_sec << " Gbit/s" << std::endl; std::cout << "Bandwidth " << size_gb / duration_sec / 8 << " GBytes/s" << std::endl; diff --git a/producer/event_monitor_producer/src/inotify_event.cpp b/producer/event_monitor_producer/src/inotify_event.cpp index 8535caafe..f28aa50f8 100644 --- a/producer/event_monitor_producer/src/inotify_event.cpp +++ b/producer/event_monitor_producer/src/inotify_event.cpp @@ -9,7 +9,7 @@ InotifyEvent::InotifyEvent(const struct inotify_event* inotify_event, } uint32_t InotifyEvent::Length() const { - return sizeof(struct inotify_event) + inotify_event_->len; + return sizeof(struct inotify_event) + static_cast<uint32_t>(inotify_event_->len); } bool InotifyEvent::IsDirectoryEvent() const { diff --git a/producer/event_monitor_producer/src/system_folder_watch_linux.cpp b/producer/event_monitor_producer/src/system_folder_watch_linux.cpp index b1aeb7ea0..23f153fdf 100644 --- a/producer/event_monitor_producer/src/system_folder_watch_linux.cpp +++ b/producer/event_monitor_producer/src/system_folder_watch_linux.cpp @@ -199,7 +199,7 @@ Error SystemFolderWatch::ProcessInotifyEvent(const InotifyEvent& event, FilesToS } Error SystemFolderWatch::ReadInotifyEvents(int* bytes_read) { - *bytes_read = inotify__->Read(watch_fd_, buffer_.get(), kBufLen); + *bytes_read = static_cast<int>(inotify__->Read(watch_fd_, buffer_.get(), kBufLen)); if (*bytes_read < 0) { return EventMonitorErrorTemplates::kSystemError.Generate("read from inotify fd"); } diff --git a/producer/event_monitor_producer/unittests/test_system_folder_watch_linux.cpp b/producer/event_monitor_producer/unittests/test_system_folder_watch_linux.cpp index d2b1f50e4..a22c65f74 100644 --- a/producer/event_monitor_producer/unittests/test_system_folder_watch_linux.cpp +++ b/producer/event_monitor_producer/unittests/test_system_folder_watch_linux.cpp @@ -126,9 +126,9 @@ ssize_t SystemFolderWatchTests::AddEventToBuffer(std::string filename, uint32_t event->mask = mask; event->wd = fd; strcpy(event->name, filename.c_str()); - event->len = strlen(event->name) + 1; + event->len = static_cast<uint32_t>(strlen(event->name)) + 1; memcpy(buffer + cur_buffer_pointer, event, size); - cur_buffer_pointer += size; + cur_buffer_pointer += static_cast<int>(size); free(buf); return size; diff --git a/receiver/src/data_cache.cpp b/receiver/src/data_cache.cpp index d346164fb..f6765f46f 100644 --- a/receiver/src/data_cache.cpp +++ b/receiver/src/data_cache.cpp @@ -72,7 +72,7 @@ bool DataCache::SlotTooCloseToCurrentPointer(const CacheMeta* meta) { } else { dist = cache_size_ - cur_pointer_ + shift; } - return dist < cache_size_ * keepunlocked_ratio_; + return dist < static_cast<uint64_t>(static_cast<float>(cache_size_) * keepunlocked_ratio_); } // we allow to read if it was already locked - if lock come from reading - no problems, from writing -should not happen! diff --git a/receiver/unittests/test_datacache.cpp b/receiver/unittests/test_datacache.cpp index 69d668a7d..d17f29276 100644 --- a/receiver/unittests/test_datacache.cpp +++ b/receiver/unittests/test_datacache.cpp @@ -102,7 +102,7 @@ TEST_F(DataCacheTests, PrepareToReadIdNotFound) { } TEST_F(DataCacheTests, PrepareToReadOk) { - auto data_size = static_cast<uint64_t>(expected_cache_size * 0.7); + auto data_size = static_cast<uint64_t>(static_cast<double>(expected_cache_size) * 0.7); uint8_t* ini_addr = (uint8_t*) cache.GetFreeSlotAndLock(data_size, &meta1); uint8_t* addr = (uint8_t*) cache.GetSlotToReadAndLock(meta1->id, data_size, &meta2); @@ -113,7 +113,7 @@ TEST_F(DataCacheTests, PrepareToReadOk) { TEST_F(DataCacheTests, PrepareToReadFailsIfTooCloseToCurrentPointer) { - auto data_size = static_cast<uint64_t>(expected_cache_size * 0.9); + auto data_size = static_cast<uint64_t>(static_cast<double>(expected_cache_size) * 0.9); cache.GetFreeSlotAndLock(data_size, &meta1); uint8_t* addr = (uint8_t*) cache.GetSlotToReadAndLock(meta1->id, data_size, &meta2); diff --git a/tests/automatic/consumer/consumer_api/consumer_api.c b/tests/automatic/consumer/consumer_api/consumer_api.c index 37501ed76..21cfa2937 100644 --- a/tests/automatic/consumer/consumer_api/consumer_api.c +++ b/tests/automatic/consumer/consumer_api/consumer_api.c @@ -12,7 +12,7 @@ void assert_eq_int_(uint64_t expected, uint64_t got, const char *message, int line) { printf("asserting %s at %d\n",message,line); if (expected!=got) { - printf("%s: expected %llu got %llu at %d\n",message, expected, got,line); + printf("%s: expected %llu got %llu at %d\n",message, (unsigned long long)expected, (unsigned long long)got,line); exit(EXIT_FAILURE); } } diff --git a/tests/automatic/consumer/next_multithread_broker/next_multithread_broker.cpp b/tests/automatic/consumer/next_multithread_broker/next_multithread_broker.cpp index 9934ec1a3..eb8c03c6f 100644 --- a/tests/automatic/consumer/next_multithread_broker/next_multithread_broker.cpp +++ b/tests/automatic/consumer/next_multithread_broker/next_multithread_broker.cpp @@ -12,7 +12,7 @@ void Assert(std::vector<asapo::MessageMetas> message_metas, uint64_t nthreads, i } int nfiles_read = 0; for (uint64_t i = 0; i < nthreads; i++) { - nfiles_read += message_metas[i].size(); + nfiles_read += static_cast<int>(message_metas[i].size()); for (const auto& fi : message_metas[i]) { result.push_back(fi.name); } diff --git a/tests/manual/performance_broker_receiver/getlast_broker.cpp b/tests/manual/performance_broker_receiver/getlast_broker.cpp index 9f3bf7f53..07e8032e9 100644 --- a/tests/manual/performance_broker_receiver/getlast_broker.cpp +++ b/tests/manual/performance_broker_receiver/getlast_broker.cpp @@ -203,7 +203,7 @@ int main(int argc, char* argv[]) { } std::cout << "Errors : " << nerrors << std::endl; std::cout << "Elapsed : " << duration_ms << "ms" << std::endl; - std::cout << "Rate : " << 1000.0f * nfiles / (duration_ms) << " Hz" << std::endl; + std::cout << "Rate : " << 1000.0f * static_cast<float>(nfiles) / (static_cast<float>(duration_ms)) << " Hz" << std::endl; std::cout << "Using connection type: " << ConnectionTypeToString(connectionType) << std::endl; -- GitLab