]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
src/: s/advance/operator+=/ 33003/head
authorKefu Chai <kchai@redhat.com>
Fri, 31 Jan 2020 05:07:39 +0000 (13:07 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 2 Feb 2020 03:37:28 +0000 (11:37 +0800)
for better readablity

Signed-off-by: Kefu Chai <kchai@redhat.com>
21 files changed:
src/common/buffer.cc
src/compressor/snappy/SnappyCompressor.h
src/include/buffer.h
src/include/denc.h
src/include/encoding.h
src/journal/Entry.cc
src/mds/journal.cc
src/messages/MOSDPing.h
src/msg/async/ProtocolV1.cc
src/os/Transaction.cc
src/os/bluestore/bluestore_types.cc
src/os/filestore/FileJournal.h
src/osd/OSDMap.h
src/osd/PrimaryLogPG.cc
src/osd/osd_types.cc
src/osd/osd_types.h
src/rgw/services/svc_notify.cc
src/test/bufferlist.cc
src/test/compressor/test_compression.cc
src/test/journal/test_Entry.cc
src/test/test_denc.cc

index 0030ef9d613505666c6e867f2553e12239309f92..8b9061268e47b840681bf86ef7d534aab002b7c6 100644 (file)
@@ -675,7 +675,7 @@ static ceph::spinlock debug_lock;
   buffer::list::iterator_impl<is_const>::iterator_impl(bl_t *l, unsigned o)
     : bl(l), ls(&bl->_buffers), p(ls->begin()), off(0), p_off(0)
   {
-    advance(o);
+    *this += o;
   }
 
   template<bool is_const>
@@ -683,7 +683,8 @@ static ceph::spinlock debug_lock;
     : iterator_impl<is_const>(i.bl, i.off, i.p, i.p_off) {}
 
   template<bool is_const>
-  void buffer::list::iterator_impl<is_const>::advance(unsigned o)
+  auto buffer::list::iterator_impl<is_const>::operator +=(unsigned o)
+    -> iterator_impl&
   {
     //cout << this << " advance " << o << " from " << off
     //     << " (p_off " << p_off << " in " << p->length() << ")"
@@ -704,6 +705,7 @@ static ceph::spinlock debug_lock;
       throw end_of_buffer();
     }
     off += o;
+    return *this;
   }
 
   template<bool is_const>
@@ -711,7 +713,7 @@ static ceph::spinlock debug_lock;
   {
     p = ls->begin();
     off = p_off = 0;
-    advance(o);
+    *this += o;
   }
 
   template<bool is_const>
@@ -728,7 +730,7 @@ static ceph::spinlock debug_lock;
   {
     if (p == ls->end())
       throw end_of_buffer();
-    advance(1u);
+    *this += 1;
     return *this;
   }
 
@@ -765,7 +767,7 @@ static ceph::spinlock debug_lock;
       dest += howmuch;
 
       len -= howmuch;
-      advance(howmuch);
+      *this += howmuch;
     }
   }
 
@@ -801,7 +803,7 @@ static ceph::spinlock debug_lock;
       copy(len, dest.c_str());
     } else {
       dest = ptr(*p, p_off, len);
-      advance(len);
+      *this += len;
     }
   }
 
@@ -820,7 +822,7 @@ static ceph::spinlock debug_lock;
       dest.append(*p, p_off, howmuch);
 
       len -= howmuch;
-      advance(howmuch);
+      *this += howmuch;
     }
   }
 
@@ -840,7 +842,7 @@ static ceph::spinlock debug_lock;
       dest.append(c_str + p_off, howmuch);
 
       len -= howmuch;
-      advance(howmuch);
+      *this += howmuch;
     }
   }
 
@@ -857,7 +859,7 @@ static ceph::spinlock debug_lock;
       const char *c_str = p->c_str();
       dest.append(c_str + p_off, howmuch);
 
-      advance(howmuch);
+      *this += howmuch;
     }
   }
 
@@ -927,7 +929,7 @@ static ceph::spinlock debug_lock;
        
       src += howmuch;
       len -= howmuch;
