1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Fix compilation warnings on Windows.

This commit is contained in:
Matias Fontanini
2015-04-25 18:44:38 -07:00
parent 5c8fdd2b6c
commit c108f6e4e6
9 changed files with 22 additions and 16 deletions

View File

@@ -9,8 +9,16 @@ ELSE(NOT CMAKE_BUILD_TYPE)
MESSAGE(STATUS "Using specified '${CMAKE_BUILD_TYPE}' build type.")
ENDIF(NOT CMAKE_BUILD_TYPE)
# Default compilation settings
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# Compilation flags.
IF(MSVC)
# Don't always use Wall, since VC's /Wall is ridiculously verbose.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
# Disable VC secure checks, since these are not really issues.
ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS=1")
ADD_DEFINITIONS("-D_SCL_SECURE_NO_WARNINGS=1")
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
ENDIF()
# Build output checks
OPTION(LIBTINS_BUILD_SHARED "Build libtins as a shared library." ON)
@@ -152,7 +160,7 @@ ADD_SUBDIRECTORY(examples)
IF(EXISTS "${CMAKE_SOURCE_DIR}/googletest/CMakeLists.txt")
# Enable tests and add the test directory
MESSAGE(STATUS "Tests have been enabled")
SET(gtest_force_shared_crt true)
SET(gtest_force_shared_crt ON CACHE BOOL "Always use /MD")
ENABLE_TESTING()
ADD_SUBDIRECTORY(googletest)
ADD_SUBDIRECTORY(tests)

View File

@@ -381,7 +381,6 @@ template<class ForwardIterator>
void Tins::Utils::route_entries(ForwardIterator output) {
MIB_IPFORWARDTABLE *table;
ULONG size = 0;
char iface_name[256];
GetIpForwardTable(0, &size, 0);
std::vector<uint8_t> buffer(size);
table = (MIB_IPFORWARDTABLE*)&buffer[0];

View File

@@ -201,7 +201,7 @@ DHCPv6::status_code_type DHCPv6::status_code() const {
}
bool DHCPv6::has_rapid_commit() const {
return search_option(RAPID_COMMIT);
return static_cast<bool>(search_option(RAPID_COMMIT));
}
DHCPv6::user_class_type DHCPv6::user_class() const {
@@ -225,7 +225,7 @@ uint8_t DHCPv6::reconfigure_msg() const {
}
bool DHCPv6::has_reconfigure_accept() const {
return search_option(RECONF_ACCEPT);
return static_cast<bool>(search_option(RECONF_ACCEPT));
}
DHCPv6::duid_type DHCPv6::client_id() const {

View File

@@ -87,7 +87,7 @@ uint16_t IPv4Stream::extract_offset(const IP *ip) {
}
bool IPv4Stream::extract_more_frag(const IP *ip) {
return ip->frag_off() & 0x2000;
return (ip->frag_off() & 0x2000) != 0;
}
} // namespace Internals

View File

@@ -70,11 +70,7 @@ bool OfflinePacketFilter::matches_filter(const uint8_t* buffer,
pcap_pkthdr header = {};
header.len = total_sz;
header.caplen = total_sz;
return pcap_offline_filter(
&filter,
&header,
buffer
);
return pcap_offline_filter(&filter, &header, buffer) != 0;
}
bool OfflinePacketFilter::matches_filter(PDU& pdu) const

View File

@@ -384,7 +384,7 @@ PDU *PacketSender::recv_match_loop(const std::vector<int>& sockets, PDU &pdu, st
#endif
timeout.tv_sec = _timeout;
end_time.tv_sec = time(0) + _timeout;
end_time.tv_sec = static_cast<long>(time(0) + _timeout);
end_time.tv_usec = timeout.tv_usec = _timeout_usec;
while(true) {
FD_ZERO(&readfds);

View File

@@ -178,7 +178,7 @@ void RadioTap::init() {
channel(Utils::channel_to_mhz(1), 0xa0);
flags(FCS);
tsft(0);
dbm_signal(0xce);
dbm_signal(static_cast<int8_t>(0xce));
rx_flags(0);
antenna(0);
}

View File

@@ -147,7 +147,7 @@ void TCP::sack_permitted() {
}
bool TCP::has_sack_permitted() const {
return bool(search_option(SACK_OK));
return static_cast<bool>(search_option(SACK_OK));
}
void TCP::sack(const sack_type &edges) {
@@ -286,7 +286,7 @@ void TCP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *par
buffer = write_option(*it, buffer);
if(_options_size < _total_options_size) {
uint8_t padding = _options_size;
uint16_t padding = _options_size;
while(padding < _total_options_size) {
*(buffer++) = 1;
padding++;

View File

@@ -4,6 +4,9 @@
#include "ipv6_address.h"
#include "utils.h"
// Really nice and unique macro names, Windows :D
#undef IN
using namespace Tins;