From e4852e8ee8cfd984c098293962fbab92e86ff2ee Mon Sep 17 00:00:00 2001 From: Changcheng Liu Date: Thu, 11 Jun 2020 23:04:29 +0800 Subject: [PATCH] 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 --- src/common/buffer.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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(); } } -- 2.47.3