Added -Wconversion support for C++.

This commit is contained in:
Takatoshi Kondo
2019-03-20 17:35:00 +09:00
parent b759f5bdf7
commit 17267ed475
65 changed files with 498 additions and 219 deletions

View File

@@ -55,7 +55,7 @@ class zone {
++m_tail;
}
void push_expand(void (*func)(void*), void* data) {
const size_t nused = m_end - m_array;
const size_t nused = static_cast<size_t>(m_end - m_array);
size_t nnext;
if(nused == 0) {
nnext = (sizeof(finalizer) < 72/2) ?
@@ -201,12 +201,12 @@ inline char* zone::get_aligned(char* ptr, size_t align)
inline void* zone::allocate_align(size_t size, size_t align)
{
char* aligned = get_aligned(m_chunk_list.m_ptr, align);
size_t adjusted_size = size + (aligned - m_chunk_list.m_ptr);
size_t adjusted_size = size + static_cast<size_t>(aligned - m_chunk_list.m_ptr);
if (m_chunk_list.m_free < adjusted_size) {
size_t enough_size = size + align - 1;
char* ptr = allocate_expand(enough_size);
aligned = get_aligned(ptr, align);
adjusted_size = size + (aligned - m_chunk_list.m_ptr);
adjusted_size = size + static_cast<size_t>(aligned - m_chunk_list.m_ptr);
}
m_chunk_list.m_free -= adjusted_size;
m_chunk_list.m_ptr += adjusted_size;

View File

@@ -838,31 +838,31 @@ msgpack_pack_inline_func(_ext)(msgpack_pack_user x, size_t l, int8_t type)
case 1: {
unsigned char buf[2];
buf[0] = 0xd4;
buf[1] = type;
buf[1] = (unsigned char)type;
msgpack_pack_append_buffer(x, buf, 2);
} break;
case 2: {
unsigned char buf[2];
buf[0] = 0xd5;
buf[1] = type;
buf[1] = (unsigned char)type;
msgpack_pack_append_buffer(x, buf, 2);
} break;
case 4: {
unsigned char buf[2];
buf[0] = 0xd6;
buf[1] = type;
buf[1] = (unsigned char)type;
msgpack_pack_append_buffer(x, buf, 2);
} break;
case 8: {
unsigned char buf[2];
buf[0] = 0xd7;
buf[1] = type;
buf[1] = (unsigned char)type;
msgpack_pack_append_buffer(x, buf, 2);
} break;
case 16: {
unsigned char buf[2];
buf[0] = 0xd8;
buf[1] = type;
buf[1] = (unsigned char)type;
msgpack_pack_append_buffer(x, buf, 2);
} break;
default:
@@ -870,19 +870,19 @@ msgpack_pack_inline_func(_ext)(msgpack_pack_user x, size_t l, int8_t type)
unsigned char buf[3];
buf[0] = 0xc7;
buf[1] = (unsigned char)l;
buf[2] = type;
buf[2] = (unsigned char)type;
msgpack_pack_append_buffer(x, buf, 3);
} else if(l < 65536) {
unsigned char buf[4];
buf[0] = 0xc8;
_msgpack_store16(&buf[1], l);
buf[3] = type;
buf[3] = (unsigned char)type;
msgpack_pack_append_buffer(x, buf, 4);
} else {
unsigned char buf[6];
buf[0] = 0xc9;
_msgpack_store32(&buf[1], l);
buf[5] = type;
buf[5] = (unsigned char)type;
msgpack_pack_append_buffer(x, buf, 6);
}
break;
@@ -897,7 +897,7 @@ msgpack_pack_inline_func(_ext_body)(msgpack_pack_user x, const void* b, size_t l
msgpack_pack_inline_func(_timestamp)(msgpack_pack_user x, const msgpack_timestamp* d)
{
if ((((int64_t)d->tv_sec) >> 34) == 0) {
uint64_t data64 = ((uint64_t) d->tv_nsec << 34) | d->tv_sec;
uint64_t data64 = ((uint64_t) d->tv_nsec << 34) | (uint64_t)d->tv_sec;
if ((data64 & 0xffffffff00000000L) == 0) {
// timestamp 32
char buf[4];

View File

@@ -95,7 +95,7 @@
#if MSGPACK_ENDIAN_LITTLE_BYTE
# if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
# define _msgpack_be16(x) ntohs(x)
# define _msgpack_be16(x) ntohs((uint16_t)x)
# else
# if defined(ntohs)
# define _msgpack_be16(x) ntohs(x)
@@ -109,7 +109,7 @@
# endif
# if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__)
# define _msgpack_be32(x) ntohl(x)
# define _msgpack_be32(x) ntohl((uint32_t)x)
# else
# if defined(ntohl)
# define _msgpack_be32(x) ntohl(x)
@@ -154,16 +154,16 @@
#define _msgpack_load16(cast, from, to) do { \
memcpy((cast*)(to), (from), sizeof(cast)); \
*(to) = _msgpack_be16(*(to)); \
*(to) = (cast)_msgpack_be16(*(to)); \
} while (0);
#define _msgpack_load32(cast, from, to) do { \
memcpy((cast*)(to), (from), sizeof(cast)); \
*(to) = _msgpack_be32(*(to)); \
*(to) = (cast)_msgpack_be32(*(to)); \
} while (0);
#define _msgpack_load64(cast, from, to) do { \
memcpy((cast*)(to), (from), sizeof(cast)); \
*(to) = _msgpack_be64(*(to)); \
*(to) = (cast)_msgpack_be64(*(to)); \
} while (0);
#define _msgpack_store16(to, num) \

View File

@@ -53,7 +53,7 @@ inline void check_container_size_for_ext<4>(std::size_t size) {
template <typename T>
inline uint32_t checked_get_container_size(T size) {
detail::check_container_size<sizeof(T)>(size);
detail::check_container_size<sizeof(T)>(static_cast<std::size_t>(size));
return static_cast<uint32_t>(size);
}

View File

@@ -122,7 +122,7 @@ struct pack<std::chrono::system_clock::time_point> {
* std::chrono::system_clock::duration::period::ratio::num
/ std::chrono::system_clock::duration::period::ratio::den;
if ((sec >> 34) == 0) {
uint64_t data64 = (nanosec << 34) | sec;
uint64_t data64 = (static_cast<uint64_t>(nanosec) << 34) | static_cast<uint64_t>(sec);
if ((data64 & 0xffffffff00000000L) == 0) {
// timestamp 32
o.pack_ext(4, -1);
@@ -170,13 +170,13 @@ struct object_with_zone<std::chrono::system_clock::time_point> {
* std::chrono::system_clock::duration::period::ratio::num
/ std::chrono::system_clock::duration::period::ratio::den;
if ((sec >> 34) == 0) {
uint64_t data64 = (nanosec << 34) | sec;
uint64_t data64 = (static_cast<uint64_t>(nanosec) << 34) | static_cast<uint64_t>(sec);
if ((data64 & 0xffffffff00000000L) == 0) {
// timestamp 32
o.type = msgpack::type::EXT;
o.via.ext.size = 4;
char* p = static_cast<char*>(o.zone.allocate_no_align(o.via.ext.size + 1));
p[0] = -1;
p[0] = static_cast<char>(-1);
uint32_t data32 = static_cast<uint32_t>(data64);
_msgpack_store32(&p[1], data32);
o.via.ext.ptr = p;
@@ -186,7 +186,7 @@ struct object_with_zone<std::chrono::system_clock::time_point> {
o.type = msgpack::type::EXT;
o.via.ext.size = 8;
char* p = static_cast<char*>(o.zone.allocate_no_align(o.via.ext.size + 1));
p[0] = -1;
p[0] = static_cast<char>(-1);
_msgpack_store64(&p[1], data64);
o.via.ext.ptr = p;
}
@@ -196,7 +196,7 @@ struct object_with_zone<std::chrono::system_clock::time_point> {
o.type = msgpack::type::EXT;
o.via.ext.size = 12;
char* p = static_cast<char*>(o.zone.allocate_no_align(o.via.ext.size + 1));
p[0] = -1;
p[0] = static_cast<char>(-1);
_msgpack_store32(&p[1], static_cast<uint32_t>(nanosec));
_msgpack_store64(&p[1 + 4], sec);
o.via.ext.ptr = p;

View File

@@ -178,7 +178,7 @@ inline ext::ext(ext_ref const& x) {
// size limit has already been checked at ext_ref's constructor
m_data.reserve(x.size() + 1);
m_data.push_back(x.type());
m_data.push_back(static_cast<char>(x.type()));
m_data.insert(m_data.end(), x.data(), x.data() + x.size());
}

View File

@@ -22,6 +22,7 @@ namespace type {
template <typename T>
struct fix_int {
typedef T value_type;
fix_int() : value(0) { }
fix_int(T value) : value(value) { }
@@ -152,7 +153,7 @@ struct object<type::fix_int8> {
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v.get();
o.via.u64 = static_cast<uint64_t>(v.get());
}
}
};
@@ -166,7 +167,7 @@ struct object<type::fix_int16> {
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v.get();
o.via.u64 = static_cast<uint64_t>(v.get());
}
}
};
@@ -180,7 +181,7 @@ struct object<type::fix_int32> {
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v.get();
o.via.u64 = static_cast<uint64_t>(v.get());
}
}
};
@@ -194,7 +195,7 @@ struct object<type::fix_int64> {
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v.get();
o.via.u64 = static_cast<uint64_t>(v.get());
}
}
};

View File

@@ -73,7 +73,7 @@ struct object_sign<true> {
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v;
o.via.u64 = static_cast<uint64_t>(v);
}
}
};
@@ -278,7 +278,7 @@ struct object<signed char> {
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v;
o.via.u64 = static_cast<uint64_t>(v);
}
}
};
@@ -292,7 +292,7 @@ struct object<signed short> {
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v;
o.via.u64 = static_cast<uint64_t>(v);
}
}
};
@@ -306,7 +306,7 @@ struct object<signed int> {
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v;
o.via.u64 = static_cast<uint64_t>(v);
}
}
};
@@ -320,7 +320,7 @@ struct object<signed long> {
}
else {
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v;
o.via.u64 = static_cast<uint64_t>(v);
}
}
};
@@ -334,7 +334,7 @@ struct object<signed long long> {
}
else{
o.type = msgpack::type::POSITIVE_INTEGER;
o.via.u64 = v;
o.via.u64 = static_cast<uint64_t>(v);
}
}
};

