]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: Use unqualified encoding in some files
authorAdam C. Emerson <aemerson@redhat.com>
Fri, 22 Dec 2017 04:06:37 +0000 (23:06 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Wed, 10 Jan 2018 19:02:09 +0000 (14:02 -0500)
bit_vector.hpp and bloom_filter.cc to be specific.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/cls/lock/cls_lock.cc
src/cls/lock/cls_lock_types.h
src/cls/rbd/cls_rbd.cc
src/cls/rbd/cls_rbd_client.cc
src/common/bit_vector.hpp
src/common/bloom_filter.cc
src/test/common/test_bit_vector.cc
src/test/encoding/ceph_dencoder.cc
src/test/librbd/object_map/test_mock_RefreshRequest.cc

index 6e2ae4bbd1d1699570f0fd2745b640d02c55b835..32c70143f5730130e718f4d2d97ff5d8c830da88 100644 (file)
@@ -54,7 +54,7 @@ static int read_lock(cls_method_context_t hctx, const string& name, lock_info_t
 
   try {
     bufferlist::iterator it = bl.begin();
-    ::decode(*lock, it);
+    decode(*lock, it);
   } catch (const buffer::error &err) {
     CLS_ERR("error decoding %s", key.c_str());
     return -EIO;
@@ -88,7 +88,7 @@ static int write_lock(cls_method_context_t hctx, const string& name, const lock_
   key.append(name);
 
   bufferlist lock_bl;
-  ::encode(lock, lock_bl, cls_get_client_features(hctx));
+  encode(lock, lock_bl, cls_get_client_features(hctx));
 
   int r = cls_cxx_setxattr(hctx, key.c_str(), &lock_bl);
   if (r < 0)
index 36d39c89014c67c596cf443bf1c7e3e772a7264b..e28a312d1066745a7e38815a4966f32af25ddbf8 100644 (file)
@@ -129,8 +129,5 @@ namespace rados {
     }
   }
 }
-WRITE_CLASS_ENCODER_FEATURES(rados::cls::lock::locker_info_t)
-WRITE_CLASS_ENCODER(rados::cls::lock::locker_id_t)
-WRITE_CLASS_ENCODER_FEATURES(rados::cls::lock::lock_info_t)
 
 #endif
index 08f06985c29c9a3ca0ba5f0db128ac3054862674..3932180a841a1bab5e53fa27e1c5576d07ade6f8 100644 (file)
@@ -2284,7 +2284,7 @@ int object_map_read(cls_method_context_t hctx, BitVector<2> &object_map)
 
   try {
     bufferlist::iterator iter = bl.begin();
-    ::decode(object_map, iter);
+    decode(object_map, iter);
   } catch (const buffer::error &err) {
     CLS_ERR("failed to decode object map: %s", err.what());
     return -EINVAL;
@@ -2311,7 +2311,7 @@ int object_map_load(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   }
 
   object_map.set_crc_enabled(false);
-  ::encode(object_map, *out);
+  encode(object_map, *out);
   return 0;
 }
 
@@ -2329,7 +2329,7 @@ int object_map_save(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   BitVector<2> object_map;
   try {
     bufferlist::iterator iter = in->begin();
-    ::decode(object_map, iter);
+    decode(object_map, iter);
   } catch (const buffer::error &err) {
     return -EINVAL;
   }
@@ -2337,7 +2337,7 @@ int object_map_save(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
   object_map.set_crc_enabled(true);
 
   bufferlist bl;
-  ::encode(object_map, bl);
+  encode(object_map, bl);
   CLS_LOG(20, "object_map_save: object size=%" PRIu64 ", byte size=%u",
          object_map.size(), bl.length());
   return cls_cxx_write_full(hctx, &bl);
@@ -2394,7 +2394,7 @@ int object_map_resize(cls_method_context_t hctx, bufferlist *in, bufferlist *out
   }
 
   bufferlist map;
-  ::encode(object_map, map);
+  encode(object_map, map);
   CLS_LOG(20, "object_map_resize: object size=%" PRIu64 ", byte size=%u",
          object_count, map.length());
   return cls_cxx_write_full(hctx, &map);
@@ -2567,7 +2567,7 @@ int object_map_snap_add(cls_method_context_t hctx, bufferlist *in,
 
   if (updated) {
     bufferlist bl;
-    ::encode(object_map, bl);
+    encode(object_map, bl);
     r = cls_cxx_write_full(hctx, &bl);
   }
   return r;
@@ -2589,7 +2589,7 @@ int object_map_snap_remove(cls_method_context_t hctx, bufferlist *in,
   BitVector<2> src_object_map;
   try {
     bufferlist::iterator iter = in->begin();
-    ::decode(src_object_map, iter);
+    decode(src_object_map, iter);
   } catch (const buffer::error &err) {
     return -EINVAL;
   }
@@ -2611,7 +2611,7 @@ int object_map_snap_remove(cls_method_context_t hctx, bufferlist *in,
 
   if (updated) {
     bufferlist bl;
-    ::encode(dst_object_map, bl);
+    encode(dst_object_map, bl);
     r = cls_cxx_write_full(hctx, &bl);
   }
   return r;
index 90c25c6bcc2956fb0a6e737231cae1efdf932275..9e12ab61584926b629d8f5bf13ac8ac88488ba57 100644 (file)
@@ -1176,7 +1176,7 @@ namespace librbd {
     int object_map_load_finish(bufferlist::iterator *it,
                                ceph::BitVector<2> *object_map) {
       try {
-        ::decode(*object_map, *it);
+        decode(*object_map, *it);
       } catch (const buffer::error &err) {
         return -EBADMSG;
       }
@@ -1206,7 +1206,7 @@ namespace librbd {
       object_map_copy.set_crc_enabled(false);
 
       bufferlist in;
-      ::encode(object_map_copy, in);
+      encode(object_map_copy, in);
       rados_op->exec("rbd", "object_map_save", in);
     }
 
@@ -1245,7 +1245,7 @@ namespace librbd {
       object_map_copy.set_crc_enabled(false);
 
       bufferlist in;
-      ::encode(object_map_copy, in);
+      encode(object_map_copy, in);
       rados_op->exec("rbd", "object_map_snap_remove", in);
     }
 
index b010970b3213d4fae377a2bb25bb8e778d7b4951..859df6137d452b3a406f4387b72c026dd52c6e0b 100644 (file)
@@ -272,22 +272,23 @@ template <uint8_t _b>
 void BitVector<_b>::encode_header(bufferlist& bl) const {
   bufferlist header_bl;
   ENCODE_START(1, 1, header_bl);
-  ::encode(m_size, header_bl);
+  encode(m_size, header_bl);
   ENCODE_FINISH(header_bl);
   m_header_crc = header_bl.crc32c(0);
 
-  ::encode(header_bl, bl);
+  encode(header_bl, bl);
 }
 
 template <uint8_t _b>
 void BitVector<_b>::decode_header(bufferlist::iterator& it) {
+  using ceph::decode;
   bufferlist header_bl;
-  ::decode(header_bl, it);
+  decode(header_bl, it);
 
   bufferlist::iterator header_it = header_bl.begin();
   uint64_t size;
   DECODE_START(1, header_it);
-  ::decode(size, header_it);
+  decode(size, header_it);
   DECODE_FINISH(header_it);
 
   resize(size);
@@ -385,31 +386,33 @@ void BitVector<_b>::get_data_extents(uint64_t offset, uint64_t length,
 
 template <uint8_t _b>
 void BitVector<_b>::encode_footer(bufferlist& bl) const {
+  using ceph::encode;
   bufferlist footer_bl;
   if (m_crc_enabled) {
-    ::encode(m_header_crc, footer_bl);
-    ::encode(m_data_crcs, footer_bl);
+    encode(m_header_crc, footer_bl);
+    encode(m_data_crcs, footer_bl);
   }
-  ::encode(footer_bl, bl);
+  encode(footer_bl, bl);
 }
 
 template <uint8_t _b>
 void BitVector<_b>::decode_footer(bufferlist::iterator& it) {
+  using ceph::decode;
   bufferlist footer_bl;
-  ::decode(footer_bl, it);
+  decode(footer_bl, it);
 
   m_crc_enabled = (footer_bl.length() > 0);
   if (m_crc_enabled) {
     bufferlist::iterator footer_it = footer_bl.begin();
 
     __u32 header_crc;
-    ::decode(header_crc, footer_it);
+    decode(header_crc, footer_it);
     if (m_header_crc != header_crc) {
       throw buffer::malformed_input("incorrect header CRC");
     }
 
     uint64_t block_count = (m_data.length() + BLOCK_SIZE - 1) / BLOCK_SIZE;
-    ::decode(m_data_crcs, footer_it);
+    decode(m_data_crcs, footer_it);
     if (m_data_crcs.size() != block_count) {
       throw buffer::malformed_input("invalid data block CRCs");
     }
@@ -505,7 +508,6 @@ void BitVector<_b>::generate_test_instances(std::list<BitVector *> &o) {
   o.push_back(b);
 }
 
-}
 
 WRITE_CLASS_ENCODER(ceph::BitVector<2>)
 
@@ -516,5 +518,6 @@ inline std::ostream& operator<<(std::ostream& out, const ceph::BitVector<_b> &b)
       << b.get_data() << ")";
   return out;
 }
+}
 
 #endif // BIT_VECTOR_HPP
index 95516e6fdb8978c5c87089f4b7458f8dcba91d94..d3484610d5c3b5ded05aacda32ea4ff63923ec02 100644 (file)
@@ -8,12 +8,12 @@ MEMPOOL_DEFINE_FACTORY(unsigned char, byte, bloom_filter);
 void bloom_filter::encode(bufferlist& bl) const
 {
   ENCODE_START(2, 2, bl);
-  ::encode((uint64_t)salt_count_, bl);
-  ::encode((uint64_t)insert_count_, bl);
-  ::encode((uint64_t)target_element_count_, bl);
-  ::encode((uint64_t)random_seed_, bl);
+  encode((uint64_t)salt_count_, bl);
+  encode((uint64_t)insert_count_, bl);
+  encode((uint64_t)target_element_count_, bl);
+  encode((uint64_t)random_seed_, bl);
   bufferptr bp((const char*)bit_table_, table_size_);
-  ::encode(bp, bl);
+  encode(bp, bl);
   ENCODE_FINISH(bl);
 }
 
@@ -21,16 +21,16 @@ void bloom_filter::decode(bufferlist::iterator& p)
 {
   DECODE_START(2, p);
   uint64_t v;
-  ::decode(v, p);
+  decode(v, p);
   salt_count_ = v;
-  ::decode(v, p);
+  decode(v, p);
   insert_count_ = v;
-  ::decode(v, p);
+  decode(v, p);
   target_element_count_ = v;
-  ::decode(v, p);
+  decode(v, p);
   random_seed_ = v;
   bufferlist t;
-  ::decode(t, p);
+  decode(t, p);
 
   salt_.clear();
   generate_unique_salt();
@@ -86,10 +86,10 @@ void compressible_bloom_filter::encode(bufferlist& bl) const
   bloom_filter::encode(bl);
 
   uint32_t s = size_list.size();
-  ::encode(s, bl);
+  encode(s, bl);
   for (std::vector<size_t>::const_iterator p = size_list.begin();
        p != size_list.end(); ++p)
-    ::encode((uint64_t)*p, bl);
+    encode((uint64_t)*p, bl);
 
   ENCODE_FINISH(bl);
 }
@@ -100,11 +100,11 @@ void compressible_bloom_filter::decode(bufferlist::iterator& p)
   bloom_filter::decode(p);
 
   uint32_t s;
-  ::decode(s, p);
+  decode(s, p);
   size_list.resize(s);
   for (unsigned i = 0; i < s; i++) {
     uint64_t v;
-    ::decode(v, p);
+    decode(v, p);
     size_list[i] = v;
   }
 
index a486bf46d07b2e98d821cf08e10bef156b2bece3..9c2bee8cbd83aec0b838450824475eaa8fe79fb6 100644 (file)
@@ -137,7 +137,7 @@ TYPED_TEST(BitVectorTest, partial_decode_encode) {
   }
 
   bufferlist bl;
-  ::encode(bit_vector, bl);
+  encode(bit_vector, bl);
   bit_vector.clear();
 
   bufferlist header_bl;
@@ -197,7 +197,7 @@ TYPED_TEST(BitVectorTest, partial_decode_encode) {
     ASSERT_EQ(bl, updated_bl);
 
     bufferlist::iterator updated_it = updated_bl.begin();
-    ::decode(bit_vector, updated_it);
+    decode(bit_vector, updated_it);
   }
 }
 
index c2bea68b266a0ba44af7fbaf68d6b051a524389a..77892ca2f0d26c43a25f68f1e6a545e14bd8908a 100644 (file)
@@ -112,7 +112,9 @@ public:
     bufferlist::iterator p = bl.begin();
     p.seek(seek);
     try {
-      ::decode(*m_object, p);
+      using ::decode;
+      using ceph::decode;
+      decode(*m_object, p);
     }
     catch (buffer::error& e) {
       return e.what();
@@ -158,7 +160,9 @@ public:
     : DencoderBase<T>(stray_ok, nondeterministic) {}
   void encode(bufferlist& out, uint64_t features) override {
     out.clear();
-    ::encode(*this->m_object, out);
+    using ::encode;
+    using ceph::encode;
+    encode(*this->m_object, out);
   }
 };
 
@@ -187,7 +191,9 @@ public:
     : DencoderBase<T>(stray_ok, nondeterministic) {}
   void encode(bufferlist& out, uint64_t features) override {
     out.clear();
-    ::encode(*(this->m_object), out, features);
+    using ::encode;
+    using ceph::encode;
+    encode(*(this->m_object), out, features);
   }
 };
 
index 9f6ed2f65f82351ab4d7a45c2da08561cee049fe..1bae4e72e9fbe7def63f8ac6e097bc8f36003acf 100644 (file)
@@ -96,7 +96,7 @@ public:
       object_map->set_crc_enabled(false);
 
       bufferlist bl;
-      ::encode(*object_map, bl);
+      encode(*object_map, bl);
 
       std::string str(bl.c_str(), bl.length());
       expect.WillOnce(DoAll(WithArg<5>(CopyInBufferlist(str)), Return(0)));