fixed more warnings of shorten-64-to-32 and sign-compare in android (#1425)

fixed more warnings of -Wshorten-64-to-32 in android. changed file_status to use std::time and disable warnings of NLMSG_OK in clang
This commit is contained in:
Alden Torres 2016-12-18 10:59:41 -05:00 committed by Arvid Norberg
parent 10e3847b40
commit eaf99aa42b
6 changed files with 24 additions and 13 deletions

View File

@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <memory> #include <memory>
#include <string> #include <string>
#include <functional> #include <functional>
#include <ctime>
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/string_view.hpp" #include "libtorrent/string_view.hpp"
@ -94,9 +95,9 @@ namespace libtorrent
struct file_status struct file_status
{ {
std::int64_t file_size; std::int64_t file_size;
std::uint64_t atime; std::time_t atime;
std::uint64_t mtime; std::time_t mtime;
std::uint64_t ctime; std::time_t ctime;
enum { enum {
#if defined TORRENT_WINDOWS #if defined TORRENT_WINDOWS
fifo = 0x1000, // named pipe (fifo) fifo = 0x1000, // named pipe (fifo)

View File

@ -129,8 +129,8 @@ namespace libtorrent
string_view filename() const; string_view filename() const;
enum { enum {
name_is_owned = (1<<12)-1, name_is_owned = (1 << 12) - 1,
not_a_symlink = (1<<15)-1 not_a_symlink = (1 << 15) - 1
}; };
// the offset of this file inside the torrent // the offset of this file inside the torrent
@ -283,7 +283,7 @@ namespace libtorrent
void add_file_borrow(char const* filename, int filename_len void add_file_borrow(char const* filename, int filename_len
, std::string const& path, std::int64_t file_size , std::string const& path, std::int64_t file_size
, std::uint32_t file_flags = 0, char const* filehash = 0 , std::uint32_t file_flags = 0, char const* filehash = 0
, std::int64_t mtime = 0, string_view symlink_path = string_view()); , std::time_t mtime = 0, string_view symlink_path = string_view());
void add_file(std::string const& path, std::int64_t file_size, int file_flags = 0 void add_file(std::string const& path, std::int64_t file_size, int file_flags = 0
, std::time_t mtime = 0, string_view symlink_path = string_view()); , std::time_t mtime = 0, string_view symlink_path = string_view());

View File

@ -158,13 +158,21 @@ namespace libtorrent { namespace
do do
{ {
int read_len = recv(sock, buf, bufsize - msg_len, 0); int read_len = int(recv(sock, buf, bufsize - msg_len, 0));
if (read_len < 0) return -1; if (read_len < 0) return -1;
nl_hdr = reinterpret_cast<nlmsghdr*>(buf); nl_hdr = reinterpret_cast<nlmsghdr*>(buf);
#ifdef __clang__
#pragma clang diagnostic push
// NLMSG_OK uses signed/unsigned compare in the same expression
#pragma clang diagnostic ignored "-Wsign-compare"
#endif
if ((NLMSG_OK(nl_hdr, read_len) == 0) || (nl_hdr->nlmsg_type == NLMSG_ERROR)) if ((NLMSG_OK(nl_hdr, read_len) == 0) || (nl_hdr->nlmsg_type == NLMSG_ERROR))
return -1; return -1;
#ifdef __clang__
#pragma clang diagnostic pop
#endif
if (nl_hdr->nlmsg_type == NLMSG_DONE) break; if (nl_hdr->nlmsg_type == NLMSG_DONE) break;
@ -1120,6 +1128,8 @@ namespace libtorrent
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wcast-align" #pragma clang diagnostic ignored "-Wcast-align"
// NLMSG_OK uses signed/unsigned compare in the same expression
#pragma clang diagnostic ignored "-Wsign-compare"
#endif #endif
for (; NLMSG_OK(nl_msg, len); nl_msg = NLMSG_NEXT(nl_msg, len)) for (; NLMSG_OK(nl_msg, len); nl_msg = NLMSG_NEXT(nl_msg, len))
{ {

View File

@ -662,14 +662,14 @@ namespace libtorrent
char buffer[4096]; char buffer[4096];
for (;;) for (;;)
{ {
int const num_read = read(infd, buffer, sizeof(buffer)); int const num_read = int(read(infd, buffer, sizeof(buffer)));
if (num_read == 0) break; if (num_read == 0) break;
if (num_read < 0) if (num_read < 0)
{ {
ec.assign(errno, system_category()); ec.assign(errno, system_category());
break; break;
} }
int const num_written = write(outfd, buffer, num_read); int const num_written = int(write(outfd, buffer, num_read));
if (num_written < num_read) if (num_written < num_read)
{ {
ec.assign(errno, system_category()); ec.assign(errno, system_category());

View File

@ -549,7 +549,7 @@ namespace libtorrent
void file_storage::add_file_borrow(char const* filename, int const filename_len void file_storage::add_file_borrow(char const* filename, int const filename_len
, std::string const& path, std::int64_t const file_size , std::string const& path, std::int64_t const file_size
, std::uint32_t const file_flags, char const* filehash , std::uint32_t const file_flags, char const* filehash
, std::int64_t const mtime, string_view symlink_path) , std::time_t const mtime, string_view symlink_path)
{ {
TORRENT_ASSERT_PRECOND(file_size >= 0); TORRENT_ASSERT_PRECOND(file_size >= 0);
if (!has_parent_path(path)) if (!has_parent_path(path))

View File

@ -117,7 +117,7 @@ namespace libtorrent
ret.finished_time = int(rd.dict_find_int_value("finished_time")); ret.finished_time = int(rd.dict_find_int_value("finished_time"));
ret.seeding_time = int(rd.dict_find_int_value("seeding_time")); ret.seeding_time = int(rd.dict_find_int_value("seeding_time"));
ret.last_seen_complete = rd.dict_find_int_value("last_seen_complete"); ret.last_seen_complete = std::time_t(rd.dict_find_int_value("last_seen_complete"));
// scrape data cache // scrape data cache
ret.num_complete = int(rd.dict_find_int_value("num_complete", -1)); ret.num_complete = int(rd.dict_find_int_value("num_complete", -1));
@ -156,8 +156,8 @@ namespace libtorrent
} }
} }
ret.added_time = rd.dict_find_int_value("added_time", 0); ret.added_time = std::time_t(rd.dict_find_int_value("added_time", 0));
ret.completed_time = rd.dict_find_int_value("completed_time", 0); ret.completed_time = std::time_t(rd.dict_find_int_value("completed_time", 0));
// load file priorities except if the add_torrent_param file was set to // load file priorities except if the add_torrent_param file was set to
// override resume data // override resume data