From aa3870848a248eebd4df71720f39232e13f3f813 Mon Sep 17 00:00:00 2001 From: Severin Leonhardt Date: Fri, 16 Jun 2023 14:33:28 +0200 Subject: [PATCH 1/3] Use inet_pton instead of inet_addr Compiling with MSVC produces the following warning: warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings Instead of just ignoring the deprecation warnings replacing `inet_addr` is straight-forward here. `inet_pton` works well as a cross-platform alternative. The difference in parsing[^1] are acceptable since this is only used in test code where it won't lead to a chance in behavior since the only used value is a fixed string of "127.0.0.1" in `bridge.cpp`. [^1]: https://man7.org/linux/man-pages/man3/inet_pton.3.html#NOTES --- tests/src/integration/ccm/tsocket.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/src/integration/ccm/tsocket.cpp b/tests/src/integration/ccm/tsocket.cpp index b61e0045f..6bd29618c 100644 --- a/tests/src/integration/ccm/tsocket.cpp +++ b/tests/src/integration/ccm/tsocket.cpp @@ -18,7 +18,9 @@ #include -#ifndef _WIN32 +#ifdef _WIN32 +#include +#else #include #include #include @@ -125,7 +127,7 @@ void Socket::establish_connection(const std::string& ip_address, unsigned short struct sockaddr_in ipv4_socket_address; ipv4_socket_address.sin_family = AF_INET; ipv4_socket_address.sin_port = htons(port); - ipv4_socket_address.sin_addr.s_addr = inet_addr(ip_address.c_str()); + inet_pton(AF_INET, ip_address.c_str(), &ipv4_socket_address.sin_addr.s_addr); if (connect(handle_, (struct sockaddr*)(&ipv4_socket_address), sizeof(struct sockaddr_in)) != 0) { std::string message = "Failed to Establish Connection: "; #ifdef _WIN32 From 105c5698a3f34ac00b92a1795e8b743707ebcb16 Mon Sep 17 00:00:00 2001 From: Severin Leonhardt Date: Fri, 16 Jun 2023 14:51:16 +0200 Subject: [PATCH 2/3] Fix signed/unsigned mismatch Compiling the code with a higher warning level than the default gives the following warning from MSVC: warning C4245: 'argument': conversion from 'long' to 'uint64_t', signed/unsigned mismatch Indeed `long` is signed while `uint64_t` is unsigned. Casting to the right data type gives the same result but fixes the warning. --- tests/src/unit/tests/test_serialization.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/unit/tests/test_serialization.cpp b/tests/src/unit/tests/test_serialization.cpp index baac718bb..d4c0be12d 100644 --- a/tests/src/unit/tests/test_serialization.cpp +++ b/tests/src/unit/tests/test_serialization.cpp @@ -21,7 +21,7 @@ using namespace datastax::internal; -TEST(SerializationTest, DecodeZigZag) { ASSERT_EQ(1LL << 63, decode_zig_zag((long)-1)); } +TEST(SerializationTest, DecodeZigZag) { ASSERT_EQ(1LL << 63, decode_zig_zag((uint64_t)-1)); } TEST(SerializationTest, DecodeByte) { const signed char input[2] = { -1, 0 }; From c77df6c0dac306288d5c8227fcdad9eb01e48927 Mon Sep 17 00:00:00 2001 From: Severin Leonhardt Date: Fri, 16 Jun 2023 16:01:09 +0200 Subject: [PATCH 3/3] Suppress expected deprecation warning In the tests `cass_retry_policy_downgrading_consistency_new` is called intentionally, even though it's marked as deprecated. Ignore that warning on MSVC. --- tests/src/integration/objects/retry_policy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/src/integration/objects/retry_policy.cpp b/tests/src/integration/objects/retry_policy.cpp index cde330172..58b76cfa9 100644 --- a/tests/src/integration/objects/retry_policy.cpp +++ b/tests/src/integration/objects/retry_policy.cpp @@ -16,6 +16,10 @@ #include "retry_policy.hpp" +#if defined(_MSC_VER) +#pragma warning(disable : 4996) +#endif + using namespace test::driver; DowngradingConsistencyRetryPolicy::DowngradingConsistencyRetryPolicy()