-      advance(howmuch);
+      *this += howmuch;
     }
   }
   
index 0291a9231126b8d8e5ceaefafc018a878aa4a82f..0cfb819cd96f5aa2c074b06977ffecd2d1ae04c0 100644 (file)
@@ -46,7 +46,7 @@ class CEPH_BUFFER_API BufferlistSource : public snappy::Source {
   }
   void Skip(size_t n) override {
     ceph_assert(n <= remaining);
-    pb.advance(n);
+    pb += n;
     remaining -= n;
   }
 
index 6bcbecc3a820a66c6933d33f6edbb89c968df61f..2745675cdb387a953126ed5b043e388435288854 100644 (file)
@@ -214,7 +214,7 @@ inline namespace v14_2_0 {
       using pointer = typename std::conditional<is_const, const char*, char *>::type;
       pointer get_pos_add(size_t n) {
        auto r = pos;
-       advance(n);
+       *this += n;
        return r;
       }
       ptr get_ptr(size_t len) {
@@ -222,18 +222,15 @@ inline namespace v14_2_0 {
          return buffer::copy(get_pos_add(len), len);
        } else {
          size_t off = pos - bp->c_str();
-         advance(len);
+         *this += len;
          return ptr(*bp, off, len);
        }
       }
 
-      void advance(size_t len) {
+      iterator_impl& operator+=(size_t len) {
        pos += len;
        if (pos > end_ptr)
          throw end_of_buffer();
-      }
-      iterator_impl& operator+=(size_t len) {
-        advance(len);
         return *this;
       }
 
@@ -721,13 +718,9 @@ inline namespace v14_2_0 {
        return p == ls->end();
        //return off == bl->length();
       }
-      void advance(unsigned o);
       void seek(unsigned o);
       char operator*() const;
-      iterator_impl& operator+=(unsigned o) {
-        advance(o);
-        return *this;
-      }
+      iterator_impl& operator+=(unsigned o);
       iterator_impl& operator++();
       ptr get_current_ptr() const;
       bool is_pointing_same_raw(const ptr& other) const;
index 2a3a640147627142c5cbf9c1696e19cbab16da0d..adb93ad16a1afbd2b37b4497652c4047b2246178 100644 (file)
@@ -1590,7 +1590,7 @@ inline std::enable_if_t<traits::supported && !traits::need_contiguous> decode(
     t.copy_shallow(remaining, tmp);
     auto cp = std::cbegin(tmp);
     traits::decode(o, cp);
-    p.advance(cp.get_offset());
+    p += cp.get_offset();
   }
 }
 
@@ -1611,7 +1611,7 @@ inline std::enable_if_t<traits::supported && traits::need_contiguous> decode(
   t.copy_shallow(p.get_bl().length() - p.get_off(), tmp);
   auto cp = std::cbegin(tmp);
   traits::decode(o, cp);
-  p.advance(cp.get_offset());
+  p += cp.get_offset();
 }
 
 // nohead variants
@@ -1650,7 +1650,7 @@ inline std::enable_if_t<traits::supported && !traits::featured> decode_nohead(
     }
     auto cp = std::cbegin(tmp);
     traits::decode_nohead(num, o, cp);
-    p.advance(cp.get_offset());
+    p += cp.get_offset();
   } else {
     traits::decode_nohead(num, o, p);
   }
@@ -1715,7 +1715,7 @@ inline std::enable_if_t<traits::supported && !traits::featured> decode_nohead(
     char *end = *start_pos + *struct_len;                              \
     ceph_assert(pos <= end);                                                   \
     if (pos < end) {                                                   \
-      p.advance(end - pos);                                            \
+      p += end - pos;                                                  \
     }                                                                  \
   }
 