View File

@@ -55,7 +55,7 @@ class zone {
++m_tail;
}
void push_expand(void (*func)(void*), void* data) {
const size_t nused = m_end - m_array;
const size_t nused = static_cast<size_t>(m_end - m_array);
size_t nnext;
if(nused == 0) {
nnext = (sizeof(finalizer) < 72/2) ?
@@ -246,12 +246,12 @@ inline char* zone::get_aligned(char* ptr, size_t align)
inline void* zone::allocate_align(size_t size, size_t align)
{
char* aligned = get_aligned(m_chunk_list.m_ptr, align);
size_t adjusted_size = size + (aligned - m_chunk_list.m_ptr);
size_t adjusted_size = size + static_cast<size_t>(aligned - m_chunk_list.m_ptr);
if (m_chunk_list.m_free < adjusted_size) {
size_t enough_size = size + align - 1;
char* ptr = allocate_expand(enough_size);
aligned = get_aligned(ptr, align);
adjusted_size = size + (aligned - m_chunk_list.m_ptr);
adjusted_size = size + static_cast<size_t>(aligned - m_chunk_list.m_ptr);
}
m_chunk_list.m_free -= adjusted_size;
m_chunk_list.m_ptr += adjusted_size;

View File

@@ -61,7 +61,7 @@ private:
++m_tail;
}
void push_expand(void (*func)(void*), void* data) {
const size_t nused = m_end - m_array;
const size_t nused = static_cast<size_t>(m_end - m_array);
size_t nnext;
if(nused == 0) {
nnext = (sizeof(finalizer) < 72/2) ?
@@ -239,12 +239,12 @@ inline char* zone::get_aligned(char* ptr, size_t align)
inline void* zone::allocate_align(size_t size, size_t align)
{
char* aligned = get_aligned(m_chunk_list.m_ptr, align);
size_t adjusted_size = size + (aligned - m_chunk_list.m_ptr);
size_t adjusted_size = size + static_cast<size_t>(aligned - m_chunk_list.m_ptr);
if (m_chunk_list.m_free < adjusted_size) {
size_t enough_size = size + align - 1;
char* ptr = allocate_expand(enough_size);
aligned = get_aligned(ptr, align);
adjusted_size = size + (aligned - m_chunk_list.m_ptr);
adjusted_size = size + static_cast<size_t>(aligned - m_chunk_list.m_ptr);
}
m_chunk_list.m_free -= adjusted_size;
m_chunk_list.m_ptr += adjusted_size;

View File

@@ -352,7 +352,7 @@ struct object_pack_visitor {
return true;
}
bool visit_ext(const char* v, uint32_t size) {
m_packer.pack_ext(size - 1, *v);
m_packer.pack_ext(size - 1, static_cast<int8_t>(*v));
m_packer.pack_ext_body(v + 1, size - 1);
return true;
}
@@ -467,7 +467,7 @@ struct object_stringize_visitor {
return true;
}
bool visit_bin(const char* v, uint32_t size) {
(m_os << '"').write(v, size) << '"';
(m_os << '"').write(v, static_cast<std::streamsize>(size)) << '"';
return true;
}
bool visit_ext(const char* /*v*/, uint32_t /*size*/) {

View File

@@ -40,7 +40,7 @@ struct object_bin {
};
struct object_ext {
int8_t type() const { return ptr[0]; }
int8_t type() const { return static_cast<int8_t>(ptr[0]); }
const char* data() const { return &ptr[1]; }
uint32_t size;
const char* ptr;

View File

@@ -16,6 +16,7 @@
#include <limits>
#include <cstring>
#include <climits>
#include <ostream>
namespace msgpack {
@@ -618,7 +619,33 @@ private:
void pack_imp_int64(T d);
void append_buffer(const char* buf, size_t len)
{ m_stream.write(buf, len); }
{
append_buffer(m_stream, &Stream::write, buf, len);
}
template <typename S, typename Write>
typename enable_if<
is_same<
std::ostream& (std::ostream::*)(const char*, std::streamsize),
Write
>::value
>::type
append_buffer(S& s, Write, const char* buf, size_t len)
{
s.write(buf, static_cast<std::streamsize>(len));
}
template <typename S, typename Write>
typename enable_if<
!is_same<
std::ostream& (std::ostream::*)(const char*, std::streamsize),
Write
>::value
>::type
append_buffer(S& s, Write, const char* buf, size_t len)
{
s.write(buf, len);
}
private:
Stream& m_stream;
@@ -795,7 +822,7 @@ template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_fix_int16(int16_t d)
{
char buf[3];
buf[0] = static_cast<char>(0xd1u); _msgpack_store16(&buf[1], d);
buf[0] = static_cast<char>(0xd1u); _msgpack_store16(&buf[1], (uint16_t)d);
append_buffer(buf, 3);
return *this;
}
@@ -804,7 +831,7 @@ template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_fix_int32(int32_t d)
{
char buf[5];
buf[0] = static_cast<char>(0xd2u); _msgpack_store32(&buf[1], d);
buf[0] = static_cast<char>(0xd2u); _msgpack_store32(&buf[1], (uint32_t)d);
append_buffer(buf, 5);
return *this;
}
@@ -1228,7 +1255,7 @@ inline packer<Stream>& packer<Stream>::pack_str(uint32_t l)
append_buffer(&buf, 1);
} else if(l < 256) {
char buf[2];
buf[0] = static_cast<char>(0xd9u); buf[1] = static_cast<uint8_t>(l);
buf[0] = static_cast<char>(0xd9u); buf[1] = static_cast<char>(l);
append_buffer(buf, 2);
} else if(l < 65536) {
char buf[3];
@@ -1282,7 +1309,7 @@ inline packer<Stream>& packer<Stream>::pack_bin(uint32_t l)
{
if(l < 256) {
char buf[2];
buf[0] = static_cast<char>(0xc4u); buf[1] = static_cast<uint8_t>(l);
buf[0] = static_cast<char>(0xc4u); buf[1] = static_cast<char>(l);
append_buffer(buf, 2);
} else if(l < 65536) {
char buf[3];

View File

@@ -78,19 +78,19 @@ inline void unpack_uint64(uint64_t d, msgpack::object& o)
{ o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = d; }
inline void unpack_int8(int8_t d, msgpack::object& o)
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = d; }
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = static_cast<uint64_t>(d); }
else { o.type = msgpack::type::NEGATIVE_INTEGER; o.via.i64 = d; } }
inline void unpack_int16(int16_t d, msgpack::object& o)
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = d; }
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = static_cast<uint64_t>(d); }
else { o.type = msgpack::type::NEGATIVE_INTEGER; o.via.i64 = d; } }
inline void unpack_int32(int32_t d, msgpack::object& o)
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = d; }
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = static_cast<uint64_t>(d); }
else { o.type = msgpack::type::NEGATIVE_INTEGER; o.via.i64 = d; } }
inline void unpack_int64(int64_t d, msgpack::object& o)
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = d; }
{ if(d >= 0) { o.type = msgpack::type::POSITIVE_INTEGER; o.via.u64 = static_cast<uint64_t>(d); }
else { o.type = msgpack::type::NEGATIVE_INTEGER; o.via.i64 = d; } }
inline void unpack_float(float d, msgpack::object& o)
@@ -418,10 +418,10 @@ private:
m_stack[0].set_obj(obj);
++m_current;
/*printf("-- finish --\n"); */
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
}
else if (ret < 0) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
}
else {
m_cs = MSGPACK_CS_HEADER;
@@ -461,7 +461,7 @@ inline int context::execute(const char* data, std::size_t len, std::size_t& off)
msgpack::object obj;
if(m_current == pe) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return 0;
}
bool fixed_trail_again = false;
@@ -544,7 +544,7 @@ inline int context::execute(const char* data, std::size_t len, std::size_t& off)
int ret = push_proc(obj, off);
if (ret != 0) return ret;
} else {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return -1;
}
// end MSGPACK_CS_HEADER
@@ -555,7 +555,7 @@ inline int context::execute(const char* data, std::size_t len, std::size_t& off)
fixed_trail_again = false;
}
if(static_cast<std::size_t>(pe - m_current) < m_trail) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return 0;
}
n = m_current;
@@ -830,13 +830,13 @@ inline int context::execute(const char* data, std::size_t len, std::size_t& off)
if (ret != 0) return ret;
} break;
default:
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return -1;
}
}
} while(m_current != pe);
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return 0;
}

