From: Sage Weil Date: Tue, 28 Jan 2014 18:26:12 +0000 (-0800) Subject: buffer: make 0-length splice() a no-op X-Git-Tag: v0.67.6~32 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2528186c0dd327607b1e76a51581df72aeea52f2;p=ceph.git buffer: make 0-length splice() a no-op 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 Reviewed-by: Greg Farnum (cherry picked from commit ff5abfbdae07ae8a56fa83ebaa92000896f793c2) --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 0424887139e9..a32990c57d44 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -1039,6 +1039,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(); diff --git a/src/test/bufferlist.cc b/src/test/bufferlist.cc index b23bd33e55a4..04374d91cad1 100644 --- a/src/test/bufferlist.cc +++ b/src/test/bufferlist.cc @@ -1520,7 +1520,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');