From c1059f11f50770f009e789a84fd47579cfaf2d02 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Mon, 13 Jul 2020 20:59:36 +0300 Subject: [PATCH] Remove yet more windows warnings --- CMakeLists.txt | 7 ++++++- components/codecs/src/reader.cpp | 2 +- components/common/cpp/src/uri.cpp | 2 +- components/net/cpp/include/ftl/net/universe.hpp | 2 +- components/net/cpp/src/peer.cpp | 16 ++++++++-------- components/net/cpp/src/universe.cpp | 6 +++--- .../structures/include/ftl/data/new_frame.hpp | 5 +++++ 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9da0cf46b..e15d1bfce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -305,16 +305,21 @@ endif() check_language(CUDA) if (CUDA_TOOLKIT_ROOT_DIR) enable_language(CUDA) -set(CMAKE_CUDA_FLAGS "-Xcompiler -fPIC") + +if (NOT WIN32) + set(CMAKE_CUDA_FLAGS "-Xcompiler -fPIC") +endif() set(CMAKE_CUDA_FLAGS_DEBUG "--gpu-architecture=compute_61 -g -DDEBUG -D_DEBUG") set(CMAKE_CUDA_FLAGS_RELEASE "--gpu-architecture=compute_61") set(HAVE_CUDA TRUE) include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) # Some kind of fix for nvcc and -pthread problem on Linux +if (NOT WIN32) set_property(TARGET Threads::Threads PROPERTY INTERFACE_COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler -pthread> "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-pthread>") +endif() endif () diff --git a/components/codecs/src/reader.cpp b/components/codecs/src/reader.cpp index 2a2fc4145..26d4f58f4 100644 --- a/components/codecs/src/reader.cpp +++ b/components/codecs/src/reader.cpp @@ -80,7 +80,7 @@ bool Reader::read(int64_t ts, const std::function<void(const ftl::codecs::Stream stream_->read(buffer_.buffer(), buffer_.buffer_capacity()); //if (stream_->bad()) return false; - int bytes = stream_->gcount(); + size_t bytes = static_cast<size_t>(stream_->gcount()); if (bytes == 0) break; buffer_.buffer_consumed(bytes); partial = false; diff --git a/components/common/cpp/src/uri.cpp b/components/common/cpp/src/uri.cpp index fdb8e046c..14270640c 100644 --- a/components/common/cpp/src/uri.cpp +++ b/components/common/cpp/src/uri.cpp @@ -175,7 +175,7 @@ string URI::getBaseURI(int n) { size_t N = m_pathseg.size()+n; for (size_t i=0; i<N; i++) { r += "/"; - r += getPathSegment(i); + r += getPathSegment(static_cast<int>(i)); } return r; diff --git a/components/net/cpp/include/ftl/net/universe.hpp b/components/net/cpp/include/ftl/net/universe.hpp index 260e9dea3..37bdd1362 100644 --- a/components/net/cpp/include/ftl/net/universe.hpp +++ b/components/net/cpp/include/ftl/net/universe.hpp @@ -214,7 +214,7 @@ class Universe : public ftl::Configurable { private: void _run(); - int _setDescriptors(); + SOCKET _setDescriptors(); void _installBindings(); void _installBindings(Peer *); //bool _subscribe(const std::string &res); diff --git a/components/net/cpp/src/peer.cpp b/components/net/cpp/src/peer.cpp index 2a8bf879c..339e2f667 100644 --- a/components/net/cpp/src/peer.cpp +++ b/components/net/cpp/src/peer.cpp @@ -67,7 +67,7 @@ ftl::UUID ftl::net::this_peer; //static ctpl::thread_pool pool(5); // TODO:(nick) Move to tcp_internal.cpp -static SOCKET tcpConnect(URI &uri, int ssize, int rsize) { +static SOCKET tcpConnect(URI &uri, size_t ssize, size_t rsize) { int rc; //sockaddr_in destAddr; @@ -90,11 +90,11 @@ static SOCKET tcpConnect(URI &uri, int ssize, int rsize) { int flags =1; if (setsockopt(csocket, IPPROTO_TCP, TCP_NODELAY, (const char *)&flags, sizeof(flags))) { LOG(ERROR) << "ERROR: setsocketopt(), TCP_NODELAY"; }; - int a = rsize; + int a = static_cast<int>(rsize); if (setsockopt(csocket, SOL_SOCKET, SO_RCVBUF, (const char *)&a, sizeof(int)) == -1) { fprintf(stderr, "Error setting socket opts: %s\n", strerror(errno)); } - a = ssize; + a = static_cast<int>(ssize); if (setsockopt(csocket, SOL_SOCKET, SO_SNDBUF, (const char *)&a, sizeof(int)) == -1) { fprintf(stderr, "Error setting socket opts: %s\n", strerror(errno)); } @@ -136,7 +136,7 @@ static SOCKET tcpConnect(URI &uri, int ssize, int rsize) { tv.tv_usec = 0; FD_ZERO(&myset); FD_SET(csocket, &myset); - rc = select(csocket+1, NULL, &myset, NULL, &tv); + rc = select(csocket+1u, NULL, &myset, NULL, &tv); if (rc <= 0) { //} && errno != EINTR) { #ifndef WIN32 close(csocket); @@ -182,11 +182,11 @@ Peer::Peer(SOCKET s, Universe *u, Dispatcher *d) : sock_(s), can_reconnect_(fals int flags =1; if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (const char *)&flags, sizeof(flags))) { LOG(ERROR) << "ERROR: setsocketopt(), TCP_NODELAY"; }; - int a = u->getRecvBufferSize(); + int a = static_cast<int>(u->getRecvBufferSize()); if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, (const char *)&a, sizeof(int)) == -1) { fprintf(stderr, "Error setting socket opts: %s\n", strerror(errno)); } - a = u->getSendBufferSize(); + a = static_cast<int>(u->getSendBufferSize()); if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, (const char *)&a, sizeof(int)) == -1) { fprintf(stderr, "Error setting socket opts: %s\n", strerror(errno)); } @@ -434,7 +434,7 @@ void Peer::data() { return; } - int cap = recv_buf_.buffer_capacity(); + int cap = static_cast<int>(recv_buf_.buffer_capacity()); auto buf = recv_buf_.buffer(); lk.unlock(); @@ -696,7 +696,7 @@ int Peer::_send() { } DWORD bytessent; - int c = WSASend(sock_, wsabuf.data(), send_size, (LPDWORD)&bytessent, 0, NULL, NULL); + int c = WSASend(sock_, wsabuf.data(), static_cast<DWORD>(send_size), (LPDWORD)&bytessent, 0, NULL, NULL); #else int c = ftl::net::internal::writev(sock_, send_buf_.vector(), (int)send_buf_.vector_size()); #endif diff --git a/components/net/cpp/src/universe.cpp b/components/net/cpp/src/universe.cpp index 8eaff08b4..dd56ef935 100644 --- a/components/net/cpp/src/universe.cpp +++ b/components/net/cpp/src/universe.cpp @@ -183,7 +183,7 @@ int Universe::waitConnections() { return count; } -int Universe::_setDescriptors() { +SOCKET Universe::_setDescriptors() { //Reset all file descriptors FD_ZERO(&impl_->sfdread_); FD_ZERO(&impl_->sfderror_); @@ -301,7 +301,7 @@ void Universe::_run() { auto start = std::chrono::high_resolution_clock::now(); while (active_) { - int n = _setDescriptors(); + SOCKET n = _setDescriptors(); int selres = 1; // Do periodics @@ -321,7 +321,7 @@ void Universe::_run() { //Wait for a network event or timeout in 3 seconds block.tv_sec = 0; block.tv_usec = 100000; - selres = select(n+1, &impl_->sfdread_, 0, &impl_->sfderror_, &block); + selres = select(n+1u, &impl_->sfdread_, 0, &impl_->sfderror_, &block); // NOTE Nick: Is it possible that not all the recvs have been called before I // again reach a select call!? What are the consequences of this? A double recv attempt? diff --git a/components/structures/include/ftl/data/new_frame.hpp b/components/structures/include/ftl/data/new_frame.hpp index dab1a8bb2..7d779a68f 100644 --- a/components/structures/include/ftl/data/new_frame.hpp +++ b/components/structures/include/ftl/data/new_frame.hpp @@ -1,6 +1,11 @@ #ifndef _FTL_DATA_NEWFRAME_HPP_ #define _FTL_DATA_NEWFRAME_HPP_ +// Remove pointless warning +#ifdef _MSC_VER +#pragma warning(disable : 4544) +#endif + #include <map> #include <unordered_set> #include <any> -- GitLab