fixed warnings and compilation issues (#980)

fixed warnings and compilation issues
This commit is contained in:
Alden Torres 2016-08-03 00:35:40 -04:00 committed by Arvid Norberg
parent 8fedfcdce6
commit fdfe69f414
14 changed files with 42 additions and 47 deletions

View File

@ -80,6 +80,7 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma clang diagnostic ignored "-Wgnu-folding-constant"
#pragma clang diagnostic ignored "-Wdouble-promotion"
#pragma clang diagnostic ignored "-Wfloat-equal"
#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
#endif
#ifdef _MSC_VER
@ -87,4 +88,3 @@ POSSIBILITY OF SUCH DAMAGE.
// warning C4005: macro redefinition
#pragma warning( disable : 4005 )
#endif

View File

@ -255,4 +255,3 @@ namespace libtorrent
}
#endif // TORRENT_BITFIELD_HPP_INCLUDED

View File

@ -167,7 +167,7 @@ POSSIBILITY OF SUCH DAMAGE.
#elif defined __linux__
#define TORRENT_LINUX
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) && !defined __ANDROID__
# define TORRENT_USE_PREADV 1
# define TORRENT_USE_PREAD 0
#else
@ -183,8 +183,6 @@ POSSIBILITY OF SUCH DAMAGE.
// ===== ANDROID ===== (almost linux, sort of)
#if defined __ANDROID__
#define TORRENT_USE_PREADV 0
#define TORRENT_USE_PREAD 1
#define TORRENT_ANDROID 1
#define TORRENT_HAS_FALLOCATE 0
#define TORRENT_USE_ICONV 0

View File

@ -46,7 +46,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/system/error_code.hpp>
#include <boost/system/system_error.hpp>
#include <boost/asio/error.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"

View File

@ -50,8 +50,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <winsock2.h>
#endif
#include <boost/version.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ip/udp.hpp>
#include <boost/asio/write.hpp>
@ -194,4 +192,3 @@ namespace libtorrent
}
#endif // TORRENT_SOCKET_HPP_INCLUDED

View File

@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/time.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/copy_ptr.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/sha1_hash.hpp"
#include "libtorrent/file_storage.hpp"

View File

@ -63,6 +63,8 @@ namespace libtorrent
#endif
#if TORRENT_UTP_LOG
TORRENT_FORMAT(1, 2)
void utp_log(char const* fmt, ...);
TORRENT_EXPORT bool is_utp_stream_logging();
// This function should be used at the very beginning and very end of your program.

View File

@ -90,7 +90,7 @@ namespace libtorrent
{
for (int i = 1; i < words + 1; ++i)
{
uint8x8_t const in_val = vld1_u8((unsigned char *) &m_buf[i]);
uint8x8_t const in_val = vld1_u8(reinterpret_cast<unsigned char*>(&m_buf[i]));
uint8x8_t const cnt8x8_val = vcnt_u8(in_val);
uint16x4_t const cnt16x4_val = vpaddl_u8(cnt8x8_val);
uint32x2_t const cnt32x2_val = vpaddl_u16(cnt16x4_val);
@ -191,4 +191,3 @@ namespace libtorrent
TORRENT_ASSERT(size() == bits);
}
}

View File

