Fixed -Wextra warnings on gcc.

This commit is contained in:
Takatoshi Kondo
2014-09-02 18:15:58 +09:00
parent d15e49cb73
commit 5896ff3746
17 changed files with 271 additions and 59 deletions

View File

@@ -21,6 +21,7 @@
* @}
*/
#include "msgpack/util.h"
#include "msgpack/object.h"
#include "msgpack/zone.h"
#include "msgpack/pack.h"

View File

@@ -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;

View File

@@ -10582,7 +10582,7 @@ tuple<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16,
inline object const& operator>> (
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 <typename Stream>
const packer<Stream>& operator<< (
packer<Stream>& o,
const type::tuple<>& v) {
const type::tuple<>&) {
o.pack_array(0);
return o;
}
@@ -12263,7 +12263,7 @@ const packer<Stream>& 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;

View File

@@ -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;

View File

@@ -115,16 +115,52 @@ inline packer<Stream>& operator<< (packer<Stream>& 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)

View File

@@ -98,8 +98,14 @@ namespace detail {
template <>
struct object_char_sign<true> {
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; }

View File

@@ -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 <typename Stream>
inline packer<Stream>& operator<< (packer<Stream>& o, const type::nil& v)
inline packer<Stream>& operator<< (packer<Stream>& 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;
}

View File

@@ -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()
{
}

View File

@@ -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<uint32_t>(*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<uint8_t>(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<uint8_t>(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<uint16_t>(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<uint16_t>(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<uint32_t>(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<uint32_t>(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;
}

23
include/msgpack/util.h Normal file
View File

@@ -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 */