Skip to content

Commit

Permalink
Merge pull request #13458 from tchaikov/wip-silence-gcc-warnings
Browse files Browse the repository at this point in the history
include/denc, kv: silence gcc warnings

Reviewed-by: Adam C. Emerson <aemerson@redhat.com>
Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
tchaikov committed Feb 18, 2017
2 parents 9d7dd22 + 7251ea5 commit 5e98ce9
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 90 deletions.
154 changes: 78 additions & 76 deletions src/include/denc.h

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/include/fs_types.h
Expand Up @@ -30,9 +30,9 @@ WRITE_CLASS_ENCODER(inodeno_t)

template<>
struct denc_traits<inodeno_t> {
enum { supported = 2 };
enum { featured = false };
enum { bounded = true };
static constexpr bool supported = true;
static constexpr bool featured = false;
static constexpr bool bounded = true;
static void bound_encode(const inodeno_t &o, size_t& p) {
denc(o.val, p);
}
Expand Down
6 changes: 3 additions & 3 deletions src/include/interval_set.h
Expand Up @@ -558,9 +558,9 @@ class interval_set {
// want to include _nohead variants.
template<typename T>
struct denc_traits<interval_set<T>> {
enum { supported = true };
enum { bounded = false };
enum { featured = false };
static constexpr bool supported = true;
static constexpr bool bounded = false;
static constexpr bool featured = false;
static void bound_encode(const interval_set<T>& v, size_t& p) {
v.bound_encode(p);
}
Expand Down
6 changes: 3 additions & 3 deletions src/include/object.h
Expand Up @@ -124,9 +124,9 @@ inline void decode(snapid_t &i, bufferlist::iterator &p) { decode(i.val, p); }

template<>
struct denc_traits<snapid_t> {
enum { supported = 2 };
enum { featured = false };
enum { bounded = true };
static constexpr bool supported = true;
static constexpr bool featured = false;
static constexpr bool bounded = true;
static void bound_encode(const snapid_t& o, size_t& p) {
denc(o.val, p);
}
Expand Down
6 changes: 5 additions & 1 deletion src/kv/LevelDBStore.h
Expand Up @@ -190,12 +190,14 @@ class LevelDBStore : public KeyValueDB {
const string &prefix,
const string &k,
const bufferlist &bl);
using KeyValueDB::TransactionImpl::set;
void rmkey(
const string &prefix,
const string &k);
void rmkeys_by_prefix(
const string &prefix
);
using KeyValueDB::TransactionImpl::rmkey;
};

KeyValueDB::Transaction get_transaction() {
Expand All @@ -213,7 +215,9 @@ class LevelDBStore : public KeyValueDB {
int get(const string &prefix,
const string &key,
bufferlist *value);


using KeyValueDB::get;

class LevelDBWholeSpaceIteratorImpl :
public KeyValueDB::WholeSpaceIteratorImpl {
protected:
Expand Down
6 changes: 5 additions & 1 deletion src/kv/MemDB.h
Expand Up @@ -86,7 +86,9 @@ class MemDB : public KeyValueDB

void set(const std::string &prefix, const std::string &key,
const bufferlist &val);
using KeyValueDB::TransactionImpl::set;
void rmkey(const std::string &prefix, const std::string &k);
using KeyValueDB::TransactionImpl::rmkey;
void rmkeys_by_prefix(const std::string &prefix);

void merge(const std::string &prefix, const std::string &key, const bufferlist &value);
Expand Down Expand Up @@ -127,11 +129,13 @@ class MemDB : public KeyValueDB
int submit_transaction_sync(Transaction);

int get(const std::string &prefix, const std::set<std::string> &key,
std::map<std::string, bufferlist> *out);
std::map<std::string, bufferlist> *out) override;

int get(const std::string &prefix, const std::string &key,
bufferlist *out) override;

using KeyValueDB::get;

class MDBWholeSpaceIteratorImpl : public KeyValueDB::WholeSpaceIteratorImpl {

mdb_iter_t m_iter;
Expand Down
6 changes: 3 additions & 3 deletions src/os/bluestore/bluestore_types.h
Expand Up @@ -160,9 +160,9 @@ typedef mempool::bluestore_meta_other::vector<bluestore_pextent_t> PExtentVector

template<>
struct denc_traits<PExtentVector> {
enum { supported = true };
enum { bounded = false };
enum { featured = false };
static constexpr bool supported = true;
static constexpr bool bounded = false;
static constexpr bool featured = false;
static void bound_encode(const PExtentVector& v, size_t& p) {
p += sizeof(uint32_t);
size_t per = 0;
Expand Down
56 changes: 56 additions & 0 deletions src/test/encoding.cc
Expand Up @@ -201,6 +201,62 @@ TEST(EncodingRoundTrip, MultimapConstructorCounter) {
EXPECT_EQ(my_val_t::get_assigns(), 0);
}

// make sure that the legacy encode/decode methods are selected
// over the ones defined using templates. the later is likely to
// be slower, see also the definition of "WRITE_INT_DENC" in
// include/denc.h
template<>
void encode<uint64_t, denc_traits<uint64_t>>(const uint64_t&,
bufferlist&,
uint64_t f) {
static_assert(denc_traits<uint64_t>::supported,
"should support new encoder");
static_assert(!denc_traits<uint64_t>::featured,
"should not be featured");
ASSERT_EQ(0UL, f);
// make sure the test fails if i get called
ASSERT_TRUE(false);
}

template<>
void encode<ceph_le64, denc_traits<ceph_le64>>(const ceph_le64&,
bufferlist&,
uint64_t f) {
static_assert(denc_traits<ceph_le64>::supported,
"should support new encoder");
static_assert(!denc_traits<ceph_le64>::featured,
"should not be featured");
ASSERT_EQ(0UL, f);
// make sure the test fails if i get called
ASSERT_TRUE(false);
}

TEST(EncodingRoundTrip, Integers) {
// int types
{
uint64_t i = 42;
test_encode_and_decode(i);
}
{
int16_t i = 42;
test_encode_and_decode(i);
}
{
bool b = true;
test_encode_and_decode(b);
}
{
bool b = false;
test_encode_and_decode(b);
}
// raw encoder
{
ceph_le64 i;
i = 42;
test_encode_and_decode(i);
}
}

const char* expected_what[] = {
"buffer::malformed_input: void lame_decoder(int) unknown encoding version > 100",
"buffer::malformed_input: void lame_decoder(int) no longer understand old encoding version < 100",
Expand Down

0 comments on commit 5e98ce9

Please sign in to comment.