]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer.h: push_back,push_front of an empty buffer pointer should be noop
authorSamuel Just <samuel.just@dreamhost.com>
Mon, 7 Mar 2011 13:34:23 +0000 (05:34 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 7 Mar 2011 13:34:52 +0000 (05:34 -0800)
Also adds an assert to copy to ensure that bufferlist iterator copy
completes.

Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
src/include/buffer.h

index 0905e11883bdfb1a1d1eef52f9b881498003aaf4..825698c928b78c4bcf2bd3d9b1028e960276e5b3 100644 (file)
@@ -635,6 +635,7 @@ public:
        while (len > 0) {
          if (p == ls->end())
            throw end_of_buffer();
+         assert(p->length() > 0); 
 
          unsigned howmuch = p->length() - p_off;
          if (len < howmuch) howmuch = len;
@@ -787,22 +788,22 @@ public:
       last_p = begin();
     }
     void push_front(ptr& bp) {
+      if (bp.length() == 0) return;
       _buffers.push_front(bp);
       _len += bp.length();
     }
     void push_front(raw *r) {
       ptr bp(r);
-      _buffers.push_front(bp);
-      _len += bp.length();
+      push_front(bp);
     }
     void push_back(const ptr& bp) {
+      if (bp.length() == 0) return;
       _buffers.push_back(bp);
       _len += bp.length();
     }
     void push_back(raw *r) {
       ptr bp(r);
-      _buffers.push_back(bp);
-      _len += bp.length();
+      push_back(bp);
     }
     void zero() {
       for (std::list<ptr>::iterator it = _buffers.begin();