View File

@@ -117,7 +117,7 @@ public:
void append_ref(const char* buf, size_t len)
{
if(m_tail == m_end) {
const size_t nused = m_tail - m_array;
const size_t nused = static_cast<size_t>(m_tail - m_array);
const size_t nnext = nused * 2;
iovec* nvec = static_cast<iovec*>(::realloc(
@@ -184,7 +184,7 @@ public:
size_t vector_size() const
{
return m_tail - m_array;
return static_cast<size_t>(m_tail - m_array);
}
void migrate(vrefbuffer* to)
@@ -202,11 +202,11 @@ public:
empty->next = MSGPACK_NULLPTR;
const size_t nused = m_tail - m_array;
const size_t nused = static_cast<size_t>(m_tail - m_array);
if(to->m_tail + nused < m_end) {
const size_t tosize = to->m_tail - to->m_array;
const size_t tosize = static_cast<size_t>(to->m_tail - to->m_array);
const size_t reqsize = nused + tosize;
size_t nnext = (to->m_end - to->m_array) * 2;
size_t nnext = static_cast<size_t>(to->m_end - to->m_array) * 2;
while(nnext < reqsize) {
size_t tmp_nnext = nnext * 2;
if (tmp_nnext <= nnext) {

View File

@@ -47,7 +47,7 @@ public:
void write(const char* buf, size_t len)
{
m_stream.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(buf));
m_stream.avail_in = len;
m_stream.avail_in = static_cast<uInt>(len);
while(m_stream.avail_in > 0) {
if(m_stream.avail_out < MSGPACK_ZBUFFER_RESERVE_SIZE) {
@@ -91,7 +91,7 @@ public:
size_t size() const
{
return reinterpret_cast<char*>(m_stream.next_out) - m_data;
return static_cast<size_t>(reinterpret_cast<char*>(m_stream.next_out) - m_data);
}
void reset()
@@ -104,7 +104,7 @@ public:
void reset_buffer()
{
m_stream.avail_out += reinterpret_cast<char*>(m_stream.next_out) - m_data;
m_stream.avail_out += static_cast<uInt>(reinterpret_cast<char*>(m_stream.next_out) - m_data);
m_stream.next_out = reinterpret_cast<Bytef*>(m_data);
}
@@ -120,7 +120,7 @@ public:
private:
bool expand()
{
size_t used = reinterpret_cast<char*>(m_stream.next_out) - m_data;
size_t used = static_cast<size_t>(reinterpret_cast<char*>(m_stream.next_out) - m_data);
size_t csize = used + m_stream.avail_out;
size_t nsize = (csize == 0) ? m_init_size : csize * 2;
@@ -131,7 +131,7 @@ private:
m_data = tmp;
m_stream.next_out = reinterpret_cast<Bytef*>(tmp + used);
m_stream.avail_out = nsize - used;
m_stream.avail_out = static_cast<uInt>(nsize - used);
return true;
}

View File

@@ -85,7 +85,7 @@ public:
msgpack::object* obj = m_stack.back();
if(v >= 0) {
obj->type = msgpack::type::POSITIVE_INTEGER;
obj->via.u64 = v;
obj->via.u64 = static_cast<uint64_t>(v);
}
else {
obj->type = msgpack::type::NEGATIVE_INTEGER;

View File

@@ -71,27 +71,27 @@ private:
++m_current;
if (size == 0) {
if (!sv(size)) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_STOP_VISITOR;
}
if (!ev()) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_STOP_VISITOR;
}
parse_return ret = m_stack.consume(holder());
if (ret != PARSE_CONTINUE) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return ret;
}
}
else {
if (!sv(size)) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_STOP_VISITOR;
}
parse_return ret = m_stack.push(holder(), sv.type(), static_cast<uint32_t>(size));
if (ret != PARSE_CONTINUE) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return ret;
}
}
@@ -102,12 +102,12 @@ private:
parse_return after_visit_proc(bool visit_result, std::size_t& off) {
++m_current;
if (!visit_result) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_STOP_VISITOR;
}
parse_return ret = m_stack.consume(holder());
if (ret != PARSE_CONTINUE) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
}
m_cs = MSGPACK_CS_HEADER;
return ret;
@@ -244,7 +244,7 @@ inline parse_return context<VisitorHolder>::execute(const char* data, std::size_
msgpack::object obj;
if(m_current == pe) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_CONTINUE;
}
bool fixed_trail_again = false;
@@ -326,7 +326,7 @@ inline parse_return context<VisitorHolder>::execute(const char* data, std::size_
parse_return upr = after_visit_proc(visret, off);
if (upr != PARSE_CONTINUE) return upr;
} else {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
holder().visitor().parse_error(off - 1, off);
return PARSE_PARSE_ERROR;
}
@@ -338,7 +338,7 @@ inline parse_return context<VisitorHolder>::execute(const char* data, std::size_
fixed_trail_again = false;
}
if(static_cast<std::size_t>(pe - m_current) < m_trail) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_CONTINUE;
}
n = m_current;
@@ -608,14 +608,14 @@ inline parse_return context<VisitorHolder>::execute(const char* data, std::size_
if (ret != PARSE_CONTINUE) return ret;
} break;
default:
off = m_current - m_start;
holder().visitor().parse_error(n - m_start - 1, n - m_start);
off = static_cast<std::size_t>(m_current - m_start);
holder().visitor().parse_error(static_cast<std::size_t>(n - m_start - 1), static_cast<std::size_t>(n - m_start));
return PARSE_PARSE_ERROR;
}
}
} while(m_current != pe);
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_CONTINUE;
}

View File