index 4bb9233df784cdebf30bd7f0be735e651bfb0dab..2b3e723da22ab2cf170511cfe007b553a389bb60 100644 (file)
@@ -1382,7 +1382,7 @@ decode(std::array<T, N>& v, bufferlist::const_iterator& p)
   } else if (skip_v) {                                                 \
     if (bl.get_remaining() < skip_v)                                   \
       throw ::ceph::buffer::malformed_input(DECODE_ERR_PAST(__PRETTY_FUNCTION__)); \
-    bl.advance(skip_v);                                                        \
+    bl +=  skip_v;                                                     \
   }                                                                    \
   unsigned struct_end = 0;                                             \
   if (struct_v >= lenv) {                                              \
@@ -1467,7 +1467,7 @@ decode(std::array<T, N>& v, bufferlist::const_iterator& p)
     if (bl.get_off() > struct_end)                                     \
       throw ::ceph::buffer::malformed_input(DECODE_ERR_PAST(__PRETTY_FUNCTION__)); \
     if (bl.get_off() < struct_end)                                     \
-      bl.advance(struct_end - bl.get_off());                           \
+      bl += struct_end - bl.get_off();                                 \
   }
 
 namespace ceph {
index 7899bf1cc5a6d4e701aa3ce70a569c0a42b07c21..9879a9aad97b479b80bb563b1c4f8590d418a239 100644 (file)
@@ -102,7 +102,7 @@ bool Entry::is_readable(bufferlist::const_iterator iter, uint32_t *bytes_needed)
     *bytes_needed = 0;
     return false;
   }
-  iter.advance(HEADER_FIXED_SIZE - sizeof(bl_preamble));
+  iter += HEADER_FIXED_SIZE - sizeof(bl_preamble);
 
   if (iter.get_remaining() < sizeof(uint32_t)) {
     *bytes_needed = sizeof(uint32_t) - iter.get_remaining();
@@ -115,7 +115,7 @@ bool Entry::is_readable(bufferlist::const_iterator iter, uint32_t *bytes_needed)
     *bytes_needed = data_size - iter.get_remaining();
     return false;
   }
-  iter.advance(data_size);
+  iter += data_size;
   uint32_t end_off = iter.get_off();
 
   if (iter.get_remaining() < sizeof(uint32_t)) {
index 17c7c3a0a3a2a876fca06ecb60ab5c42091e449e..14966f14ce153847b78a94da0e2216ea2b18e37b 100644 (file)
@@ -3153,7 +3153,7 @@ void ENoOp::decode(bufferlist::const_iterator &bl)
     // journal debug tools catch it and recognise a malformed entry.
     throw buffer::end_of_buffer();
   } else {
-    bl.advance(pad_size);
+    bl += pad_size;
   }
   DECODE_FINISH(bl);
 }
index f95fe0a613e7190b1c50ede86c2301a6235adced..530c803ce48f7b2740b3bff383a6db6551ac9ffc 100644 (file)
@@ -110,7 +110,7 @@ public:
       decode(delta_ub, p);
     }
 
