From: Changcheng Liu Date: Thu, 11 Jun 2020 15:04:29 +0000 (+0800) Subject: common/buffer: use bufferptr length directly for memory compare X-Git-Tag: v16.1.0~1999^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e4852e8ee8cfd984c098293962fbab92e86ff2ee;p=ceph.git common/buffer: use bufferptr length directly for memory compare The input length should be equal to bufferlist length, so the round_length is always equal to bp.length(). Signed-off-by: Changcheng Liu --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 2e7cb35da46d..e407c79fa742 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -995,12 +995,12 @@ static ceph::spinlock debug_lock; const auto* other_buf = reinterpret_cast(other); for (const auto& bp : buffers()) { - const auto round_length = std::min(length, bp.length()); - if (std::memcmp(bp.c_str(), other_buf, round_length) != 0) { + assert(bp.length() <= length); + if (std::memcmp(bp.c_str(), other_buf, bp.length()) != 0) { return false; } else { - length -= round_length; - other_buf += round_length; + length -= bp.length(); + other_buf += bp.length(); } }