From 5896ff3746d12be64db1744af87db0bcff0096a7 Mon Sep 17 00:00:00 2001 From: Takatoshi Kondo Date: Tue, 2 Sep 2014 18:15:58 +0900 Subject: [PATCH] Fixed -Wextra warnings on gcc. --- CMakeLists.txt | 1 + erb/cpp03_define.hpp.erb | 2 +- erb/cpp03_msgpack_tuple.hpp.erb | 6 +- include/msgpack.h | 1 + .../msgpack/adaptor/detail/cpp03_define.hpp | 2 +- .../adaptor/detail/cpp03_msgpack_tuple.hpp | 6 +- .../msgpack/adaptor/detail/cpp11_define.hpp | 2 +- include/msgpack/adaptor/fixint.hpp | 44 +++++- include/msgpack/adaptor/int.hpp | 66 +++++++-- include/msgpack/adaptor/nil.hpp | 6 +- include/msgpack/detail/cpp11_zone.hpp | 4 +- include/msgpack/unpack.hpp | 24 ++-- include/msgpack/util.h | 23 +++ src/Makefile.am | 1 + src/unpack.c | 136 +++++++++++++++--- test/object.cpp | 2 +- test/streaming.cpp | 4 +- 17 files changed, 271 insertions(+), 59 deletions(-) create mode 100644 include/msgpack/util.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f9d07c4..791adb56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ LIST (APPEND msgpack_HEADERS include/msgpack/pack_template.h include/msgpack/unpack_define.h include/msgpack/unpack_template.h + include/msgpack/util.h include/msgpack/sysdep.h include/msgpack/sbuffer.h include/msgpack/version.h diff --git a/erb/cpp03_define.hpp.erb b/erb/cpp03_define.hpp.erb index 04c6a0fe..27d165e0 100644 --- a/erb/cpp03_define.hpp.erb +++ b/erb/cpp03_define.hpp.erb @@ -82,7 +82,7 @@ struct define<> { { if(o.type != type::ARRAY) { throw type_error(); } } - void msgpack_object(msgpack::object* o, msgpack::zone& z) const + void msgpack_object(msgpack::object* o, msgpack::zone&) const { o->type = type::ARRAY; o->via.array.ptr = nullptr; diff --git a/erb/cpp03_msgpack_tuple.hpp.erb b/erb/cpp03_msgpack_tuple.hpp.erb index f748ccfd..930f5368 100644 --- a/erb/cpp03_msgpack_tuple.hpp.erb +++ b/erb/cpp03_msgpack_tuple.hpp.erb @@ -135,7 +135,7 @@ tuple, A<%=j%><%}%>> make_tuple(typename tuple_type::tr inline object const& operator>> ( object const& o, - type::tuple<>& v) { + type::tuple<>&) { if(o.type != type::ARRAY) { throw type_error(); } return o; } @@ -155,7 +155,7 @@ object const& operator>> ( template const packer& operator<< ( packer& o, - const type::tuple<>& v) { + const type::tuple<>&) { o.pack_array(0); return o; } @@ -173,7 +173,7 @@ const packer& operator<< ( inline void operator<< ( object::with_zone& o, - const type::tuple<>& v) { + const type::tuple<>&) { o.type = type::ARRAY; o.via.array.ptr = nullptr; o.via.array.size = 0; diff --git a/include/msgpack.h b/include/msgpack.h index 082edb84..5bb4494b 100644 --- a/include/msgpack.h +++ b/include/msgpack.h @@ -21,6 +21,7 @@ * @} */ +#include "msgpack/util.h" #include "msgpack/object.h" #include "msgpack/zone.h" #include "msgpack/pack.h" diff --git a/include/msgpack/adaptor/detail/cpp03_define.hpp b/include/msgpack/adaptor/detail/cpp03_define.hpp index 675690c2..8e2b4b2a 100644 --- a/include/msgpack/adaptor/detail/cpp03_define.hpp +++ b/include/msgpack/adaptor/detail/cpp03_define.hpp @@ -82,7 +82,7 @@ struct define<> { { if(o.type != type::ARRAY) { throw type_error(); } } - void msgpack_object(msgpack::object* o, msgpack::zone& z) const + void msgpack_object(msgpack::object* o, msgpack::zone&) const { o->type = type::ARRAY; o->via.array.ptr = nullptr; diff --git a/include/msgpack/adaptor/detail/cpp03_msgpack_tuple.hpp b/include/msgpack/adaptor/detail/cpp03_msgpack_tuple.hpp index d17fd703..8be8dd71 100644 --- a/include/msgpack/adaptor/detail/cpp03_msgpack_tuple.hpp +++ b/include/msgpack/adaptor/detail/cpp03_msgpack_tuple.hpp @@ -10582,7 +10582,7 @@ tuple> ( object const& o, - type::tuple<>& v) { + type::tuple<>&) { if(o.type != type::ARRAY) { throw type_error(); } return o; } @@ -11439,7 +11439,7 @@ object const& operator>> ( template const packer& operator<< ( packer& o, - const type::tuple<>& v) { + const type::tuple<>&) { o.pack_array(0); return o; } @@ -12263,7 +12263,7 @@ const packer& operator<< ( inline void operator<< ( object::with_zone& o, - const type::tuple<>& v) { + const type::tuple<>&) { o.type = type::ARRAY; o.via.array.ptr = nullptr; o.via.array.size = 0; diff --git a/include/msgpack/adaptor/detail/cpp11_define.hpp b/include/msgpack/adaptor/detail/cpp11_define.hpp index 795a1184..eb955316 100644 --- a/include/msgpack/adaptor/detail/cpp11_define.hpp +++ b/include/msgpack/adaptor/detail/cpp11_define.hpp @@ -145,7 +145,7 @@ struct define<> { { if(o.type != type::ARRAY) { throw type_error(); } } - void msgpack_object(msgpack::object* o, msgpack::zone& z) const + void msgpack_object(msgpack::object* o, msgpack::zone&) const { o->type = type::ARRAY; o->via.array.ptr = NULL; diff --git a/include/msgpack/adaptor/fixint.hpp b/include/msgpack/adaptor/fixint.hpp index 3deccd10..b395850a 100644 --- a/include/msgpack/adaptor/fixint.hpp +++ b/include/msgpack/adaptor/fixint.hpp @@ -115,16 +115,52 @@ inline packer& operator<< (packer& o, const type::fix_uint64& v) inline void operator<< (object& o, type::fix_int8 v) - { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); } +{ + if (v.get() < 0) { + o.type = type::NEGATIVE_INTEGER; + o.via.i64 = v.get(); + } + else { + o.type = type::POSITIVE_INTEGER; + o.via.u64 = v.get(); + } +} inline void operator<< (object& o, type::fix_int16 v) - { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); } +{ + if(v.get() < 0) { + o.type = type::NEGATIVE_INTEGER; + o.via.i64 = v.get(); + } + else { + o.type = type::POSITIVE_INTEGER; + o.via.u64 = v.get(); + } +} inline void operator<< (object& o, type::fix_int32 v) - { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); } +{ + if (v.get() < 0) { + o.type = type::NEGATIVE_INTEGER; + o.via.i64 = v.get(); + } + else { + o.type = type::POSITIVE_INTEGER; + o.via.u64 = v.get(); + } +} inline void operator<< (object& o, type::fix_int64 v) - { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); } +{ + if (v.get() < 0) { + o.type = type::NEGATIVE_INTEGER; + o.via.i64 = v.get(); + } + else { + o.type = type::POSITIVE_INTEGER; + o.via.u64 = v.get(); + } +} inline void operator<< (object& o, type::fix_uint8 v) diff --git a/include/msgpack/adaptor/int.hpp b/include/msgpack/adaptor/int.hpp index 726bf7d3..305af663 100644 --- a/include/msgpack/adaptor/int.hpp +++ b/include/msgpack/adaptor/int.hpp @@ -98,8 +98,14 @@ namespace detail { template <> struct object_char_sign { static inline void make(object& o, char v) { - v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v - : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; + if (v < 0) { + o.type = type::NEGATIVE_INTEGER; + o.via.i64 = v; + } + else { + o.type = type::POSITIVE_INTEGER; + o.via.u64 = v; + } } }; @@ -205,20 +211,64 @@ inline void operator<< (object& o, char v) inline void operator<< (object& o, signed char v) - { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; } +{ + if (v < 0) { + o.type = type::NEGATIVE_INTEGER; + o.via.i64 = v; + } + else { + o.type = type::POSITIVE_INTEGER; + o.via.u64 = v; + } +} inline void operator<< (object& o, signed short v) - { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; } +{ + if (v < 0) { + o.type = type::NEGATIVE_INTEGER; + o.via.i64 = v; + } + else { + o.type = type::POSITIVE_INTEGER; + o.via.u64 = v; + } +} inline void operator<< (object& o, signed int v) - { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; } +{ + if (v < 0) { + o.type = type::NEGATIVE_INTEGER; + o.via.i64 = v; + } + else { + o.type = type::POSITIVE_INTEGER; + o.via.u64 = v; + } +} inline void operator<< (object& o, signed long v) - { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; } +{ + if (v < 0) { + o.type = type::NEGATIVE_INTEGER; + o.via.i64 = v; + } + else { + o.type = type::POSITIVE_INTEGER; + o.via.u64 = v; + } +} inline void operator<< (object& o, signed long long v) - { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; } - +{ + if (v < 0) { + o.type = type::NEGATIVE_INTEGER; + o.via.i64 = v; + } + else{ + o.type = type::POSITIVE_INTEGER; + o.via.u64 = v; + } +} inline void operator<< (object& o, unsigned char v) { o.type = type::POSITIVE_INTEGER, o.via.u64 = v; } diff --git a/include/msgpack/adaptor/nil.hpp b/include/msgpack/adaptor/nil.hpp index 9f8a12ea..f52d4ffe 100644 --- a/include/msgpack/adaptor/nil.hpp +++ b/include/msgpack/adaptor/nil.hpp @@ -29,20 +29,20 @@ struct nil { }; } // namespace type -inline object const& operator>> (object const& o, type::nil& v) +inline object const& operator>> (object const& o, type::nil&) { if(o.type != type::NIL) { throw type_error(); } return o; } template -inline packer& operator<< (packer& o, const type::nil& v) +inline packer& operator<< (packer& o, const type::nil&) { o.pack_nil(); return o; } -inline void operator<< (object& o, type::nil v) +inline void operator<< (object& o, type::nil) { o.type = type::NIL; } diff --git a/include/msgpack/detail/cpp11_zone.hpp b/include/msgpack/detail/cpp11_zone.hpp index 574ee8c7..f768f008 100644 --- a/include/msgpack/detail/cpp11_zone.hpp +++ b/include/msgpack/detail/cpp11_zone.hpp @@ -207,11 +207,11 @@ public: { ::free(p); } - static void* operator new(std::size_t size, void* mem) throw() + static void* operator new(std::size_t /*size*/, void* mem) throw() { return mem; } - static void operator delete(void *p, void* mem) throw() + static void operator delete(void * /*p*/, void* /*mem*/) throw() { } diff --git a/include/msgpack/unpack.hpp b/include/msgpack/unpack.hpp index 652bbcbd..8c334a7e 100644 --- a/include/msgpack/unpack.hpp +++ b/include/msgpack/unpack.hpp @@ -149,7 +149,7 @@ inline void unpack_map_item(object& c, object const& k, object const& v) ++c.via.map.size; } -inline void unpack_str(unpack_user& u, const char* b, const char* p, uint64_t l, object& o) +inline void unpack_str(unpack_user& u, const char* p, uint64_t l, object& o) { o.type = type::STR; if (u.reference_func() && u.reference_func()(o.type, l, u.user_data())) { @@ -164,7 +164,7 @@ inline void unpack_str(unpack_user& u, const char* b, const char* p, uint64_t l, o.via.str.size = l; } -inline void unpack_bin(unpack_user& u, const char* b, const char* p, uint64_t l, object& o) +inline void unpack_bin(unpack_user& u, const char* p, uint64_t l, object& o) { o.type = type::BIN; if (u.reference_func() && u.reference_func()(o.type, l, u.user_data())) { @@ -370,7 +370,7 @@ public: } else if(0xa0 <= selector && selector <= 0xbf) { // FixStr m_trail = static_cast(*m_current) & 0x1f; if(m_trail == 0) { - unpack_str(m_user, data, n, m_trail, obj); + unpack_str(m_user, n, m_trail, obj); int ret = push_proc(obj, off); if (ret != 0) return ret; } @@ -523,7 +523,7 @@ public: load(tmp, n); m_trail = tmp; if(m_trail == 0) { - unpack_str(m_user, data, n, m_trail, obj); + unpack_str(m_user, n, m_trail, obj); int ret = push_proc(obj, off); if (ret != 0) return ret; } @@ -537,7 +537,7 @@ public: load(tmp, n); m_trail = tmp; if(m_trail == 0) { - unpack_bin(m_user, data, n, m_trail, obj); + unpack_bin(m_user, n, m_trail, obj); int ret = push_proc(obj, off); if (ret != 0) return ret; } @@ -565,7 +565,7 @@ public: load(tmp, n); m_trail = tmp; if(m_trail == 0) { - unpack_str(m_user, data, n, m_trail, obj); + unpack_str(m_user, n, m_trail, obj); int ret = push_proc(obj, off); if (ret != 0) return ret; } @@ -579,7 +579,7 @@ public: load(tmp, n); m_trail = tmp; if(m_trail == 0) { - unpack_bin(m_user, data, n, m_trail, obj); + unpack_bin(m_user, n, m_trail, obj); int ret = push_proc(obj, off); if (ret != 0) return ret; } @@ -607,7 +607,7 @@ public: load(tmp, n); m_trail = tmp; if(m_trail == 0) { - unpack_str(m_user, data, n, m_trail, obj); + unpack_str(m_user, n, m_trail, obj); int ret = push_proc(obj, off); if (ret != 0) return ret; } @@ -621,7 +621,7 @@ public: load(tmp, n); m_trail = tmp; if(m_trail == 0) { - unpack_bin(m_user, data, n, m_trail, obj); + unpack_bin(m_user, n, m_trail, obj); int ret = push_proc(obj, off); if (ret != 0) return ret; } @@ -645,12 +645,12 @@ public: } } break; case ACS_STR_VALUE: { - unpack_str(m_user, data, n, m_trail, obj); + unpack_str(m_user, n, m_trail, obj); int ret = push_proc(obj, off); if (ret != 0) return ret; } break; case ACS_BIN_VALUE: { - unpack_bin(m_user, data, n, m_trail, obj); + unpack_bin(m_user, n, m_trail, obj); int ret = push_proc(obj, off); if (ret != 0) return ret; } break; @@ -1379,7 +1379,7 @@ inline void unpack(unpacked* result, else unpack(*result, data, len, f, user_data); } -bool unpacker::default_reference_func(type::object_type type, uint64_t len, void*) +bool unpacker::default_reference_func(type::object_type /*type*/, uint64_t /*len*/, void*) { return true; } diff --git a/include/msgpack/util.h b/include/msgpack/util.h new file mode 100644 index 00000000..89b98a18 --- /dev/null +++ b/include/msgpack/util.h @@ -0,0 +1,23 @@ +/* + * MessagePack for C utilities + * + * Copyright (C) 2014 FURUHASHI Sadayuki + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MSGPACK_UTIL_H +#define MSGPACK_UTIL_H + +#define MSGPACK_UNUSED(a) (void)(a) + +#endif /* MSGPACK_UTIL_H */ diff --git a/src/Makefile.am b/src/Makefile.am index 1528d20e..039aeacd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,6 +36,7 @@ nobase_include_HEADERS = \ ../include/msgpack/pack_template.h \ ../include/msgpack/unpack_define.h \ ../include/msgpack/unpack_template.h \ + ../include/msgpack/util.h \ ../include/msgpack/sysdep.h \ ../include/msgpack.h \ ../include/msgpack/sbuffer.h \ diff --git a/src/unpack.c b/src/unpack.c index 8b68efe6..93a8d7c3 100644 --- a/src/unpack.c +++ b/src/unpack.c @@ -17,6 +17,7 @@ */ #include "msgpack/unpack.h" #include "msgpack/unpack_define.h" +#include "msgpack/util.h" #include #ifdef _msgpack_atomic_counter_header @@ -56,50 +57,143 @@ static int template_execute( static inline msgpack_object template_callback_root(unpack_user* u) -{ msgpack_object o = { MSGPACK_OBJECT_NIL }; return o; } +{ + MSGPACK_UNUSED(u); + msgpack_object o; + o.type = MSGPACK_OBJECT_NIL; + return o; +} static inline int template_callback_uint8(unpack_user* u, uint8_t d, msgpack_object* o) -{ o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; } +{ + MSGPACK_UNUSED(u); + o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; + o->via.u64 = d; + return 0; +} static inline int template_callback_uint16(unpack_user* u, uint16_t d, msgpack_object* o) -{ o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; } +{ + MSGPACK_UNUSED(u); + o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; + o->via.u64 = d; + return 0; +} static inline int template_callback_uint32(unpack_user* u, uint32_t d, msgpack_object* o) -{ o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; } +{ + MSGPACK_UNUSED(u); + o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; + o->via.u64 = d; + return 0; +} static inline int template_callback_uint64(unpack_user* u, uint64_t d, msgpack_object* o) -{ o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = d; return 0; } +{ + MSGPACK_UNUSED(u); + o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; + o->via.u64 = d; + return 0; +} static inline int template_callback_int8(unpack_user* u, int8_t d, msgpack_object* o) -{ if(d >= 0) { o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = (uint64_t)d; return 0; } - else { o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; o->via.i64 = d; return 0; } } +{ + MSGPACK_UNUSED(u); + if(d >= 0) { + o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; + o->via.u64 = (uint64_t)d; + return 0; + } + else { + o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; + o->via.i64 = d; + return 0; + } +} static inline int template_callback_int16(unpack_user* u, int16_t d, msgpack_object* o) -{ if(d >= 0) { o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = (uint64_t)d; return 0; } - else { o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; o->via.i64 = d; return 0; } } +{ + MSGPACK_UNUSED(u); + if(d >= 0) { + o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; + o->via.u64 = (uint64_t)d; + return 0; + } + else { + o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; + o->via.i64 = d; + return 0; + } +} static inline int template_callback_int32(unpack_user* u, int32_t d, msgpack_object* o) -{ if(d >= 0) { o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = (uint64_t)d; return 0; } - else { o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; o->via.i64 = d; return 0; } } +{ + MSGPACK_UNUSED(u); + if(d >= 0) { + o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; + o->via.u64 = (uint64_t)d; + return 0; + } + else { + o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; + o->via.i64 = d; + return 0; + } +} static inline int template_callback_int64(unpack_user* u, int64_t d, msgpack_object* o) -{ if(d >= 0) { o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; o->via.u64 = (uint64_t)d; return 0; } - else { o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; o->via.i64 = d; return 0; } } +{ + MSGPACK_UNUSED(u); + if(d >= 0) { + o->type = MSGPACK_OBJECT_POSITIVE_INTEGER; + o->via.u64 = (uint64_t)d; + return 0; + } + else { + o->type = MSGPACK_OBJECT_NEGATIVE_INTEGER; + o->via.i64 = d; + return 0; + } +} static inline int template_callback_float(unpack_user* u, float d, msgpack_object* o) -{ o->type = MSGPACK_OBJECT_DOUBLE; o->via.dec = d; return 0; } +{ + MSGPACK_UNUSED(u); + o->type = MSGPACK_OBJECT_DOUBLE; + o->via.dec = d; + return 0; +} static inline int template_callback_double(unpack_user* u, double d, msgpack_object* o) -{ o->type = MSGPACK_OBJECT_DOUBLE; o->via.dec = d; return 0; } +{ + MSGPACK_UNUSED(u); + o->type = MSGPACK_OBJECT_DOUBLE; + o->via.dec = d; + return 0; +} static inline int template_callback_nil(unpack_user* u, msgpack_object* o) -{ o->type = MSGPACK_OBJECT_NIL; return 0; } +{ + MSGPACK_UNUSED(u); + o->type = MSGPACK_OBJECT_NIL; + return 0; +} static inline int template_callback_true(unpack_user* u, msgpack_object* o) -{ o->type = MSGPACK_OBJECT_BOOLEAN; o->via.boolean = true; return 0; } +{ + MSGPACK_UNUSED(u); + o->type = MSGPACK_OBJECT_BOOLEAN; + o->via.boolean = true; + return 0; +} static inline int template_callback_false(unpack_user* u, msgpack_object* o) -{ o->type = MSGPACK_OBJECT_BOOLEAN; o->via.boolean = false; return 0; } +{ + MSGPACK_UNUSED(u); + o->type = MSGPACK_OBJECT_BOOLEAN; + o->via.boolean = false; + return 0; +} static inline int template_callback_array(unpack_user* u, unsigned int n, msgpack_object* o) { @@ -112,6 +206,7 @@ static inline int template_callback_array(unpack_user* u, unsigned int n, msgpac static inline int template_callback_array_item(unpack_user* u, msgpack_object* c, msgpack_object o) { + MSGPACK_UNUSED(u); #if defined(__GNUC__) && !defined(__clang__) memcpy(&c->via.array.ptr[c->via.array.size], &o, sizeof(msgpack_object)); #else /* __GNUC__ && !__clang__ */ @@ -132,6 +227,7 @@ static inline int template_callback_map(unpack_user* u, unsigned int n, msgpack_ static inline int template_callback_map_item(unpack_user* u, msgpack_object* c, msgpack_object k, msgpack_object v) { + MSGPACK_UNUSED(u); #if defined(__GNUC__) && !defined(__clang__) memcpy(&c->via.map.ptr[c->via.map.size].key, &k, sizeof(msgpack_object)); memcpy(&c->via.map.ptr[c->via.map.size].val, &v, sizeof(msgpack_object)); @@ -145,6 +241,8 @@ static inline int template_callback_map_item(unpack_user* u, msgpack_object* c, static inline int template_callback_str(unpack_user* u, const char* b, const char* p, unsigned int l, msgpack_object* o) { + MSGPACK_UNUSED(u); + MSGPACK_UNUSED(b); o->type = MSGPACK_OBJECT_STR; o->via.str.ptr = p; o->via.str.size = l; @@ -154,6 +252,8 @@ static inline int template_callback_str(unpack_user* u, const char* b, const cha static inline int template_callback_bin(unpack_user* u, const char* b, const char* p, unsigned int l, msgpack_object* o) { + MSGPACK_UNUSED(u); + MSGPACK_UNUSED(b); o->type = MSGPACK_OBJECT_BIN; o->via.bin.ptr = p; o->via.bin.size = l; diff --git a/test/object.cpp b/test/object.cpp index 88490fb5..0cb5c889 100644 --- a/test/object.cpp +++ b/test/object.cpp @@ -5,7 +5,7 @@ struct myclass { myclass() : num(0), str("default") { } myclass(int num, const std::string& str) : - num(0), str("default") { } + num(num), str(str) { } ~myclass() { } diff --git a/test/streaming.cpp b/test/streaming.cpp index 2daa98a1..b9d2199e 100644 --- a/test/streaming.cpp +++ b/test/streaming.cpp @@ -175,7 +175,7 @@ public: } } - void on_message(msgpack::object obj, msgpack::unique_ptr z) + void on_message(msgpack::object obj, msgpack::unique_ptr) { EXPECT_EQ(expect, obj.as()); } @@ -283,7 +283,7 @@ public: } } - void on_message(msgpack::object obj, msgpack::unique_ptr z) + void on_message(msgpack::object obj, msgpack::unique_ptr) { EXPECT_EQ(expect, obj.as()); }