-    p.advance(size);
+    p += size;
     min_message_size = size + payload_mid_length;
   }
   void encode_payload(uint64_t features) override {
index c5d5e021fbdb86829537cd168b7ff54179c79ffe..06f77efa7a38d2b45ed53383e2796a5dee5ff3f0 100644 (file)
@@ -862,7 +862,7 @@ CtPtr ProtocolV1::handle_message_data(char *buffer, int r) {
   unsigned read_len = std::min(bp.length(), msg_left);
   ceph_assert(read_len <
              static_cast<unsigned>(std::numeric_limits<int>::max()));
-  data_blp.advance(read_len);
+  data_blp += read_len;
   data.append(bp, 0, read_len);
   msg_left -= read_len;
 
index 0701e14daa5311dd642df57c431b0391da9b0a4f..325f887d94d0b9658697b5bccdf85fbc5c827f68 100644 (file)
@@ -14,10 +14,10 @@ void decode_str_str_map_to_bl(bufferlist::const_iterator& p,
   while (n--) {
     __u32 l;
     decode(l, p);
-    p.advance(l);
+    p += l;
     len += 4 + l;
     decode(l, p);
-    p.advance(l);
+    p += l;
     len += 4 + l;
   }
   start.copy(len, *out);
@@ -33,7 +33,7 @@ void decode_str_set_to_bl(bufferlist::const_iterator& p,
   while (n--) {
     __u32 l;
     decode(l, p);
-    p.advance(l);
+    p += l;
     len += 4 + l;
   }
   start.copy(len, *out);
index f7ff63e936dc14a920e202c646af556fac58b86e..a0b799422f75a5aeb1efe995fe368743e85c1fc3 100644 (file)
@@ -36,7 +36,7 @@ void bluestore_bdev_label_t::encode(bufferlist& bl) const
 
 void bluestore_bdev_label_t::decode(bufferlist::const_iterator& p)
 {
-  p.advance(60u); // see above
+  p += 60u; // see above
   DECODE_START(2, p);
   decode(osd_uuid, p);
   decode(size, p);
index e9d41331bcc08ab40f4f966e0939491bf6290f59..c4357b473cf3005e8c6134982af061c0247b3cbb 100644 (file)
@@ -184,7 +184,7 @@ public:
       decode(v, bl);
       if (v < 2) {  // normally 0, but conceivably 1
        // decode old header_t struct (pre v0.40).
-       bl.advance(4u); // skip __u32 flags (it was unused by any old code)
+       bl += 4u; // skip __u32 flags (it was unused by any old code)
        flags = 0;
        uint64_t tfsid;
        decode(tfsid, bl);
index db45f811ae82ab67c6a4230f075bb96b28145e4f..15ce0ef7216c165c9567a546b65532ab8ddd47e4 100644 (file)
@@ -142,7 +142,7 @@ struct PGTempMap {
       offsets[i].second = p.get_off() - start_off;
       uint32_t vn;
       decode(vn, p);
-      p.advance(vn * sizeof(int32_t));
+      p += vn * sizeof(int32_t);
     }
     size_t len = p.get_off() - start_off;
     pstart.copy(len, data);
index f7a465b9c187dfb7a8900f9697b9308ec30a6837..731866aac1e8ae1753f48de4e19e90da4c8fd09f 100644 (file)
@@ -5226,7 +5226,7 @@ int PrimaryLogPG::do_checksum(OpContext *ctx, OSDOp& osd_op,
   bufferlist init_value_bl;
   init_value_bl.substr_of(bl_it->get_bl(), bl_it->get_off(),
                          csum_init_value_size);
-  bl_it->advance(csum_init_value_size);
+  *bl_it += csum_init_value_size;
 
   if (pool.info.is_erasure() && op.checksum.length > 0) {
     // If there is a data digest and it is possible we are reading
index 901480b849f3c0fb188dc58281870803c0cec777..0e0b47cfbbfdf0c34c510e079f98a024987ec9b9 100644 (file)
@@ -314,7 +314,7 @@ void request_redirect_t::decode(ceph::buffer::list::const_iterator& bl)
   decode(redirect_object, bl);
   decode(legacy_osd_instructions_len, bl);
   if (legacy_osd_instructions_len) {
-    bl.advance(legacy_osd_instructions_len);
+    bl += legacy_osd_instructions_len;
   }
   DECODE_FINISH(bl);
 }
@@ -5578,7 +5578,7 @@ void SnapSet::decode(ceph::buffer::list::const_iterator& bl)
 {
   DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl);
   decode(seq, bl);
-  bl.advance(1u);  // skip legacy head_exists (always true)
+  bl += 1u;  // skip legacy head_exists (always true)
   decode(snaps, bl);
   decode(clones, bl);
   decode(clone_overlap, bl);
index a405c69d36aa6307956d3479b67116651c93fb89..3102bcb8903c34dfcb775e057fd749851f9be831 100644 (file)
@@ -491,7 +491,7 @@ struct pg_t {
     decode(v, bl);
     decode(m_pool, bl);
     decode(m_seed, bl);
-    bl.advance(sizeof(int32_t)); // was preferred
+    bl += sizeof(int32_t); // was preferred
   }
   void decode_old(ceph::buffer::list::const_iterator& bl) {
     using ceph::decode;
index a7148adadb09208ef06dc94ee4f202e6f79e7502..e6c0b58fbd2a3855ec68d3fca68a6e85af9da525 100644 (file)
@@ -396,7 +396,7 @@ int RGWSI_Notify::robust_notify(RGWSI_RADOS::Obj& notify_obj, bufferlist& bl,
        ldout(cct, 20) << "robust_notify: acked by " << id << dendl;
        uint32_t blen;
        decode(blen, p);
-       p.advance(blen);
+       p += blen;
       }
     } catch (const buffer::error& e) {
       ldout(cct, 0) << "robust_notify: notify response parse failed: "
@@ -435,7 +435,7 @@ int RGWSI_Notify::robust_notify(RGWSI_RADOS::Obj& notify_obj, bufferlist& bl,
            }
            uint32_t blen;
            decode(blen, p);
-           p.advance(blen);
+           p += blen;
          }
 
          uint32_t num_timeouts;
index 9f9c206d4f016a02ac9268cb560a4ed994d89ed8..6ec640fdb154f4782ca32648398c252a17fbeb36 100644 (file)
@@ -804,7 +804,7 @@ static void bench_bufferlistiter_deref(const size_t step,
   utime_t start = ceph_clock_now();
   bufferlist::iterator iter = bl.begin();
   while (iter != bl.end()) {
-    iter.advance(step);
+    iter += step;
   }
   utime_t end = ceph_clock_now();
   cout << bufsize * bufnum << " derefs over bl with " << bufnum
@@ -833,14 +833,14 @@ TEST(BufferListIterator, advance) {
 
   {
     bufferlist::iterator i(&bl);
-    EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+    EXPECT_THROW(i += 200u, buffer::end_of_buffer);
   }
   {
     bufferlist::iterator i(&bl);
     EXPECT_EQ('A', *i);
-    i.advance(1u);
+    i += 1u;
     EXPECT_EQ('B', *i);
-    i.advance(3u);
+    i += 3u;
     EXPECT_EQ('E', *i);
   }
 }
@@ -939,14 +939,14 @@ TEST(BufferListIterator, iterator_crc32c) {
 
   bl3.append(s.substr(98, 55));
   it = bl1.begin();
-  it.advance(98u);
+  it += 98u;
   ASSERT_EQ(bl3.crc32c(0), it.crc32c(55, 0));
   ASSERT_EQ(4u, it.get_remaining());
 
   bl3.clear();
   bl3.append(s.substr(98 + 55));
   it = bl1.begin();
-  it.advance(98u + 55u);
+  it += 98u + 55u;
   ASSERT_EQ(bl3.crc32c(0), it.crc32c(10, 0));
   ASSERT_EQ(0u, it.get_remaining());
 }
@@ -970,7 +970,7 @@ TEST(BufferListIterator, operator_star) {
   {
     bufferlist::iterator i(&bl);
     EXPECT_EQ('A', *i);
-    EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+    EXPECT_THROW(i += 200u, buffer::end_of_buffer);
     EXPECT_THROW(*i, buffer::end_of_buffer);
   }
 }
@@ -1062,7 +1062,7 @@ TEST(BufferListIterator, copy) {
     //
     // demonstrates that it seeks back to offset if p == ls->end()
     //
-    EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+    EXPECT_THROW(i += 200u, buffer::end_of_buffer);
     i.copy(2, copy);
     EXPECT_EQ(0, ::memcmp(copy, expected, 2));
     EXPECT_EQ('X', copy[2]);
@@ -1102,7 +1102,7 @@ TEST(BufferListIterator, copy) {
     //
     // demonstrates that it seeks back to offset if p == ls->end()
     //
-    EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+    EXPECT_THROW(i += 200u, buffer::end_of_buffer);
     i.copy(2, copy);
     EXPECT_EQ(0, ::memcmp(copy.c_str(), expected, 2));
     i.seek(0);
@@ -1123,7 +1123,7 @@ TEST(BufferListIterator, copy) {
     //
     // demonstrates that it seeks back to offset if p == ls->end()
     //
-    EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+    EXPECT_THROW(i += 200u, buffer::end_of_buffer);
     i.copy_all(copy);
     EXPECT_EQ('A', copy[0]);
     EXPECT_EQ('B', copy[1]);
@@ -1139,7 +1139,7 @@ TEST(BufferListIterator, copy) {
     //
     // demonstrates that it seeks back to offset if p == ls->end()
     //
-    EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+    EXPECT_THROW(i += 200u, buffer::end_of_buffer);
     i.copy(2, copy);
     EXPECT_EQ(0, ::memcmp(copy.c_str(), expected, 2));
     i.seek(0);
@@ -1165,7 +1165,7 @@ TEST(BufferListIterator, copy_in) {
     //
     // demonstrates that it seeks back to offset if p == ls->end()
     //
-    EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+    EXPECT_THROW(i += 200u, buffer::end_of_buffer);
     const char *expected = "ABC";
     i.copy_in(3, expected);
     EXPECT_EQ(0, ::memcmp(bl.c_str(), expected, 3));
@@ -1182,7 +1182,7 @@ TEST(BufferListIterator, copy_in) {
     //
     // demonstrates that it seeks back to offset if p == ls->end()
     //
-    EXPECT_THROW(i.advance(200u), buffer::end_of_buffer);
+    EXPECT_THROW(i += 200u, buffer::end_of_buffer);
     bufferlist expected;
     expected.append("ABC", 3);
     i.copy_in(3, expected);
index 52857cd541593838eaf5733c0e8ce8b5567cc395..34049305460d6adad738a7b26f98c790879e72a2 100644 (file)
@@ -201,7 +201,7 @@ TEST_P(CompressorTest, compress_decompress)
   prefix.claim_append(out);
   out.swap(prefix);
   it = out.cbegin();
-  it.advance(prefix_len);
+  it += prefix_len;
   res = compressor->decompress(it, compressed_len, after);
   EXPECT_EQ(res, 0);
   EXPECT_TRUE(exp.contents_equal(after));
index ff0e82c01f0cff7cb211c6ae3e13075a6048c63c..1fa3136f795198b21083c6f7ac5a99050c6f107e 100644 (file)
@@ -70,7 +70,7 @@ TEST_F(TestEntry, IsReadableBadPreamble) {
   ASSERT_FALSE(journal::Entry::is_readable(it, &bytes_needed));
   ASSERT_EQ(0U, bytes_needed);
 
-  it.advance(sizeof(stray_bytes));
+  it += sizeof(stray_bytes);
   ASSERT_TRUE(journal::Entry::is_readable(it, &bytes_needed));
   ASSERT_EQ(0U, bytes_needed);
 }
index 4e7838a9391e4288dbe441d686ada4019da5a666..0924ee4eda2c8fa65462bc25fc2405db2299166d 100644 (file)
@@ -124,7 +124,7 @@ struct denc_counter_t {
     ++counts.num_encode;
   }
   void decode(buffer::ptr::const_iterator &p) {
-    p.advance(1);
+    p += 1;
     ++counts.num_decode;
   }
 };
@@ -140,7 +140,7 @@ struct denc_counter_bounded_t {
     ++counts.num_encode;
   }
   void decode(buffer::ptr::const_iterator &p) {
-    p.advance(1);
+    p += 1;
     ++counts.num_decode;
   }
 };
@@ -712,7 +712,7 @@ TEST(denc, no_copy_if_segmented_and_lengthy)
     ASSERT_GT(segmented.get_num_buffers(), 1u);
     ASSERT_GT(segmented.length(), CEPH_PAGE_SIZE);
     auto p = segmented.cbegin();
-    p.advance(large_bl.length());
+    p += large_bl.length();
     ASSERT_LT(segmented.length() - p.get_off(), CEPH_PAGE_SIZE);
     vector<Legacy> v;
     Legacy::reset();
@@ -730,7 +730,7 @@ TEST(denc, no_copy_if_segmented_and_lengthy)
     ASSERT_GT(segmented.get_num_buffers(), 1u);
     ASSERT_GT(segmented.length(), CEPH_PAGE_SIZE);
     auto p = segmented.cbegin();
-    p.advance(small_bl.length());
+    p += small_bl.length();
     ASSERT_GT(segmented.length() - p.get_off(), CEPH_PAGE_SIZE);
     vector<Legacy> v;
     Legacy::reset();