From: Kefu Chai Date: Mon, 8 Dec 2025 08:29:00 +0000 (+0800) Subject: include/cpp-btree: fix array bounds warning in child() accessors X-Git-Tag: testing/wip-pdonnell-testing-20260108.183402~5^2~7^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=78d29e2a06d135ad8756d0f8e49e88a267b5fa79;p=ceph-ci.git include/cpp-btree: fix array bounds warning in child() accessors Replace array indexing with pointer arithmetic in child() and mutable_child() methods to avoid compiler warning when accessing child nodes beyond the static array bounds. The original code was functionally correct but triggered -Warray-bounds when accessing mutable_child(32) during btree operations. Using pointer arithmetic achieves the same result without the bounds check warning. This is a follow-up to commit 8458a19ab which fixed similar warnings in other btree_node methods. No functional changes. Fixes: https://tracker.ceph.com/issues/72477 Signed-off-by: Kefu Chai --- diff --git a/src/include/cpp-btree/btree.h b/src/include/cpp-btree/btree.h index e8077db7b71..a689b2d43a2 100644 --- a/src/include/cpp-btree/btree.h +++ b/src/include/cpp-btree/btree.h @@ -511,8 +511,8 @@ public: const_reference value(int i) const { return params_type::element(slot(i)); } // Getters/setter for the child at position i in the node. - btree_node* child(int i) const { return GetField<&internal_fields::children>()[i]; } - btree_node*& mutable_child(int i) { return GetField<&internal_fields::children>()[i]; } + btree_node* child(int i) const { return *(GetField<&internal_fields::children>() + i); } + btree_node*& mutable_child(int i) { return *(GetField<&internal_fields::children>() + i); } void clear_child(int i) { #ifndef NDEBUG memset(&mutable_child(i), 0, sizeof(btree_node*));