From e5282f8a3c7b5f743c5487bd5364ea2b0d3d0579 Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Sun, 21 Feb 2016 18:50:47 -0800 Subject: [PATCH] Fix compilation warnings --- src/packet_sender.cpp | 12 ++++++++++-- tests/src/icmpv6.cpp | 2 +- tests/src/tcp_ip.cpp | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/packet_sender.cpp b/src/packet_sender.cpp index dac8521..ecab256 100644 --- a/src/packet_sender.cpp +++ b/src/packet_sender.cpp @@ -483,9 +483,17 @@ PDU* PacketSender::recv_match_loop(const vector& sockets, if (now > end) { return 0; } + // VC complains if we don't statically cast here + #ifdef _WIN32 + typedef long tv_sec_type; + typedef long tv_usec_type; + #else + typedef time_t tv_sec_type; + typedef long tv_usec_type; + #endif microseconds diff = end - now; - timeout.tv_sec = duration_cast(diff).count(); - timeout.tv_usec = (diff - seconds(timeout.tv_sec)).count(); + timeout.tv_sec = static_cast(duration_cast(diff).count()); + timeout.tv_usec = static_cast((diff - seconds(timeout.tv_sec)).count()); #else #ifdef _WIN32 // Can't do much diff --git a/tests/src/icmpv6.cpp b/tests/src/icmpv6.cpp index bf8298b..e2d5564 100644 --- a/tests/src/icmpv6.cpp +++ b/tests/src/icmpv6.cpp @@ -581,7 +581,7 @@ TEST_F(ICMPv6Test, MLD2Fields) { icmp.multicast_address_records(records); ICMPv6::multicast_address_records_list stored_records; stored_records = icmp.multicast_address_records(); - ASSERT_EQ(1, stored_records.size()); + ASSERT_EQ(1U, stored_records.size()); ICMPv6::multicast_address_record r2 = *stored_records.begin(); EXPECT_EQ(r.type, r2.type); diff --git a/tests/src/tcp_ip.cpp b/tests/src/tcp_ip.cpp index 5d76ae3..6ef1071 100644 --- a/tests/src/tcp_ip.cpp +++ b/tests/src/tcp_ip.cpp @@ -346,7 +346,7 @@ TEST_F(FlowTest, StreamFollower_ThreeWayHandshake) { if (i != 0) { ts += milliseconds(100); } - Packet packet(packets[i], ts); + Packet packet(packets[i], duration_cast(ts)); follower.process_packet(packet); } Stream& stream = follower.find_stream(IPv4Address("1.2.3.4"), 22,