@@ -22,6 +22,7 @@
#if __GNUC__ >= 4
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wconversion"
#endif // __GNUC__ >= 4
#include <boost/config/warning_disable.hpp>
@@ -202,7 +203,7 @@ const auto mp_object_def =
(
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
std::int8_t val = _attr(ctx);
std::int8_t val = static_cast<std::int8_t>(_attr(ctx));
app_specific.vis.visit_negative_integer(val);
}
)
@@ -253,7 +254,7 @@ const auto mp_object_def =
(
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
std::int8_t val = _attr(ctx);
std::int8_t val = static_cast<std::int8_t>(_attr(ctx));
app_specific.vis.visit_negative_integer(val);
}
)
@@ -264,7 +265,7 @@ const auto mp_object_def =
(
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
std::int16_t val = _attr(ctx);
std::int16_t val = static_cast<std::int16_t>(_attr(ctx));
app_specific.vis.visit_negative_integer(val);
}
)
@@ -275,7 +276,7 @@ const auto mp_object_def =
(
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
std::int32_t val = _attr(ctx);
std::int32_t val = static_cast<std::int32_t>(_attr(ctx));
app_specific.vis.visit_negative_integer(val);
}
)
@@ -286,7 +287,7 @@ const auto mp_object_def =
(
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
std::int64_t val = _attr(ctx);
std::int64_t val = static_cast<std::int64_t>(_attr(ctx));
app_specific.vis.visit_negative_integer(val);
}
)
@@ -339,7 +340,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& str = _attr(ctx);
std::size_t size = std::distance(str.begin(), str.end());
auto size = static_cast<uint32_t>(std::distance(str.begin(), str.end()));
app_specific.vis.visit_str(size ? &str.front() : nullptr, size);
}
)
@@ -363,7 +364,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& str = _attr(ctx);
std::size_t size = std::distance(str.begin(), str.end());
auto size = static_cast<uint32_t>(std::distance(str.begin(), str.end()));
app_specific.vis.visit_str(size ? &str.front() : nullptr, size);
}
)
@@ -387,7 +388,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& str = _attr(ctx);
std::size_t size = std::distance(str.begin(), str.end());
auto size = static_cast<uint32_t>(std::distance(str.begin(), str.end()));
app_specific.vis.visit_str(size ? &str.front() : nullptr, size);
}
)
@@ -411,7 +412,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& str = _attr(ctx);
std::size_t size = std::distance(str.begin(), str.end());
auto size = static_cast<uint32_t>(std::distance(str.begin(), str.end()));
app_specific.vis.visit_str(size ? &str.front() : nullptr, size);
}
)
@@ -435,7 +436,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& bin = _attr(ctx);
std::size_t size = std::distance(bin.begin(), bin.end());
auto size = static_cast<uint32_t>(std::distance(bin.begin(), bin.end()));
app_specific.vis.visit_bin(size ? &bin.front() : nullptr, size);
}
)
@@ -459,7 +460,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& bin = _attr(ctx);
std::size_t size = std::distance(bin.begin(), bin.end());
auto size = static_cast<uint32_t>(std::distance(bin.begin(), bin.end()));
app_specific.vis.visit_bin(size ? &bin.front() : nullptr, size);
}
)
@@ -483,7 +484,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& bin = _attr(ctx);
std::size_t size = std::distance(bin.begin(), bin.end());
auto size = static_cast<uint32_t>(std::distance(bin.begin(), bin.end()));
app_specific.vis.visit_bin(size ? &bin.front() : nullptr, size);
}
)
@@ -494,7 +495,7 @@ const auto mp_object_def =
(
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
std::size_t size = _attr(ctx) & 0b00001111;
uint32_t size = _attr(ctx) & 0b00001111;
app_specific.index_sizes.emplace_back(size, index_size::type_t::array);
app_specific.vis.start_array(size);
}
@@ -508,7 +509,7 @@ const auto mp_object_def =
(
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
std::size_t size = _attr(ctx);
uint32_t size = _attr(ctx);
app_specific.index_sizes.emplace_back(size, index_size::type_t::array);
app_specific.vis.start_array(size);
}
@@ -522,7 +523,7 @@ const auto mp_object_def =
(
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
std::size_t size = _attr(ctx);
uint32_t size = _attr(ctx);
app_specific.index_sizes.emplace_back(size, index_size::type_t::array);
app_specific.vis.start_array(size);
}
@@ -536,7 +537,7 @@ const auto mp_object_def =
(
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
std::size_t size = _attr(ctx) & 0b00001111;
uint32_t size = _attr(ctx) & 0b00001111;
app_specific.index_sizes.emplace_back(size, index_size::type_t::map);
app_specific.vis.start_map(size);
}
@@ -550,7 +551,7 @@ const auto mp_object_def =
(
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
std::size_t size = _attr(ctx);
uint32_t size = _attr(ctx);
app_specific.index_sizes.emplace_back(size, index_size::type_t::map);
app_specific.vis.start_map(size);
}
@@ -564,7 +565,7 @@ const auto mp_object_def =
(
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
std::size_t size = _attr(ctx);
uint32_t size = _attr(ctx);
app_specific.index_sizes.emplace_back(size, index_size::type_t::map);
app_specific.vis.start_map(size);
}
@@ -591,7 +592,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& ext = _attr(ctx);
std::size_t size = std::distance(ext.begin(), ext.end());
auto size = static_cast<uint32_t>(std::distance(ext.begin(), ext.end()));
app_specific.vis.visit_ext(size ? &ext.front() : nullptr, size);
}
)
@@ -615,7 +616,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& ext = _attr(ctx);
std::size_t size = std::distance(ext.begin(), ext.end());
auto size = static_cast<uint32_t>(std::distance(ext.begin(), ext.end()));
app_specific.vis.visit_ext(size ? &ext.front() : nullptr, size);
}
)
@@ -639,7 +640,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& ext = _attr(ctx);
std::size_t size = std::distance(ext.begin(), ext.end());
auto size = static_cast<uint32_t>(std::distance(ext.begin(), ext.end()));
app_specific.vis.visit_ext(size ? &ext.front() : nullptr, size);
}
)
@@ -663,7 +664,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& ext = _attr(ctx);
std::size_t size = std::distance(ext.begin(), ext.end());
auto size = static_cast<uint32_t>(std::distance(ext.begin(), ext.end()));
app_specific.vis.visit_ext(size ? &ext.front() : nullptr, size);
}
)
@@ -687,7 +688,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& ext = _attr(ctx);
std::size_t size = std::distance(ext.begin(), ext.end());
auto size = static_cast<uint32_t>(std::distance(ext.begin(), ext.end()));
app_specific.vis.visit_ext(size ? &ext.front() : nullptr, size);
}
)
@@ -711,7 +712,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& ext = _attr(ctx);
std::size_t size = std::distance(ext.begin(), ext.end());
auto size = static_cast<uint32_t>(std::distance(ext.begin(), ext.end()));
app_specific.vis.visit_ext(size ? &ext.front() : nullptr, size);
}
)
@@ -735,7 +736,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& ext = _attr(ctx);
std::size_t size = std::distance(ext.begin(), ext.end());
auto size = static_cast<uint32_t>(std::distance(ext.begin(), ext.end()));
app_specific.vis.visit_ext(size ? &ext.front() : nullptr, size);
}
)
@@ -759,7 +760,7 @@ const auto mp_object_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
auto const& ext = _attr(ctx);
std::size_t size = std::distance(ext.begin(), ext.end());
auto size = static_cast<uint32_t>(std::distance(ext.begin(), ext.end()));
app_specific.vis.visit_ext(size ? &ext.front() : nullptr, size);
}
)
@@ -771,6 +772,7 @@ const auto array_item_def =
[](auto& ctx){
auto& app_specific = x3::get<tag_app_specific>(ctx).get();
app_specific.vis.start_array_item();
_pass(ctx) = true;
}
)

View File

@@ -63,29 +63,29 @@ private:
load<T>(size, load_pos);
if (size == 0) {
if (!sv(size)) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_STOP_VISITOR;
}
if (!ev()) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_STOP_VISITOR;
}
parse_return ret = m_stack.consume(holder(), m_current);
++m_current;
if (ret != PARSE_CONTINUE) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return ret;
}
}
else {
if (!sv(size)) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_STOP_VISITOR;
}
parse_return ret = m_stack.push(holder(), sv.type(), static_cast<uint32_t>(size));
++m_current;
if (ret != PARSE_CONTINUE) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return ret;
}
}
@@ -95,13 +95,13 @@ private:
parse_return after_visit_proc(bool visit_result, std::size_t& off) {
if (!visit_result) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_STOP_VISITOR;
}
parse_return ret = m_stack.consume(holder(), m_current);
++m_current;
if (ret != PARSE_CONTINUE) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
}
m_cs = MSGPACK_CS_HEADER;
return ret;
@@ -253,7 +253,7 @@ inline parse_return context<VisitorHolder>::execute(const char* data, std::size_
msgpack::object obj;
if(m_current == pe) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_CONTINUE;
}
bool fixed_trail_again = false;
@@ -335,7 +335,7 @@ inline parse_return context<VisitorHolder>::execute(const char* data, std::size_
parse_return upr = after_visit_proc(visret, off);
if (upr != PARSE_CONTINUE) return upr;
} else {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
holder().visitor().parse_error(off - 1, off);
return PARSE_PARSE_ERROR;
}
@@ -347,7 +347,7 @@ inline parse_return context<VisitorHolder>::execute(const char* data, std::size_
fixed_trail_again = false;
}
if(static_cast<std::size_t>(pe - m_current) < m_trail) {
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_CONTINUE;
}
n = m_current;
@@ -617,14 +617,14 @@ inline parse_return context<VisitorHolder>::execute(const char* data, std::size_
if (ret != PARSE_CONTINUE) return ret;
} break;
default:
off = m_current - m_start;
holder().visitor().parse_error(n - m_start - 1, n - m_start);
off = static_cast<std::size_t>(m_current - m_start);
holder().visitor().parse_error(static_cast<std::size_t>(n - m_start - 1), static_cast<std::size_t>(n - m_start));
return PARSE_PARSE_ERROR;
}
}
} while(m_current != pe);
off = m_current - m_start;
off = static_cast<std::size_t>(m_current - m_start);
return PARSE_CONTINUE;
}

View File

