From 9fb7b7b51750865c6834d838c7a5b41c976da994 Mon Sep 17 00:00:00 2001 From: Wang Gao <80475837@qq.com> Date: Wed, 26 Feb 2020 09:33:41 +0800 Subject: [PATCH 1/8] fix MSVC2015 type convert --- trantor/net/InetAddress.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trantor/net/InetAddress.cc b/trantor/net/InetAddress.cc index 8eb1361b..38a67515 100644 --- a/trantor/net/InetAddress.cc +++ b/trantor/net/InetAddress.cc @@ -189,11 +189,11 @@ std::string InetAddress::toIp() const char buf[64]; if (addr_.sin_family == AF_INET) { - ::inet_ntop(AF_INET, &addr_.sin_addr, buf, sizeof(buf)); + ::inet_ntop(AF_INET, (PVOID)&addr_.sin_addr, buf, sizeof(buf)); } else if (addr_.sin_family == AF_INET6) { - ::inet_ntop(AF_INET6, &addr6_.sin6_addr, buf, sizeof(buf)); + ::inet_ntop(AF_INET6, (PVOID)&addr6_.sin6_addr, buf, sizeof(buf)); } return buf; From 238ba84a162c4124e5161e3ce2c8ebff4aed14c7 Mon Sep 17 00:00:00 2001 From: Wang Gao <80475837@qq.com> Date: Wed, 26 Feb 2020 10:09:27 +0800 Subject: [PATCH 2/8] Update InetAddress.cc --- trantor/net/InetAddress.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trantor/net/InetAddress.cc b/trantor/net/InetAddress.cc index 38a67515..6362c6d9 100644 --- a/trantor/net/InetAddress.cc +++ b/trantor/net/InetAddress.cc @@ -189,11 +189,11 @@ std::string InetAddress::toIp() const char buf[64]; if (addr_.sin_family == AF_INET) { - ::inet_ntop(AF_INET, (PVOID)&addr_.sin_addr, buf, sizeof(buf)); + ::inet_ntop(AF_INET, static_cast(&addr_.sin_addr), buf, sizeof(buf)); } else if (addr_.sin_family == AF_INET6) { - ::inet_ntop(AF_INET6, (PVOID)&addr6_.sin6_addr, buf, sizeof(buf)); + ::inet_ntop(AF_INET6, static_cast(&addr6_.sin6_addr), buf, sizeof(buf)); } return buf; From 60521b205b7baf875a151d333ce6a869a59a0fab Mon Sep 17 00:00:00 2001 From: Wang Gao <80475837@qq.com> Date: Wed, 26 Feb 2020 10:14:39 +0800 Subject: [PATCH 3/8] Update InetAddress.cc --- trantor/net/InetAddress.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trantor/net/InetAddress.cc b/trantor/net/InetAddress.cc index 6362c6d9..745a7b0e 100644 --- a/trantor/net/InetAddress.cc +++ b/trantor/net/InetAddress.cc @@ -189,11 +189,11 @@ std::string InetAddress::toIp() const char buf[64]; if (addr_.sin_family == AF_INET) { - ::inet_ntop(AF_INET, static_cast(&addr_.sin_addr), buf, sizeof(buf)); + ::inet_ntop(AF_INET, const_cast(&addr_.sin_addr), buf, sizeof(buf)); } else if (addr_.sin_family == AF_INET6) { - ::inet_ntop(AF_INET6, static_cast(&addr6_.sin6_addr), buf, sizeof(buf)); + ::inet_ntop(AF_INET6, const_cast(&addr6_.sin6_addr), buf, sizeof(buf)); } return buf; From 7b3b54195e9847ae677b0f223769b976381c7889 Mon Sep 17 00:00:00 2001 From: Wang Gao <80475837@qq.com> Date: Wed, 26 Feb 2020 10:20:02 +0800 Subject: [PATCH 4/8] Update InetAddress.cc --- trantor/net/InetAddress.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trantor/net/InetAddress.cc b/trantor/net/InetAddress.cc index 745a7b0e..c063c236 100644 --- a/trantor/net/InetAddress.cc +++ b/trantor/net/InetAddress.cc @@ -189,11 +189,11 @@ std::string InetAddress::toIp() const char buf[64]; if (addr_.sin_family == AF_INET) { - ::inet_ntop(AF_INET, const_cast(&addr_.sin_addr), buf, sizeof(buf)); + ::inet_ntop(AF_INET, (void*)&addr_.sin_addr, buf, sizeof(buf)); } else if (addr_.sin_family == AF_INET6) { - ::inet_ntop(AF_INET6, const_cast(&addr6_.sin6_addr), buf, sizeof(buf)); + ::inet_ntop(AF_INET6, (void*)&addr6_.sin6_addr, buf, sizeof(buf)); } return buf; From d37d8ce9ca958a230103469e64967c9acca910a3 Mon Sep 17 00:00:00 2001 From: Wang Gao <80475837@qq.com> Date: Wed, 26 Feb 2020 10:41:51 +0800 Subject: [PATCH 5/8] Update InetAddress.cc --- trantor/net/InetAddress.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/trantor/net/InetAddress.cc b/trantor/net/InetAddress.cc index c063c236..7ab6f3c6 100644 --- a/trantor/net/InetAddress.cc +++ b/trantor/net/InetAddress.cc @@ -187,14 +187,19 @@ bool InetAddress::isLoopbackIp() const std::string InetAddress::toIp() const { char buf[64]; - if (addr_.sin_family == AF_INET) - { - ::inet_ntop(AF_INET, (void*)&addr_.sin_addr, buf, sizeof(buf)); + #if defined _MSC_VER && _MSC_VER == 1900 + ::inet_ntop(AF_INET, (PVOID)&addr_.sin_addr, buf, sizeof(buf)); + #else + ::inet_ntop(AF_INET, &addr_.sin_addr, buf, sizeof(buf)); + #endif } else if (addr_.sin_family == AF_INET6) { - ::inet_ntop(AF_INET6, (void*)&addr6_.sin6_addr, buf, sizeof(buf)); - } + #if defined _MSC_VER && _MSC_VER == 1900 + ::inet_ntop(AF_INET6, (PVOID*)&addr6_.sin6_addr, buf, sizeof(buf)); + #else + ::inet_ntop(AF_INET6, &addr6_.sin6_addr, buf, sizeof(buf)); + #endif return buf; } From 51189d169aba1a264a26705247f7833c455372af Mon Sep 17 00:00:00 2001 From: Wang Gao <80475837@qq.com> Date: Wed, 26 Feb 2020 10:52:18 +0800 Subject: [PATCH 6/8] Update InetAddress.cc --- trantor/net/InetAddress.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trantor/net/InetAddress.cc b/trantor/net/InetAddress.cc index 7ab6f3c6..ed1e0ac6 100644 --- a/trantor/net/InetAddress.cc +++ b/trantor/net/InetAddress.cc @@ -196,7 +196,7 @@ std::string InetAddress::toIp() const else if (addr_.sin_family == AF_INET6) { #if defined _MSC_VER && _MSC_VER == 1900 - ::inet_ntop(AF_INET6, (PVOID*)&addr6_.sin6_addr, buf, sizeof(buf)); + ::inet_ntop(AF_INET6, (PVOID)&addr6_.sin6_addr, buf, sizeof(buf)); #else ::inet_ntop(AF_INET6, &addr6_.sin6_addr, buf, sizeof(buf)); #endif From 2cef09b2a7db6ed753c64084a30b749edf2d8f73 Mon Sep 17 00:00:00 2001 From: Wang Gao <80475837@qq.com> Date: Wed, 26 Feb 2020 10:53:22 +0800 Subject: [PATCH 7/8] Update InetAddress.cc --- trantor/net/InetAddress.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/trantor/net/InetAddress.cc b/trantor/net/InetAddress.cc index ed1e0ac6..0aeaaae4 100644 --- a/trantor/net/InetAddress.cc +++ b/trantor/net/InetAddress.cc @@ -187,6 +187,8 @@ bool InetAddress::isLoopbackIp() const std::string InetAddress::toIp() const { char buf[64]; + if (addr_.sin_family == AF_INET) + { #if defined _MSC_VER && _MSC_VER == 1900 ::inet_ntop(AF_INET, (PVOID)&addr_.sin_addr, buf, sizeof(buf)); #else @@ -200,6 +202,7 @@ std::string InetAddress::toIp() const #else ::inet_ntop(AF_INET6, &addr6_.sin6_addr, buf, sizeof(buf)); #endif + } return buf; } From cc5b42be3efe4f3066fa7cd57af12b506389161b Mon Sep 17 00:00:00 2001 From: antao Date: Wed, 26 Feb 2020 10:58:29 +0800 Subject: [PATCH 8/8] Format --- trantor/net/InetAddress.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/trantor/net/InetAddress.cc b/trantor/net/InetAddress.cc index 0aeaaae4..f72f2179 100644 --- a/trantor/net/InetAddress.cc +++ b/trantor/net/InetAddress.cc @@ -189,19 +189,19 @@ std::string InetAddress::toIp() const char buf[64]; if (addr_.sin_family == AF_INET) { - #if defined _MSC_VER && _MSC_VER == 1900 +#if defined _MSC_VER && _MSC_VER == 1900 ::inet_ntop(AF_INET, (PVOID)&addr_.sin_addr, buf, sizeof(buf)); - #else +#else ::inet_ntop(AF_INET, &addr_.sin_addr, buf, sizeof(buf)); - #endif +#endif } else if (addr_.sin_family == AF_INET6) { - #if defined _MSC_VER && _MSC_VER == 1900 +#if defined _MSC_VER && _MSC_VER == 1900 ::inet_ntop(AF_INET6, (PVOID)&addr6_.sin6_addr, buf, sizeof(buf)); - #else +#else ::inet_ntop(AF_INET6, &addr6_.sin6_addr, buf, sizeof(buf)); - #endif +#endif } return buf;