]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer: make 0-length splice() a no-op
authorSage Weil <sage@inktank.com>
Tue, 28 Jan 2014 18:26:12 +0000 (10:26 -0800)
committerSage Weil <sage@inktank.com>
Tue, 28 Jan 2014 18:26:12 +0000 (10:26 -0800)
This was causing a problem in the Striper, but fixing it here will avoid
corner cases all over the tree.  Note that we have to bail out before
the end-of-buffer check to avoid hitting that check when the bufferlist is
also empty.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/common/buffer.cc
src/test/bufferlist.cc

index 5c57763264b72edec9cc4e7f85576e72ad2c17a4..5e57055b3ff15a540b20033da3c956f3c3b1ee94 100644 (file)
@@ -1369,6 +1369,9 @@ void buffer::list::rebuild_page_aligned()
   // funky modifer
   void buffer::list::splice(unsigned off, unsigned len, list *claim_by /*, bufferlist& replace_with */)
   {    // fixme?
+    if (len == 0)
+      return;
+
     if (off >= length())
       throw end_of_buffer();
 
index 506a0c6ab59c0ea5edc47e133cdb44eb0c07b286..5155a218b16bb1a8f35b1da376dbe62cd82cef1d 100644 (file)
@@ -1694,7 +1694,7 @@ TEST(BufferList, splice) {
     bl.push_back(ptr);
   }
   EXPECT_EQ((unsigned)4, bl.buffers().size());
-  EXPECT_THROW(bl.splice(0, 0), FailedAssertion);
+  bl.splice(0, 0);
 
   bufferlist other;
   other.append('X');