@@ -100,8 +100,9 @@ static inline void msgpack_zbuffer_free(msgpack_zbuffer* zbuf)
static inline bool msgpack_zbuffer_expand(msgpack_zbuffer* zbuf)
{
size_t used = (char*)zbuf->stream.next_out - zbuf->data;
size_t used = static_cast<size_t>(reinterpret_cast<char*>(zbuf->stream.next_out) - zbuf->data);
size_t csize = used + zbuf->stream.avail_out;
size_t nsize = (csize == 0) ? zbuf->init_size : csize * 2;
char* tmp = (char*)realloc(zbuf->data, nsize);
@@ -111,7 +112,7 @@ static inline bool msgpack_zbuffer_expand(msgpack_zbuffer* zbuf)
zbuf->data = tmp;
zbuf->stream.next_out = (Bytef*)(tmp + used);
zbuf->stream.avail_out = nsize - used;
zbuf->stream.avail_out = static_cast<uInt>(nsize - used);
return true;
}
@@ -121,7 +122,7 @@ static inline int msgpack_zbuffer_write(void* data, const char* buf, size_t len)
msgpack_zbuffer* zbuf = (msgpack_zbuffer*)data;
zbuf->stream.next_in = (Bytef*)buf;
zbuf->stream.avail_in = len;
zbuf->stream.avail_in = static_cast<uInt>(len);
while(zbuf->stream.avail_in > 0) {
if(zbuf->stream.avail_out < MSGPACK_ZBUFFER_RESERVE_SIZE) {
@@ -162,12 +163,12 @@ static inline const char* msgpack_zbuffer_data(const msgpack_zbuffer* zbuf)
static inline size_t msgpack_zbuffer_size(const msgpack_zbuffer* zbuf)
{
return (char*)zbuf->stream.next_out - zbuf->data;
return static_cast<size_t>(reinterpret_cast<char*>(zbuf->stream.next_out) - zbuf->data);
}
static inline void msgpack_zbuffer_reset_buffer(msgpack_zbuffer* zbuf)
{
zbuf->stream.avail_out += (char*)zbuf->stream.next_out - zbuf->data;
zbuf->stream.avail_out += (uInt)((char*)zbuf->stream.next_out - zbuf->data);
zbuf->stream.next_out = (Bytef*)zbuf->data;
}
@@ -197,4 +198,3 @@ static inline char* msgpack_zbuffer_release_buffer(msgpack_zbuffer* zbuf)
#endif
#endif /* msgpack/zbuffer.h */

View File

@@ -111,7 +111,7 @@ static inline void* msgpack_zone_malloc(msgpack_zone* zone, size_t size)
zone->chunk_list.ptr + (MSGPACK_ZONE_ALIGN - 1)
) / MSGPACK_ZONE_ALIGN * MSGPACK_ZONE_ALIGN
);
size_t adjusted_size = size + (aligned - zone->chunk_list.ptr);
size_t adjusted_size = size + (size_t)(aligned - zone->chunk_list.ptr);
if(zone->chunk_list.free >= adjusted_size) {
zone->chunk_list.free -= adjusted_size;
zone->chunk_list.ptr += adjusted_size;

View File

@@ -89,7 +89,7 @@ FOREACH (source_file ${check_PROGRAMS})
)
ADD_TEST (${source_file_we} ${source_file_we})
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra -Wconversion")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")

View File

@@ -3,8 +3,13 @@
#include <string>
#include <sstream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -3,8 +3,13 @@
#include <iterator>
#include <cmath>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -1,8 +1,15 @@
#include <msgpack.hpp>
#include <sstream>
#include <iterator>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -1,8 +1,15 @@
#include <msgpack.hpp>
#include <sstream>
#include <iterator>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -1,8 +1,14 @@
#include <msgpack.hpp>
#include <sstream>
#include <iterator>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -2,8 +2,14 @@
#include <msgpack.hpp>
#include <sstream>
#include <iterator>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -393,10 +399,10 @@ TEST(MSGPACK_BOOST, object_with_zone_variant_raw_ref)
v.push_back('a');
v.push_back('b');
v.push_back('c');
msgpack::type::raw_ref rr(&v.front(), v.size());
msgpack::type::raw_ref rr(&v.front(), static_cast<uint32_t>(v.size()));
msgpack::type::variant val1 = rr;
EXPECT_TRUE(val1.is_raw_ref());
EXPECT_EQ(val1.as_raw_ref(), msgpack::type::raw_ref(&v.front(), v.size()));
EXPECT_EQ(val1.as_raw_ref(), msgpack::type::raw_ref(&v.front(), static_cast<uint32_t>(v.size())));
msgpack::object obj(val1, z);
msgpack::type::variant val2 = obj.as<msgpack::type::variant>();
// Converted as std::vector<char>.
@@ -418,7 +424,7 @@ TEST(MSGPACK_BOOST, pack_convert_variant_ext)
v.push_back('a');
v.push_back('b');
v.push_back('c');
msgpack::type::ext e(42, v.data(), v.size());
msgpack::type::ext e(42, v.data(), static_cast<uint32_t>(v.size()));
msgpack::type::variant val1(e);
EXPECT_TRUE(val1.is_ext());
EXPECT_EQ(val1.as_ext(), e);
@@ -443,7 +449,7 @@ TEST(MSGPACK_BOOST, object_with_zone_variant_ext)
v.push_back('a');
v.push_back('b');
v.push_back('c');
msgpack::type::ext e(42, v.data(), v.size());
msgpack::type::ext e(42, v.data(), static_cast<uint32_t>(v.size()));
msgpack::type::variant val1(e);
EXPECT_TRUE(val1.is_ext());
EXPECT_EQ(val1.as_ext(), e);
@@ -463,7 +469,7 @@ TEST(MSGPACK_BOOST, object_with_zone_variant_ext_ref)
v.push_back('a');
v.push_back('b');
v.push_back('c');
msgpack::type::ext_ref e(v.data(), v.size());
msgpack::type::ext_ref e(v.data(), static_cast<uint32_t>(v.size()));
msgpack::type::variant val1(e);
EXPECT_TRUE(val1.is_ext_ref());
EXPECT_EQ(val1.as_ext_ref(), e);
@@ -616,7 +622,7 @@ TEST(MSGPACK_BOOST, pack_convert_variant_ref_bin)
v.push_back('a');
v.push_back('b');
v.push_back('c');
msgpack::type::raw_ref rr(v.data(), v.size());
msgpack::type::raw_ref rr(v.data(), static_cast<uint32_t>(v.size()));
msgpack::type::variant_ref val1 = rr;
EXPECT_TRUE(val1.is_raw_ref());
EXPECT_EQ(val1.as_raw_ref(), rr);
@@ -641,7 +647,7 @@ TEST(MSGPACK_BOOST, object_with_zone_variant_ref_bin)
v.push_back('a');
v.push_back('b');
v.push_back('c');
msgpack::type::raw_ref rr(v.data(), v.size());
msgpack::type::raw_ref rr(v.data(), static_cast<uint32_t>(v.size()));
msgpack::type::variant_ref val1 = rr;
EXPECT_TRUE(val1.is_raw_ref());
EXPECT_EQ(val1.as_raw_ref(), rr);
@@ -663,7 +669,7 @@ TEST(MSGPACK_BOOST, pack_convert_variant_ref_ext)
v.push_back('a');
v.push_back('b');
v.push_back('c');
msgpack::type::ext_ref er(v.data(), v.size());
msgpack::type::ext_ref er(v.data(), static_cast<uint32_t>(v.size()));
msgpack::type::variant_ref val1(er);
EXPECT_TRUE(val1.is_ext_ref());
EXPECT_EQ(val1.as_ext_ref(), er);
@@ -688,7 +694,7 @@ TEST(MSGPACK_BOOST, object_with_zone_variant_ref_ext)
v.push_back('a');
v.push_back('b');
v.push_back('c');
msgpack::type::ext_ref er(v.data(), v.size());
msgpack::type::ext_ref er(v.data(), static_cast<uint32_t>(v.size()));
msgpack::type::variant_ref val1(er);
EXPECT_TRUE(val1.is_ext_ref());
EXPECT_EQ(val1.as_ext_ref(), er);

View File

@@ -3,7 +3,14 @@
#include <msgpack/fbuffer.h>
#include <msgpack/zbuffer.hpp>
#include <msgpack/zbuffer.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#include <string.h>
TEST(buffer, sbuffer)

View File

@@ -1,5 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#include <sstream>
TEST(carray, pack_unpack_int)

View File

