From a8b10a744927b63a7e0b726908c48db2cbe8a827 Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Thu, 9 Mar 2017 07:46:52 -0500 Subject: [PATCH] more sign warnings fixes (#1775) more sign warnings fixes --- include/libtorrent/file.hpp | 10 +++++----- include/libtorrent/platform_util.hpp | 3 +-- src/allocator.cpp | 6 +++--- src/disk_buffer_pool.cpp | 2 +- src/enum_net.cpp | 10 +++++----- src/file.cpp | 2 +- src/platform_util.cpp | 15 +++++++-------- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index 742a9b25e..07b6e08c5 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -94,10 +94,10 @@ namespace libtorrent struct file_status { - std::int64_t file_size; - std::uint64_t atime; - std::uint64_t mtime; - std::uint64_t ctime; + std::int64_t file_size = 0; + std::uint64_t atime = 0; + std::uint64_t mtime = 0; + std::uint64_t ctime = 0; enum { #if defined TORRENT_WINDOWS fifo = 0x1000, // named pipe (fifo) @@ -114,7 +114,7 @@ namespace libtorrent socket = 0140000 // socket #endif } modes_t; - int mode; + int mode = 0; }; // internal flags for stat_file diff --git a/include/libtorrent/platform_util.hpp b/include/libtorrent/platform_util.hpp index 860096f6e..d7dc72842 100644 --- a/include/libtorrent/platform_util.hpp +++ b/include/libtorrent/platform_util.hpp @@ -7,8 +7,7 @@ namespace libtorrent { int max_open_files(); - std::uint64_t total_physical_ram(); + std::int64_t total_physical_ram(); } #endif // TORRENT_PLATFORM_UTIL_HPP - diff --git a/src/allocator.cpp b/src/allocator.cpp index 7445c3fc4..e1ce6aaba 100644 --- a/src/allocator.cpp +++ b/src/allocator.cpp @@ -114,12 +114,12 @@ namespace libtorrent void* ret; #if TORRENT_USE_POSIX_MEMALIGN - if (posix_memalign(&ret, page_size(), bytes) + if (posix_memalign(&ret, std::size_t(page_size()), std::size_t(bytes)) != 0) ret = nullptr; #elif TORRENT_USE_MEMALIGN - ret = memalign(page_size(), bytes); + ret = memalign(std::size_t(page_size()), std::size_t(bytes)); #elif defined TORRENT_WINDOWS - ret = _aligned_malloc(bytes, page_size()); + ret = _aligned_malloc(std::size_t(bytes), std::size_t(page_size())); #elif defined TORRENT_BEOS area_id id = create_area("", &ret, B_ANY_ADDRESS , (bytes + page_size() - 1) & (page_size() - 1), B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index f1eb9bf5d..ec505eab9 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -337,7 +337,7 @@ namespace libtorrent int const cache_size = sett.get_int(settings_pack::cache_size); if (cache_size < 0) { - std::uint64_t phys_ram = total_physical_ram(); + std::int64_t phys_ram = total_physical_ram(); if (phys_ram == 0) m_max_use = 1024; else { diff --git a/src/enum_net.cpp b/src/enum_net.cpp index 75a268e13..1b5ee50a3 100644 --- a/src/enum_net.cpp +++ b/src/enum_net.cpp @@ -204,13 +204,13 @@ namespace libtorrent { namespace return false; int if_index = 0; - int rt_len = RTM_PAYLOAD(nl_hdr); + int rt_len = int(RTM_PAYLOAD(nl_hdr)); #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wcast-align" #endif for (rtattr* rt_attr = reinterpret_cast(RTM_RTA(rt_msg)); - RTA_OK(rt_attr,rt_len); rt_attr = RTA_NEXT(rt_attr,rt_len)) + RTA_OK(rt_attr, rt_len); rt_attr = RTA_NEXT(rt_attr, rt_len)) { switch(rt_attr->rta_type) { @@ -247,9 +247,9 @@ namespace libtorrent { namespace #pragma clang diagnostic pop #endif - if_indextoname(if_index, rt_info->name); + if_indextoname(std::uint32_t(if_index), rt_info->name); ifreq req = {}; - if_indextoname(if_index, req.ifr_name); + if_indextoname(std::uint32_t(if_index), req.ifr_name); ioctl(s, siocgifmtu, &req); rt_info->mtu = req.ifr_mtu; // obviously this doesn't work correctly. How do you get the netmask for a route? @@ -1053,7 +1053,7 @@ namespace libtorrent nl_msg->nlmsg_type = RTM_GETROUTE; nl_msg->nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST; nl_msg->nlmsg_seq = seq++; - nl_msg->nlmsg_pid = getpid(); + nl_msg->nlmsg_pid = std::uint32_t(getpid()); if (send(sock, nl_msg, nl_msg->nlmsg_len, 0) < 0) { diff --git a/src/file.cpp b/src/file.cpp index 3ecf8f3c5..2f4dda78f 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -675,7 +675,7 @@ namespace libtorrent ec.assign(errno, system_category()); break; } - int const num_written = int(write(outfd, buffer, num_read)); + int const num_written = int(write(outfd, buffer, std::size_t(num_read))); if (num_written < num_read) { ec.assign(errno, system_category()); diff --git a/src/platform_util.cpp b/src/platform_util.cpp index 014d4ebda..32400295c 100644 --- a/src/platform_util.cpp +++ b/src/platform_util.cpp @@ -86,16 +86,16 @@ namespace libtorrent #endif } - std::uint64_t total_physical_ram() + std::int64_t total_physical_ram() { #if defined TORRENT_BUILD_SIMULATOR - return std::uint64_t(4) * 1024 * 1024 * 1024; + return std::int64_t(4) * 1024 * 1024 * 1024; #else // figure out how much physical RAM there is in // this machine. This is used for automatically // sizing the disk cache size when it's set to // automatic. - std::uint64_t ret = 0; + std::int64_t ret = 0; #ifdef TORRENT_BSD #ifdef HW_MEMSIZE @@ -106,14 +106,14 @@ namespace libtorrent // than not building int mib[2] = { CTL_HW, HW_PHYSMEM }; #endif - size_t len = sizeof(ret); + std::size_t len = sizeof(ret); if (sysctl(mib, 2, &ret, &len, nullptr, 0) != 0) ret = 0; #elif defined TORRENT_WINDOWS MEMORYSTATUSEX ms; ms.dwLength = sizeof(MEMORYSTATUSEX); if (GlobalMemoryStatusEx(&ms)) - ret = ms.ullTotalPhys; + ret = int(ms.ullTotalPhys); else ret = 0; #elif defined TORRENT_LINUX @@ -129,8 +129,8 @@ namespace libtorrent struct rlimit r; if (getrlimit(rlimit_as, &r) == 0 && r.rlim_cur != rlim_infinity) { - if (ret > r.rlim_cur) - ret = r.rlim_cur; + if (ret > std::int64_t(r.rlim_cur)) + ret = std::int64_t(r.rlim_cur); } } #endif @@ -138,4 +138,3 @@ namespace libtorrent #endif // TORRENT_BUILD_SIMULATOR } } -