backport of warning related fixes

This commit is contained in:
Alden Torres 2020-01-19 23:09:44 -05:00 committed by Arvid Norberg
parent 69fe7a9ad6
commit 819eea722b
2 changed files with 16 additions and 5 deletions

View File

@ -46,22 +46,30 @@ namespace libtorrent {
TORRENT_EXTRA_EXPORT int hex_to_int(char in);
TORRENT_EXTRA_EXPORT bool is_hex(span<char const> in);
#if TORRENT_ABI_VERSION == 1
#define TORRENT_CONDITIONAL_EXPORT TORRENT_EXPORT
#else
#define TORRENT_CONDITIONAL_EXPORT TORRENT_EXTRA_EXPORT
#endif
// The overload taking a ``std::string`` converts (binary) the string ``s``
// to hexadecimal representation and returns it.
// The overload taking a ``char const*`` and a length converts the binary
// buffer [``in``, ``in`` + len) to hexadecimal and prints it to the buffer
// ``out``. The caller is responsible for making sure the buffer pointed to
// by ``out`` is large enough, i.e. has at least len * 2 bytes of space.
TORRENT_DEPRECATED_EXPORT std::string to_hex(span<char const> s);
TORRENT_DEPRECATED_EXPORT void to_hex(span<char const> in, char* out);
TORRENT_DEPRECATED_EXPORT void to_hex(char const* in, int const len, char* out);
TORRENT_CONDITIONAL_EXPORT std::string to_hex(span<char const> s);
TORRENT_CONDITIONAL_EXPORT void to_hex(span<char const> in, char* out);
TORRENT_CONDITIONAL_EXPORT void to_hex(char const* in, int const len, char* out);
// converts the buffer [``in``, ``in`` + len) from hexadecimal to
// binary. The binary output is written to the buffer pointed to
// by ``out``. The caller is responsible for making sure the buffer
// at ``out`` has enough space for the result to be written to, i.e.
// (len + 1) / 2 bytes.
TORRENT_DEPRECATED_EXPORT bool from_hex(span<char const> in, char* out);
TORRENT_CONDITIONAL_EXPORT bool from_hex(span<char const> in, char* out);
#undef TORRENT_CONDITIONAL_EXPORT
}

View File

@ -117,7 +117,10 @@ namespace {
}
else
{
ret.ti->internal_set_creation_date(rd.dict_find_int_value("creation date", 0));
// time_t might be 32 bit if we're unlucky, but there isn't
// much to do about it
ret.ti->internal_set_creation_date(static_cast<std::time_t>(
rd.dict_find_int_value("creation date", 0)));
ret.ti->internal_set_creator(rd.dict_find_string_value("created by", ""));
ret.ti->internal_set_comment(rd.dict_find_string_value("comment", ""));
}