@@ -1,13 +1,19 @@
#include <msgpack.hpp>
#include <fstream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
static void feed_file(msgpack::unpacker& pac, const char* path)
{
std::ifstream fin(path);
while(true) {
pac.reserve_buffer(32*1024);
fin.read(pac.buffer(), pac.buffer_capacity());
fin.read(pac.buffer(), static_cast<std::streamsize>(pac.buffer_capacity()));
if(fin.bad()) {
throw std::runtime_error("read failed");
}

View File

@@ -1,6 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
class enum_member {
public:
enum_member() : flag(A) { }

View File

@@ -1,6 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
template <typename T>
void check_size(size_t size) {
T v(0);
@@ -25,7 +31,7 @@ TEST(fixint, size)
template <typename T>
void check_convert() {
T v1(-11);
T v1(typename T::value_type(-11));
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, v1);

View File

@@ -1,6 +1,12 @@
#include <msgpack.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
TEST(fixint, size)
{
msgpack_sbuffer* sbuf = msgpack_sbuffer_new();
@@ -29,4 +35,3 @@ TEST(fixint, size)
msgpack_sbuffer_free(sbuf);
msgpack_packer_free(pk);
}

View File

@@ -1,5 +1,10 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#include "../fuzz/unpack_pack_fuzzer.cpp"
TEST(FUZZ_UNPACK_PACK_FUZZER, works)

View File

@@ -1,6 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -1,8 +1,14 @@
#include <msgpack.hpp>
#include <fstream>
#include <sstream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
TEST(json, basic_elements)
{
typedef std::map<std::string, int> map_s_i;

View File

@@ -1,5 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#include <sstream>
TEST(limit, unpack_array_no_over)

View File

@@ -9,8 +9,13 @@
#include <list>
#include <limits>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#if defined(_MSC_VER) || defined(__MINGW32__)
#define msgpack_rand() ((double)rand() / RAND_MAX)
#else // _MSC_VER || __MINGW32__
@@ -36,7 +41,7 @@ const double kEPS = 1e-10;
v.push_back(numeric_limits<test_type>::min()); \
v.push_back(numeric_limits<test_type>::max()); \
for (unsigned int i = 0; i < kLoop; i++) \
v.push_back(rand()); \
v.push_back(static_cast<test_type>(rand())); \
for (unsigned int i = 0; i < v.size() ; i++) { \
msgpack::sbuffer sbuf; \
test_type val1 = v[i]; \
@@ -209,7 +214,7 @@ TYPED_TEST_P(IntegerToFloatingPointTest, simple_buffer)
vector<integer_type> v;
v.push_back(0);
v.push_back(1);
if (numeric_limits<integer_type>::is_signed) v.push_back(-1);
if (numeric_limits<integer_type>::is_signed) v.push_back(static_cast<integer_type>(-1));
else v.push_back(2);
for (unsigned int i = 0; i < kLoop; i++) {
v.push_back(rand() % 0x7FFFFF);
@@ -221,7 +226,7 @@ TYPED_TEST_P(IntegerToFloatingPointTest, simple_buffer)
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
float_type val2 = oh.get().as<float_type>();
EXPECT_TRUE(fabs(val2 - val1) <= kEPS);
EXPECT_TRUE(fabs(val2 - static_cast<float_type>(val1)) <= kEPS);
}
}
@@ -664,7 +669,7 @@ TEST(MSGPACK_STL, simple_buffer_string)
for (unsigned int k = 0; k < kLoop; k++) {
string val1;
for (unsigned int i = 0; i < kElements; i++)
val1 += 'a' + rand() % 26;
val1 += static_cast<char>('a' + rand() % 26);
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =
@@ -681,7 +686,7 @@ TEST(MSGPACK_STL, simple_buffer_cstring)
for (unsigned int k = 0; k < kLoop; k++) {
string val1;
for (unsigned int i = 0; i < kElements; i++)
val1 += 'a' + rand() % 26;
val1 += static_cast<char>('a' + rand() % 26);
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1.c_str());
msgpack::object_handle oh =
@@ -698,7 +703,7 @@ TEST(MSGPACK_STL, simple_buffer_non_const_cstring)
for (unsigned int k = 0; k < kLoop; k++) {
string val1;
for (unsigned int i = 0; i < kElements; i++)
val1 += 'a' + rand() % 26;
val1 += static_cast<char>('a' + rand() % 26);
msgpack::sbuffer sbuf;
char* s = new char[val1.size() + 1];
std::memcpy(s, val1.c_str(), val1.size() + 1);

View File

@@ -4,8 +4,13 @@
#include <vector>
#include <limits>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#if defined(_MSC_VER) || defined(__MINGW32__)
#define msgpack_rand() ((double)rand() / RAND_MAX)
#else // _MSC_VER || __MINGW32__
@@ -26,7 +31,7 @@ const double kEPS = 1e-10;
v.push_back(numeric_limits<test_type>::min()); \
v.push_back(numeric_limits<test_type>::max()); \
for (unsigned int i = 0; i < kLoop; i++) \
v.push_back(rand()); \
v.push_back(static_cast<test_type>(rand())); \
for (unsigned int i = 0; i < v.size() ; i++) { \
test_type val = v[i]; \
msgpack_sbuffer sbuf; \
@@ -61,7 +66,7 @@ const double kEPS = 1e-10;
v.push_back(numeric_limits<test_type>::min()); \
v.push_back(numeric_limits<test_type>::max()); \
for (unsigned int i = 0; i < kLoop; i++) \
v.push_back(rand()); \
v.push_back(static_cast<test_type>(rand())); \
for (unsigned int i = 0; i < v.size() ; i++) { \
test_type val = v[i]; \
msgpack_sbuffer sbuf; \

View File

@@ -12,8 +12,13 @@
#include "test_allocator.hpp"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -75,7 +80,7 @@ TEST(MSGPACK_STL, simple_buffer_vector_char)
for (unsigned int k = 0; k < kLoop; k++) {
type val1;
for (unsigned int i = 0; i < kElements; i++)
val1.push_back(rand());
val1.push_back(static_cast<char>(rand()));
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =
@@ -107,7 +112,7 @@ TEST(MSGPACK_STL, simple_buffer_vector_unsigned_char)
for (unsigned int k = 0; k < kLoop; k++) {
type val1;
for (unsigned int i = 0; i < kElements; i++)
val1.push_back(rand());
val1.push_back(static_cast<unsigned char>(rand()));
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =
@@ -140,7 +145,7 @@ TEST(MSGPACK_STL, simple_buffer_vector_uint8_t)
for (unsigned int k = 0; k < kLoop; k++) {
type val1;
for (unsigned int i = 0; i < kElements; i++)
val1.push_back(rand());
val1.push_back(static_cast<uint8_t>(rand()));
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =

View File

@@ -1,7 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -1,7 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -9,8 +9,13 @@
#include <list>
#include <limits>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -26,8 +31,8 @@ const unsigned int kLoop = 1000;
msgpack::packer<msgpack::sbuffer> pk(sbuf); \
typedef std::vector<test_type> vec_type; \
vec_type vec; \
for(unsigned int i = 0; i < rand() % kLoop; ++i) { \
vec_type::value_type r = rand(); \
for(unsigned int i = 0; i < static_cast<unsigned int>(rand()) % kLoop; ++i) { \
vec_type::value_type r = static_cast<test_type>(rand()); \
vec.push_back(r); \
pk.pack(r); \
} \
@@ -36,7 +41,7 @@ const unsigned int kLoop = 1000;
const char *p = sbuf.data(); \
const char * const pend = p + sbuf.size(); \
while (p < pend) { \
const size_t sz = std::min<size_t>(pend - p, rand() % 128); \
const size_t sz = std::min<size_t>(static_cast<std::size_t>(pend - p), static_cast<std::size_t>(rand() % 128)); \
pac.reserve_buffer(sz); \
memcpy(pac.buffer(), p, sz); \
pac.buffer_consumed(sz); \

View File

@@ -1,6 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
TEST(msgpack_tuple, member_get)
{

View File

@@ -9,8 +9,13 @@
#include <list>
#include <limits>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -4,8 +4,13 @@
#include <limits>
#include <cmath>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
// To avoid link error
TEST(MSGPACK_X3_PARSE, dummy)
{
@@ -169,7 +174,7 @@ TEST(MSGPACK_X3_PARSE, uint64_2)
TEST(MSGPACK_X3_PARSE, int8_1)
{
int8_t v = 0b11011111;
int8_t v = static_cast<int8_t>(0b11011111);
std::stringstream ss;
msgpack::pack(ss, v);
@@ -179,7 +184,7 @@ TEST(MSGPACK_X3_PARSE, int8_1)
TEST(MSGPACK_X3_PARSE, int8_2)
{
int8_t v = 0b10000000;
int8_t v = static_cast<int8_t>(0b10000000);
std::stringstream ss;
msgpack::pack(ss, v);
@@ -189,7 +194,7 @@ TEST(MSGPACK_X3_PARSE, int8_2)
TEST(MSGPACK_X3_PARSE, int16_1)
{
int16_t v = 0xff00;
int16_t v = static_cast<int16_t>(0xff00);
std::stringstream ss;
msgpack::pack(ss, v);
@@ -199,7 +204,7 @@ TEST(MSGPACK_X3_PARSE, int16_1)
TEST(MSGPACK_X3_PARSE, int16_2)
{
int16_t v = 0x8000;
int16_t v = static_cast<int16_t>(0x8000);
std::stringstream ss;
msgpack::pack(ss, v);
@@ -209,7 +214,7 @@ TEST(MSGPACK_X3_PARSE, int16_2)
TEST(MSGPACK_X3_PARSE, int32_1)
{
int32_t v = 0xff000000L;
int32_t v = static_cast<int32_t>(0xff000000L);
std::stringstream ss;
msgpack::pack(ss, v);
@@ -219,7 +224,7 @@ TEST(MSGPACK_X3_PARSE, int32_1)
TEST(MSGPACK_X3_PARSE, int32_2)
{
int32_t v = 0x80000000L;
int32_t v = static_cast<int32_t>(0x80000000L);
std::stringstream ss;
msgpack::pack(ss, v);
@@ -229,7 +234,7 @@ TEST(MSGPACK_X3_PARSE, int32_2)
TEST(MSGPACK_X3_PARSE, int64_1)
{
int64_t v = 0xff00000000000000LL;
int64_t v = static_cast<int64_t>(0xff00000000000000LL);
std::stringstream ss;
msgpack::pack(ss, v);
@@ -239,7 +244,7 @@ TEST(MSGPACK_X3_PARSE, int64_1)
TEST(MSGPACK_X3_PARSE, int64_2)
{
int64_t v = 0x8000000000000000LL;
int64_t v = static_cast<int64_t>(0x8000000000000000LL);
std::stringstream ss;
msgpack::pack(ss, v);
@@ -445,7 +450,7 @@ TEST(MSGPACK_X3_PARSE, string_2)
{
std::string v;
for (uint64_t i = 0; i != 0x1fU; ++i) v.push_back('0'+(i%10));
for (uint64_t i = 0; i != 0x1fU; ++i) v.push_back(static_cast<char>('0'+(i%10)));
std::stringstream ss;
msgpack::pack(ss, v);
@@ -458,7 +463,7 @@ TEST(MSGPACK_X3_PARSE, string_3)
{
std::string v;
for (uint64_t i = 0; i != 0xffU; ++i) v.push_back('0'+(i%10));
for (uint64_t i = 0; i != 0xffU; ++i) v.push_back(static_cast<char>('0'+(i%10)));
std::stringstream ss;
msgpack::pack(ss, v);
@@ -471,7 +476,7 @@ TEST(MSGPACK_X3_PARSE, string_4)
{
std::string v;
for (uint64_t i = 0; i != 0xffU+1U; ++i) v.push_back('0'+(i%10));
for (uint64_t i = 0; i != 0xffU+1U; ++i) v.push_back(static_cast<char>('0'+(i%10)));
std::stringstream ss;
msgpack::pack(ss, v);
@@ -484,7 +489,7 @@ TEST(MSGPACK_X3_PARSE, string_5)
{
std::string v;
for (uint64_t i = 0; i != 0xffffU; ++i) v.push_back('0'+(i%10));
for (uint64_t i = 0; i != 0xffffU; ++i) v.push_back(static_cast<char>('0'+(i%10)));
std::stringstream ss;
msgpack::pack(ss, v);
@@ -497,7 +502,7 @@ TEST(MSGPACK_X3_PARSE, string_6)
{
std::string v;
for (uint64_t i = 0; i != 0xffffUL + 1UL; ++i) v.push_back('0'+(i%10));
for (uint64_t i = 0; i != 0xffffUL + 1UL; ++i) v.push_back(static_cast<char>('0'+(i%10)));
std::stringstream ss;
msgpack::pack(ss, v);
@@ -520,7 +525,7 @@ TEST(MSGPACK_X3_PARSE, bin_2)
{
std::vector<char> v;
for (uint64_t i = 0; i != 0x1fU; ++i) v.push_back(i%0xff);
for (uint64_t i = 0; i != 0x1fU; ++i) v.push_back(static_cast<char>(i%0xff));
std::stringstream ss;
msgpack::pack(ss, v);
@@ -533,7 +538,7 @@ TEST(MSGPACK_X3_PARSE, bin_3)
{
std::vector<char> v;
for (uint64_t i = 0; i != 0xffU; ++i) v.push_back(i%0xff);
for (uint64_t i = 0; i != 0xffU; ++i) v.push_back(static_cast<char>(i%0xff));
std::stringstream ss;
msgpack::pack(ss, v);
@@ -546,7 +551,7 @@ TEST(MSGPACK_X3_PARSE, bin_4)
{
std::vector<char> v;
for (uint64_t i = 0; i != 0xffU+1U; ++i) v.push_back(i%0xff);
for (uint64_t i = 0; i != 0xffU+1U; ++i) v.push_back(static_cast<char>(i%0xff));
std::stringstream ss;
msgpack::pack(ss, v);
@@ -559,7 +564,7 @@ TEST(MSGPACK_X3_PARSE, bin_5)
{
std::vector<char> v;
for (uint64_t i = 0; i != 0xffffU; ++i) v.push_back(i%0xff);
for (uint64_t i = 0; i != 0xffffU; ++i) v.push_back(static_cast<char>(i%0xff));
std::stringstream ss;
msgpack::pack(ss, v);
@@ -572,7 +577,7 @@ TEST(MSGPACK_X3_PARSE, bin_6)
{
std::vector<char> v;
for (uint64_t i = 0; i != 0xffffUL + 1UL; ++i) v.push_back(i%0xff);
for (uint64_t i = 0; i != 0xffffUL + 1UL; ++i) v.push_back(static_cast<char>(i%0xff));
std::stringstream ss;
msgpack::pack(ss, v);

View File

@@ -1,6 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
enum enum_test {
elem

View File

@@ -1,5 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#include <cmath>
#ifdef HAVE_CONFIG_H
@@ -202,7 +209,7 @@ TEST(object_with_zone, vector)
vector<int> v1;
v1.push_back(1);
for (unsigned int i = 1; i < kElements; i++)
v1.push_back(i);
v1.push_back(static_cast<int>(i));
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_TRUE(obj.as<vector<int> >() == v1);
@@ -282,7 +289,7 @@ TEST(object_with_zone, list)
list<int> v1;
v1.push_back(1);
for (unsigned int i = 1; i < kElements; i++)
v1.push_back(i);
v1.push_back(static_cast<int>(i));
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_TRUE(obj.as<list<int> >() == v1);
@@ -298,7 +305,7 @@ TEST(object_with_zone, deque)
deque<int> v1;
v1.push_back(1);
for (unsigned int i = 1; i < kElements; i++)
v1.push_back(i);
v1.push_back(static_cast<int>(i));
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_TRUE(obj.as<deque<int> >() == v1);
@@ -412,7 +419,7 @@ TEST(object_with_zone, set)
for (unsigned int k = 0; k < kLoop; k++) {
set<int> v1;
for (unsigned int i = 0; i < kElements; i++)
v1.insert(i);
v1.insert(static_cast<int>(i));
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_TRUE(obj.as<set<int> >() == v1);
@@ -872,7 +879,7 @@ TEST(object_with_zone, array_char)
test_t v1;
v1[0] = 1;
for (unsigned int i = 1; i < kElements; i++)
v1[i] = rand();
v1[i] = static_cast<char>(rand());
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_TRUE(obj.as<test_t>() == v1);
@@ -888,7 +895,7 @@ TEST(object_without_zone, array_char)
test_t v1;
v1[0] = 1;
for (unsigned int i = 1; i < kElements; i++)
v1[i] = rand();
v1[i] = static_cast<char>(rand());
msgpack::object obj(v1);
EXPECT_TRUE(obj.as<test_t>() == v1);
v1.front() = 42;
@@ -905,7 +912,7 @@ TEST(object_with_zone, array_unsigned_char)
test_t v1;
v1[0] = 1;
for (unsigned int i = 1; i < kElements; i++)
v1[i] = rand();
v1[i] = static_cast<unsigned char>(rand());
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_TRUE(obj.as<test_t>() == v1);
@@ -922,7 +929,7 @@ TEST(object_without_zone, array_unsigned_char)
test_t v1;
v1[0] = 1;
for (unsigned int i = 1; i < kElements; i++)
v1[i] = rand();
v1[i] = static_cast<unsigned char>(rand());
msgpack::object obj(v1);
EXPECT_TRUE(obj.as<test_t>() == v1);
v1.front() = 42;
@@ -937,7 +944,7 @@ TEST(object_with_zone, forward_list)
for (unsigned int k = 0; k < kLoop; k++) {
forward_list<int> v1;
for (unsigned int i = 0; i < kElements; i++)
v1.push_front(i);
v1.push_front(static_cast<int>(i));
msgpack::zone z;
msgpack::object obj(v1, z);
EXPECT_TRUE(obj.as<forward_list<int> >() == v1);
@@ -1042,7 +1049,7 @@ TEST(object_with_zone, ext_empty)
TEST(object_with_zone, ext)
{
msgpack::type::ext v(42, 10);
for (int i = 0; i < 10; ++i) v.data()[i] = i;
for (int i = 0; i < 10; ++i) v.data()[i] = static_cast<char>(i);
msgpack::zone z;
msgpack::object obj(v, z);
EXPECT_TRUE(obj.as<msgpack::type::ext>() == v);

View File

@@ -1,5 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#include <sstream>
TEST(pack, num)
@@ -517,7 +524,7 @@ TEST(unpack, int_off_larger_than_length)
TEST(unpack, empty_array_fix)
{
std::string buf;
buf.push_back(static_cast<unsigned char>(0x90));
buf.push_back(static_cast<char>(0x90));
std::size_t off = 0;
msgpack::object_handle oh = msgpack::unpack(buf.data(), buf.size(), off);
@@ -529,9 +536,9 @@ TEST(unpack, empty_array_fix)
TEST(unpack, empty_array_16)
{
std::string buf;
buf.push_back(static_cast<unsigned char>(0xdc));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<char>(0xdc));
buf.push_back(static_cast<char>(0x00));
buf.push_back(static_cast<char>(0x00));
std::size_t off = 0;
msgpack::object_handle oh = msgpack::unpack(buf.data(), buf.size(), off);
@@ -543,11 +550,11 @@ TEST(unpack, empty_array_16)
TEST(unpack, empty_array_32)
{
std::string buf;
buf.push_back(static_cast<unsigned char>(0xdd));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<char>(0xdd));
buf.push_back(static_cast<char>(0x00));
buf.push_back(static_cast<char>(0x00));
buf.push_back(static_cast<char>(0x00));
buf.push_back(static_cast<char>(0x00));
std::size_t off = 0;
msgpack::object_handle oh = msgpack::unpack(buf.data(), buf.size(), off);
@@ -559,7 +566,7 @@ TEST(unpack, empty_array_32)
TEST(unpack, empty_map_fix)
{
std::string buf;
buf.push_back(static_cast<unsigned char>(0x80));
buf.push_back(static_cast<char>(0x80));
std::size_t off = 0;
msgpack::object_handle oh = msgpack::unpack(buf.data(), buf.size(), off);
@@ -571,9 +578,9 @@ TEST(unpack, empty_map_fix)
TEST(unpack, empty_map_16)
{
std::string buf;
buf.push_back(static_cast<unsigned char>(0xde));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<char>(0xde));
buf.push_back(static_cast<char>(0x00));
buf.push_back(static_cast<char>(0x00));
std::size_t off = 0;
msgpack::object_handle oh = msgpack::unpack(buf.data(), buf.size(), off);
@@ -585,11 +592,11 @@ TEST(unpack, empty_map_16)
TEST(unpack, empty_map_32)
{
std::string buf;
buf.push_back(static_cast<unsigned char>(0xdf));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<unsigned char>(0x00));
buf.push_back(static_cast<char>(0xdf));
buf.push_back(static_cast<char>(0x00));
buf.push_back(static_cast<char>(0x00));
buf.push_back(static_cast<char>(0x00));
buf.push_back(static_cast<char>(0x00));
std::size_t off = 0;
msgpack::object_handle oh = msgpack::unpack(buf.data(), buf.size(), off);

View File

@@ -1,5 +1,12 @@
#include <msgpack.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#include <stdio.h>
TEST(pack, num)

View File

@@ -3,8 +3,13 @@
#include <string>
#include <sstream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -13,7 +18,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack)
{
std::string s = "ABC";
msgpack::type::raw_ref rr1(s.data(), s.size());
msgpack::type::raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();
@@ -33,7 +38,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_8_l)
{
std::string s;
msgpack::type::raw_ref rr1(s.data(), s.size());
msgpack::type::raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();
@@ -50,7 +55,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_8_h)
{
std::string s(0xff, 'A');
msgpack::type::raw_ref rr1(s.data(), s.size());
msgpack::type::raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();
@@ -68,7 +73,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_16_l)
{
std::string s(0xff+1, 'A');
msgpack::type::raw_ref rr1(s.data(), s.size());
msgpack::type::raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();
@@ -87,7 +92,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_16_h)
{
std::string s(0xffff, 'A');
msgpack::type::raw_ref rr1(s.data(), s.size());
msgpack::type::raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();
@@ -106,7 +111,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_32_l)
{
std::string s(0xffff+1, 'A');
msgpack::type::raw_ref rr1(s.data(), s.size());
msgpack::type::raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();
@@ -127,7 +132,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack)
{
std::string s = "ABC";
msgpack::type::v4raw_ref rr1(s.data(), s.size());
msgpack::type::v4raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();
@@ -146,7 +151,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_fix_l)
{
std::string s;
msgpack::type::v4raw_ref rr1(s.data(), s.size());
msgpack::type::v4raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();
@@ -162,7 +167,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_fix_h)
{
std::string s(0x1f, 'A');
msgpack::type::v4raw_ref rr1(s.data(), s.size());
msgpack::type::v4raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();
@@ -179,7 +184,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_16_l)
{
std::string s(0x1f+1, 'A');
msgpack::type::v4raw_ref rr1(s.data(), s.size());
msgpack::type::v4raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();
@@ -198,7 +203,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_16_h)
{
std::string s(0xffff, 'A');
msgpack::type::v4raw_ref rr1(s.data(), s.size());
msgpack::type::v4raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();
@@ -217,7 +222,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_32_l)
{
std::string s(0xffff+1, 'A');
msgpack::type::v4raw_ref rr1(s.data(), s.size());
msgpack::type::v4raw_ref rr1(s.data(), static_cast<uint32_t>(s.size()));
std::stringstream ss;
msgpack::pack(ss, rr1);
std::string packed_str = ss.str();

View File

@@ -1,6 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
TEST(reference, unpack_int)
{
msgpack::sbuffer sbuf;

View File

@@ -1,6 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#if !defined(MSGPACK_USE_CPP03)
TEST(reference, unpack_int)

View File

@@ -1,7 +1,13 @@
#include <msgpack.hpp>
#include <sstream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -1,8 +1,14 @@
#include <msgpack.hpp>
#include <sstream>
#include <iterator>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -1,7 +1,13 @@
#include <sstream>
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
TEST(size_equal_only, array)
{
std::stringstream ss;

View File

@@ -1,5 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#include <sstream>
TEST(streaming, basic)
@@ -168,7 +175,7 @@ public:
while(true) {
pac.reserve_buffer(32*1024);
size_t len = static_cast<size_t>(input.readsome(pac.buffer(), pac.buffer_capacity()));
size_t len = static_cast<size_t>(input.readsome(pac.buffer(), static_cast<std::streamsize>(pac.buffer_capacity())));
if(len == 0) {
return;
@@ -240,7 +247,7 @@ TEST(streaming, basic_compat)
while(count < 3) {
pac.reserve_buffer(32*1024);
size_t len = static_cast<size_t>(input.readsome(pac.buffer(), pac.buffer_capacity()));
size_t len = static_cast<size_t>(input.readsome(pac.buffer(), static_cast<std::streamsize>(pac.buffer_capacity())));
pac.buffer_consumed(len);
while(pac.execute()) {
@@ -276,7 +283,7 @@ public:
while(true) {
pac.reserve_buffer(32*1024);
size_t len = static_cast<size_t>(input.readsome(pac.buffer(), pac.buffer_capacity()));
size_t len = static_cast<size_t>(input.readsome(pac.buffer(), static_cast<std::streamsize>(pac.buffer_capacity())));
if(len == 0) {
return;

View File

@@ -1,5 +1,12 @@
#include <msgpack.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#include <stdio.h>
TEST(streaming, basic)

View File

@@ -1,8 +1,14 @@
#include <msgpack.hpp>
#include <sstream>
#include <iterator>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -2,8 +2,13 @@
#include <string>
#include <cmath>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@@ -1,6 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
TEST(version, print)
{
printf("MSGPACK_VERSION : %s\n", MSGPACK_VERSION);

View File

@@ -1,5 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
#include <sstream>
// To avoid link error

View File

@@ -1,6 +1,12 @@
#include <msgpack.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include <gtest/gtest.h>
#pragma GCC diagnostic pop
TEST(zone, allocate_align)
{
msgpack::zone z;