]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: bufferlist can contain 0-length bptrs.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 18 Sep 2018 20:03:06 +0000 (22:03 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 1 Feb 2019 21:54:50 +0000 (22:54 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/common/buffer.cc

index 078d41321688ce3d1fb4b42bde89e912295c8060..c3bce4c0ee072198d42ba7cc63eea7c09f77be97 100644 (file)
@@ -734,14 +734,8 @@ static ceph::spinlock debug_lock;
     //     << " (p_off " << p_off << " in " << p->length() << ")"
     //     << std::endl;
 
-    p_off += o;
-
-    if (!o) {
-      return;
-    }
-    while (p_off > 0) {
-      if (p == ls->end())
-        throw end_of_buffer();
+    p_off +=o;
+    while (p != ls->end()) {
       if (p_off >= p->length()) {
         // skip this buffer
         p_off -= p->length();
@@ -751,6 +745,9 @@ static ceph::spinlock debug_lock;
         break;
       }
     }
+    if (p == ls->end() && p_off) {
+      throw end_of_buffer();
+    }
     off += o;
   }
 
@@ -806,7 +803,6 @@ static ceph::spinlock debug_lock;
     while (len > 0) {
       if (p == ls->end())
        throw end_of_buffer();
-      ceph_assert(p->length() > 0);
 
       unsigned howmuch = p->length() - p_off;
       if (len < howmuch) howmuch = len;
@@ -832,7 +828,6 @@ static ceph::spinlock debug_lock;
     }
     if (p == ls->end())
       throw end_of_buffer();
-    ceph_assert(p->length() > 0);
     dest = create(len);
     copy(len, dest.c_str());
   }
@@ -845,7 +840,6 @@ static ceph::spinlock debug_lock;
     }
     if (p == ls->end())
       throw end_of_buffer();
-    ceph_assert(p->length() > 0);
     unsigned howmuch = p->length() - p_off;
     if (howmuch < len) {
       dest = create(len);
@@ -903,7 +897,6 @@ static ceph::spinlock debug_lock;
     while (1) {
       if (p == ls->end())
        return;
-      ceph_assert(p->length() > 0);
 
       unsigned howmuch = p->length() - p_off;
       const char *c_str = p->c_str();
@@ -1048,7 +1041,6 @@ static ceph::spinlock debug_lock;
          ++b;
        }
       }
-      ceph_assert(b == std::cend(other._buffers));
       return true;
     }