]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/buffer: use bufferptr length directly for memory compare 34189/head
authorChangcheng Liu <changcheng.liu@aliyun.com>
Thu, 11 Jun 2020 15:04:29 +0000 (23:04 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Sun, 14 Jun 2020 04:18:31 +0000 (12:18 +0800)
The input length should be equal to bufferlist length, so the round_length
is always equal to bp.length().

Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
src/common/buffer.cc

index 2e7cb35da46d4440a383ef7a31db5ec128c12004..e407c79fa742ec82ef0bcbdf30af27bd634eec00 100644 (file)
@@ -995,12 +995,12 @@ static ceph::spinlock debug_lock;
 
     const auto* other_buf = reinterpret_cast<const char*>(other);
     for (const auto& bp : buffers()) {
-      const auto round_length = std::min<size_t>(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();
       }
     }