@ -159,7 +159,7 @@ namespace libtorrent { namespace
int read_len = recv(sock, buf, bufsize - msg_len, 0);
if (read_len < 0) return -1;
nl_hdr = (nlmsghdr*)buf;
nl_hdr = reinterpret_cast<nlmsghdr*>(buf);
if ((NLMSG_OK(nl_hdr, read_len) == 0) || (nl_hdr->nlmsg_type == NLMSG_ERROR))
return -1;
@ -177,7 +177,7 @@ namespace libtorrent { namespace
bool parse_route(int s, nlmsghdr* nl_hdr, ip_route* rt_info)
{
rtmsg* rt_msg = (rtmsg*)NLMSG_DATA(nl_hdr);
rtmsg* rt_msg = reinterpret_cast<rtmsg*>(NLMSG_DATA(nl_hdr));
if((rt_msg->rtm_family != AF_INET && rt_msg->rtm_family != AF_INET6) || (rt_msg->rtm_table != RT_TABLE_MAIN
&& rt_msg->rtm_table != RT_TABLE_LOCAL))
@ -185,40 +185,47 @@ namespace libtorrent { namespace
int if_index = 0;
int rt_len = RTM_PAYLOAD(nl_hdr);
for (rtattr* rt_attr = (rtattr*)RTM_RTA(rt_msg);
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-align"
#endif
for (rtattr* rt_attr = reinterpret_cast<rtattr*>(RTM_RTA(rt_msg));
RTA_OK(rt_attr,rt_len); rt_attr = RTA_NEXT(rt_attr,rt_len))
{
switch(rt_attr->rta_type)
{
case RTA_OIF:
if_index = *(int*)RTA_DATA(rt_attr);
if_index = *reinterpret_cast<int*>(RTA_DATA(rt_attr));
break;
case RTA_GATEWAY:
#if TORRENT_USE_IPV6
if (rt_msg->rtm_family == AF_INET6)
{
rt_info->gateway = inaddr6_to_address((in6_addr*)RTA_DATA(rt_attr));
rt_info->gateway = inaddr6_to_address(reinterpret_cast<in6_addr*>(RTA_DATA(rt_attr)));
}
else
#endif
{
rt_info->gateway = inaddr_to_address((in_addr*)RTA_DATA(rt_attr));
rt_info->gateway = inaddr_to_address(reinterpret_cast<in_addr*>(RTA_DATA(rt_attr)));
}
break;
case RTA_DST:
#if TORRENT_USE_IPV6
if (rt_msg->rtm_family == AF_INET6)
{
rt_info->destination = inaddr6_to_address((in6_addr*)RTA_DATA(rt_attr));
rt_info->destination = inaddr6_to_address(reinterpret_cast<in6_addr*>(RTA_DATA(rt_attr)));
}
else
#endif
{
rt_info->destination = inaddr_to_address((in_addr*)RTA_DATA(rt_attr));
rt_info->destination = inaddr_to_address(reinterpret_cast<in_addr*>(RTA_DATA(rt_attr)));
}
break;
}
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
if_indextoname(if_index, rt_info->name);
ifreq req;
@ -493,7 +500,7 @@ namespace libtorrent
// make sure the buffer is aligned to hold ifreq structs
ifreq buf[40];
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = (char*)buf;
ifc.ifc_buf = reinterpret_cast<char*>(buf);
if (ioctl(s, SIOCGIFCONF, &ifc) < 0)
{
ec = error_code(errno, system_category());
@ -501,7 +508,7 @@ namespace libtorrent
return ret;
}
char *ifr = (char*)ifc.ifc_req;
char *ifr = reinterpret_cast<char*>(ifc.ifc_req);
int remaining = ifc.ifc_len;
while (remaining > 0)
@ -1084,7 +1091,7 @@ namespace libtorrent
char msg[BUFSIZE];
memset(msg, 0, BUFSIZE);
nlmsghdr* nl_msg = (nlmsghdr*)msg;
nlmsghdr* nl_msg = reinterpret_cast<nlmsghdr*>(msg);
nl_msg->nlmsg_len = NLMSG_LENGTH(sizeof(rtmsg));
nl_msg->nlmsg_type = RTM_GETROUTE;
@ -1113,11 +1120,18 @@ namespace libtorrent
ec = error_code(errno, system_category());
return std::vector<ip_route>();
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-align"
#endif
for (; NLMSG_OK(nl_msg, len); nl_msg = NLMSG_NEXT(nl_msg, len))
{
ip_route r;
if (parse_route(s, nl_msg, &r)) ret.push_back(r);
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
close(s);
close(sock);
@ -1148,5 +1162,3 @@ namespace libtorrent
return std::string();
}
}

View File

@ -30,12 +30,9 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include <boost/version.hpp>
#include "libtorrent/config.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/string_util.hpp" // for to_string()
#include "libtorrent/aux_/escape_string.hpp" // for convert_to_native
namespace libtorrent
{
@ -332,4 +329,3 @@ namespace libtorrent
}
}

View File

@ -118,14 +118,6 @@ POSSIBILITY OF SUCH DAMAGE.
#ifdef TORRENT_LINUX
// linux specifics
#ifdef TORRENT_ANDROID
#include <sys/vfs.h>
#define statvfs statfs
#define fstatvfs fstatfs
#else
#include <sys/statvfs.h>
#endif
#include <sys/ioctl.h>
#ifdef TORRENT_ANDROID
#include <sys/syscall.h>

View File

@ -233,6 +233,7 @@ void peer_connection_handle::peer_log(peer_log_alert::direction_t direction
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
#pragma clang diagnostic ignored "-Wclass-varargs"
#endif
pc->peer_log(direction, event, fmt, v);
#ifdef __clang__

View File

@ -58,8 +58,8 @@ namespace libtorrent {
#if TORRENT_UTP_LOG
char const* packet_type_names[] = { "ST_DATA", "ST_FIN", "ST_STATE", "ST_RESET", "ST_SYN" };
char const* socket_state_names[] = { "NONE", "SYN_SENT", "CONNECTED", "FIN_SENT", "ERROR", "DELETE" };
static char const* packet_type_names[] = { "ST_DATA", "ST_FIN", "ST_STATE", "ST_RESET", "ST_SYN" };
static char const* socket_state_names[] = { "NONE", "SYN_SENT", "CONNECTED", "FIN_SENT", "ERROR", "DELETE" };
static struct utp_logger
{
@ -3266,17 +3266,17 @@ bool utp_socket_impl::incoming_packet(span<std::uint8_t const> buf
"\n"
, static_cast<void*>(this)
, sample
, float(delay / 1000.f)
, float(their_delay / 1000.f)
, float(int(m_sm->target_delay() - delay)) / 1000.f
, delay / 1000.0
, their_delay / 1000.0
, int(m_sm->target_delay() - delay) / 1000.0
, std::uint32_t(m_cwnd >> 16)
, 0
, our_delay_base
, float(delay + their_delay) / 1000.f
, (delay + their_delay) / 1000.0
, m_sm->target_delay() / 1000
, acked_bytes
, m_bytes_in_flight
, 0.f // float(scaled_gain)
, 0.0 // float(scaled_gain)
, m_rtt.mean()
, int((m_cwnd * 1000 / (m_rtt.mean()?m_rtt.mean():50)) >> 16)
, 0
@ -3485,9 +3485,9 @@ void utp_socket_impl::do_ledbat(const int acked_bytes, const int delay
UTP_LOGV("%8p: do_ledbat delay:%d off_target: %d window_factor:%f target_factor:%f "
"scaled_gain:%f cwnd:%d slow_start:%d\n"
, static_cast<void*>(this), delay, target_delay - delay, window_factor / float(1 << 16)
, delay_factor / float(1 << 16)
, scaled_gain / float(1 << 16), int(m_cwnd >> 16)
, static_cast<void*>(this), delay, target_delay - delay, window_factor / double(1 << 16)
, delay_factor / double(1 << 16)
, scaled_gain / double(1 << 16), int(m_cwnd >> 16)
, int(m_slow_start));
// if scaled_gain + m_cwnd <= 0, set m_cwnd to 0

View File

@ -30,6 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include <cstring>
#include "libtorrent/xml_parse.hpp"
#include "libtorrent/string_util.hpp"