more sign warnings fixes (#1775)

more sign warnings fixes
This commit is contained in:
Alden Torres 2017-03-09 07:46:52 -05:00 committed by Arvid Norberg
parent 6929d051f1
commit a8b10a7449
7 changed files with 23 additions and 25 deletions

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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
{

View File

@ -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<rtattr*>(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)
{

View File

@ -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());

View File

@ -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
}
}