Fixed warnings on MSVC.

This commit is contained in:
Takatoshi Kondo
2015-08-12 12:51:12 +09:00
parent 4501551267
commit e50cc5d79f
5 changed files with 18 additions and 8 deletions

View File

@@ -92,7 +92,12 @@ TEST(buffer, zbuffer_c)
TEST(buffer, fbuffer) TEST(buffer, fbuffer)
{ {
#if defined(_MSC_VER)
FILE* file;
tmpfile_s(&file);
#else // defined(_MSC_VER)
FILE* file = tmpfile(); FILE* file = tmpfile();
#endif // defined(_MSC_VER)
EXPECT_TRUE( file != NULL ); EXPECT_TRUE( file != NULL );
msgpack::fbuffer fbuf(file); msgpack::fbuffer fbuf(file);
@@ -116,7 +121,13 @@ TEST(buffer, fbuffer)
TEST(buffer, fbuffer_c) TEST(buffer, fbuffer_c)
{ {
#if defined(_MSC_VER)
FILE* file;
tmpfile_s(&file);
#else // defined(_MSC_VER)
FILE* file = tmpfile(); FILE* file = tmpfile();
#endif // defined(_MSC_VER)
void* fbuf = (void*)file; void* fbuf = (void*)file;
EXPECT_TRUE( file != NULL ); EXPECT_TRUE( file != NULL );

View File

@@ -11,7 +11,7 @@ static void feed_file(msgpack::unpacker& pac, const char* path)
if(fin.bad()) { if(fin.bad()) {
throw std::runtime_error("read failed"); throw std::runtime_error("read failed");
} }
pac.buffer_consumed(fin.gcount()); pac.buffer_consumed(static_cast<size_t>(fin.gcount()));
if(fin.fail()) { if(fin.fail()) {
break; break;
} }
@@ -35,4 +35,3 @@ TEST(cases, format)
EXPECT_FALSE( pac_compact.next(&result) ); EXPECT_FALSE( pac_compact.next(&result) );
} }

View File

@@ -585,7 +585,7 @@ TEST(MSGPACK_STL, simple_buffer_non_const_cstring)
val1 += 'a' + rand() % 26; val1 += 'a' + rand() % 26;
msgpack::sbuffer sbuf; msgpack::sbuffer sbuf;
char* s = new char[val1.size() + 1]; char* s = new char[val1.size() + 1];
std::strcpy(s, val1.c_str()); std::memcpy(s, val1.c_str(), val1.size() + 1);
msgpack::pack(sbuf, s); msgpack::pack(sbuf, s);
delete [] s; delete [] s;
msgpack::unpacked ret; msgpack::unpacked ret;

View File

@@ -92,8 +92,8 @@ TEST(MSGPACK_RAW_REF, pack_unpack_16_h)
msgpack::pack(ss, rr1); msgpack::pack(ss, rr1);
std::string packed_str = ss.str(); std::string packed_str = ss.str();
EXPECT_EQ(packed_str[0], static_cast<char>(0xc5u)); EXPECT_EQ(packed_str[0], static_cast<char>(0xc5u));
EXPECT_EQ(packed_str[1], static_cast<char>(0xff)); EXPECT_EQ(packed_str[1], static_cast<char>(0xffu));
EXPECT_EQ(packed_str[2], static_cast<char>(0xff)); EXPECT_EQ(packed_str[2], static_cast<char>(0xffu));
EXPECT_EQ(packed_str[3], 'A'); EXPECT_EQ(packed_str[3], 'A');
msgpack::unpacked upd; msgpack::unpacked upd;

View File

@@ -156,7 +156,7 @@ public:
while(true) { while(true) {
pac.reserve_buffer(32*1024); pac.reserve_buffer(32*1024);
size_t len = input.readsome(pac.buffer(), pac.buffer_capacity()); size_t len = static_cast<size_t>(input.readsome(pac.buffer(), pac.buffer_capacity()));
if(len == 0) { if(len == 0) {
return; return;
@@ -226,7 +226,7 @@ TEST(streaming, basic_compat)
while(count < 3) { while(count < 3) {
pac.reserve_buffer(32*1024); pac.reserve_buffer(32*1024);
size_t len = input.readsome(pac.buffer(), pac.buffer_capacity()); size_t len = static_cast<size_t>(input.readsome(pac.buffer(), pac.buffer_capacity()));
pac.buffer_consumed(len); pac.buffer_consumed(len);
while(pac.execute()) { while(pac.execute()) {
@@ -262,7 +262,7 @@ public:
while(true) { while(true) {
pac.reserve_buffer(32*1024); pac.reserve_buffer(32*1024);
size_t len = input.readsome(pac.buffer(), pac.buffer_capacity()); size_t len = static_cast<size_t>(input.readsome(pac.buffer(), pac.buffer_capacity()));
if(len == 0) { if(len == 0) {
return; return;