From beb58588acb35668377d516f0e9ae16292382a9a Mon Sep 17 00:00:00 2001 From: enigma-hh Date: Tue, 10 Jun 2025 22:27:47 +0800 Subject: [PATCH 1/3] commit-message: update the code scanning alert - Multiplication result converted to larger type #{564} --- src/observer/storage/index/bplus_tree.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/observer/storage/index/bplus_tree.cpp b/src/observer/storage/index/bplus_tree.cpp index aa63c63c7..93d75b4bc 100644 --- a/src/observer/storage/index/bplus_tree.cpp +++ b/src/observer/storage/index/bplus_tree.cpp @@ -312,7 +312,9 @@ RC LeafIndexNodeHandler::move_to(LeafIndexNodeHandler &other) other.append(__item_at(0), this->size()); other.set_next_page(this->next_page()); - RC rc = mtr_.logger().node_remove_items(*this, 0, span(__item_at(0), this->size() * item_size()), this->size()); + size_t converted_size = static_cast(this->size()); + size_t converted_item_size = static_cast(item_size()); + RC rc = mtr_->logger().node_remove_items(*this, 0, span(__item_at(0), converted_size * converted_item_size), this->size()); if (OB_FAIL(rc)) { LOG_WARN("failed to log shrink leaf node. rc=%s", strrc(rc)); } @@ -324,7 +326,9 @@ RC LeafIndexNodeHandler::move_to(LeafIndexNodeHandler &other) // 复制一些数据到当前节点的最右边 RC LeafIndexNodeHandler::append(const char *items, int num) { - RC rc = mtr_.logger().node_insert_items(*this, size(), span(items, num * item_size()), num); + size_t converted_num = static_cast(num); + size_t converted_item_size = static_cast(item_size()); + RC rc = mtr_.logger().node_insert_items(*this, size(), span(items, converted_num * converted_item_size), num); if (OB_FAIL(rc)) { LOG_WARN("failed to log append items. rc=%d:%s", rc, strrc(rc)); return rc; From 804461fd46b19d9b720e9d422bef02ee60faca67 Mon Sep 17 00:00:00 2001 From: enigma-hh Date: Wed, 11 Jun 2025 14:48:32 +0800 Subject: [PATCH 2/3] Update src/observer/storage/index/bplus_tree.cpp Co-authored-by: nauta --- src/observer/storage/index/bplus_tree.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/observer/storage/index/bplus_tree.cpp b/src/observer/storage/index/bplus_tree.cpp index 93d75b4bc..0922bb163 100644 --- a/src/observer/storage/index/bplus_tree.cpp +++ b/src/observer/storage/index/bplus_tree.cpp @@ -314,7 +314,8 @@ RC LeafIndexNodeHandler::move_to(LeafIndexNodeHandler &other) size_t converted_size = static_cast(this->size()); size_t converted_item_size = static_cast(item_size()); - RC rc = mtr_->logger().node_remove_items(*this, 0, span(__item_at(0), converted_size * converted_item_size), this->size()); + RC rc = mtr_->logger().node_remove_items(*this, 0, span(__item_at(0), static_cast(this->size()) * static_cast(item_size())), this->size()); + if (OB_FAIL(rc)) { LOG_WARN("failed to log shrink leaf node. rc=%s", strrc(rc)); } From 872076850a92159369277eb140b3bb024fe140e5 Mon Sep 17 00:00:00 2001 From: enigma-hh Date: Wed, 11 Jun 2025 15:16:27 +0800 Subject: [PATCH 3/3] Update bplus_tree.cpp --- src/observer/storage/index/bplus_tree.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/observer/storage/index/bplus_tree.cpp b/src/observer/storage/index/bplus_tree.cpp index 0922bb163..aca159f54 100644 --- a/src/observer/storage/index/bplus_tree.cpp +++ b/src/observer/storage/index/bplus_tree.cpp @@ -312,9 +312,7 @@ RC LeafIndexNodeHandler::move_to(LeafIndexNodeHandler &other) other.append(__item_at(0), this->size()); other.set_next_page(this->next_page()); - size_t converted_size = static_cast(this->size()); - size_t converted_item_size = static_cast(item_size()); - RC rc = mtr_->logger().node_remove_items(*this, 0, span(__item_at(0), static_cast(this->size()) * static_cast(item_size())), this->size()); + RC rc = mtr_.logger().node_remove_items(*this, 0, span(__item_at(0), static_cast(this->size()) * static_cast(item_size())), this->size()); if (OB_FAIL(rc)) { LOG_WARN("failed to log shrink leaf node. rc=%s", strrc(rc)); @@ -327,9 +325,7 @@ RC LeafIndexNodeHandler::move_to(LeafIndexNodeHandler &other) // 复制一些数据到当前节点的最右边 RC LeafIndexNodeHandler::append(const char *items, int num) { - size_t converted_num = static_cast(num); - size_t converted_item_size = static_cast(item_size()); - RC rc = mtr_.logger().node_insert_items(*this, size(), span(items, converted_num * converted_item_size), num); + RC rc = mtr_.logger().node_insert_items(*this, size(), span(items, static_cast(num) * static_cast(item_size())), num); if (OB_FAIL(rc)) { LOG_WARN("failed to log append items. rc=%d:%s", rc, strrc(rc)); return rc;