From 6896cc63469718f6f71c836384143c2d884b3ead Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Mon, 8 May 2017 21:51:27 -0700 Subject: [PATCH] Fix more build issues on appveyor --- src/ethernetII.cpp | 2 +- src/icmp.cpp | 9 +++++---- src/ip_address.cpp | 2 ++ src/ipv6_address.cpp | 2 ++ src/utils/routing_utils.cpp | 3 ++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/ethernetII.cpp b/src/ethernetII.cpp index f053f25..0c1021c 100644 --- a/src/ethernetII.cpp +++ b/src/ethernetII.cpp @@ -106,7 +106,7 @@ uint32_t EthernetII::trailer_size() const { int32_t padding = 60 - sizeof(header_); // EthernetII min size is 60, padding is sometimes needed if (inner_pdu()) { padding -= inner_pdu()->size(); - padding = std::max(0, padding); + padding = padding > 0 ? padding : 0; } return padding; } diff --git a/src/icmp.cpp b/src/icmp.cpp index 5b14f0c..6496c60 100644 --- a/src/icmp.cpp +++ b/src/icmp.cpp @@ -40,7 +40,6 @@ #include "utils/checksum_utils.h" using std::memset; -using std::max; using Tins::Memory::InputMemoryStream; using Tins::Memory::OutputMemoryStream; @@ -148,7 +147,8 @@ uint32_t ICMP::trailer_size() const { // If the next pdu size is lower than 128 bytes, then padding = 128 - pdu size // If the next pdu size is greater than 128 bytes, // then padding = pdu size padded to next 32 bit boundary - pdu size - const uint32_t upper_bound = max(get_adjusted_inner_pdu_size(), 128U); + const uint32_t adjusted_size = get_adjusted_inner_pdu_size(); + const uint32_t upper_bound = adjusted_size > 128U ? adjusted_size : 128U; output += upper_bound - inner_pdu()->size(); } } @@ -228,8 +228,9 @@ void ICMP::write_serialization(uint8_t* buffer, uint32_t total_sz) { if (length_value) { // If we have extensions, we'll have at least 128 bytes. // Otherwise, just use the length - length_value = has_extensions() ? max(length_value, 128U) - : length_value; + if (has_extensions()) { + length_value = length_value > 128U ? length_value : 128U; + } } else { length_value = 0; diff --git a/src/ip_address.cpp b/src/ip_address.cpp index fa35b2c..e2e892a 100644 --- a/src/ip_address.cpp +++ b/src/ip_address.cpp @@ -156,7 +156,9 @@ IPv4Address IPv4Address::operator&(const IPv4Address& mask) const { } // Tins +#ifdef TINS_IS_CXX11 // Hash size_t std::hash::operator()(const Tins::IPv4Address& addr) const { return std::hash()(addr); } +#endif // TINS_IS_CXX11 diff --git a/src/ipv6_address.cpp b/src/ipv6_address.cpp index 31a2474..9a3ab79 100644 --- a/src/ipv6_address.cpp +++ b/src/ipv6_address.cpp @@ -153,7 +153,9 @@ IPv6Address operator&(const IPv6Address& lhs, const IPv6Address& rhs) { } // Tins +#ifdef TINS_IS_CXX11 // Hash size_t std::hash::operator()(const Tins::IPv6Address& addr) const { return std::hash()(addr.to_string()); } +#endif // TINS_IS_CXX11 diff --git a/src/utils/routing_utils.cpp b/src/utils/routing_utils.cpp index cf9cb32..57980ac 100644 --- a/src/utils/routing_utils.cpp +++ b/src/utils/routing_utils.cpp @@ -57,6 +57,7 @@ #include #include #include "network_interface.h" +#include "exceptions.h" using std::vector; using std::string; @@ -319,7 +320,7 @@ vector route6_entries() { entry.metric = row->Metric; output.push_back(entry); } - catch (invalid_interface&) { + catch (const invalid_interface&) { } }