From d2aba43057ef85adc5c59cfb3bf15792eb260abf Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 7 Apr 2026 12:21:32 -0700 Subject: [PATCH] [nexus] remove `mSrpHostAddresses` from `Node` class (#12850) This commit removes the `mSrpHostAddresses` array from the `Node` class in the Nexus platform. The array was specific to SRP client testing and was occupying unnecessary memory for every simulated node instance. Instead of keeping this state inside the `Node` abstraction, a local `hostAddrs` array is now declared within the `Test_1_3_SRP_TC_1()` test function. This local array safely persists for the duration of the test, allowing `Srp::Client::SetHostAddresses()` to use the provided pointer without relying on a global or node-level member. --- tests/nexus/platform/nexus_node.hpp | 2 -- tests/nexus/test_1_3_SRP_TC_1.cpp | 17 ++++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/nexus/platform/nexus_node.hpp b/tests/nexus/platform/nexus_node.hpp index 4b8b25ad3..da39e2183 100644 --- a/tests/nexus/platform/nexus_node.hpp +++ b/tests/nexus/platform/nexus_node.hpp @@ -161,8 +161,6 @@ public: Node *mNext; - Ip6::Address mSrpHostAddresses[OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_HOST_ADDRESSES]; - private: Node(void) : Platform(static_cast(*this)) diff --git a/tests/nexus/test_1_3_SRP_TC_1.cpp b/tests/nexus/test_1_3_SRP_TC_1.cpp index ee42be6dc..07945d031 100644 --- a/tests/nexus/test_1_3_SRP_TC_1.cpp +++ b/tests/nexus/test_1_3_SRP_TC_1.cpp @@ -83,8 +83,6 @@ static constexpr uint16_t kSrpUpdatedPort = 55556; void Test_1_3_SRP_TC_1(const char *aJsonFileName) { - Srp::Client::Service service; - /** * 2.1. [1.3] [CERT] Register Single Service * @@ -110,6 +108,9 @@ void Test_1_3_SRP_TC_1(const char *aJsonFileName) Node &ed1 = nexus.CreateNode(); Node ð1 = nexus.CreateNode(); + Srp::Client::Service service; + Ip6::Address hostAddrs[2]; + br1.SetName("BR_1"); ed1.SetName("ED_1"); eth1.SetName("Eth_1"); @@ -188,17 +189,15 @@ void Test_1_3_SRP_TC_1(const char *aJsonFileName) SuccessOrQuit(ed1.Get().SetHostName(kSrpHostName)); - uint8_t addrsCount = 0; - - ed1.mSrpHostAddresses[addrsCount++] = ed1.Get().GetMeshLocalEid(); + hostAddrs[0] = ed1.Get().GetMeshLocalEid(); { Ip6::Prefix omrPrefix; SuccessOrQuit(br1.Get().GetOmrPrefix(omrPrefix)); - ed1.mSrpHostAddresses[addrsCount++] = ed1.FindMatchingAddress(omrPrefix.ToString().AsCString()); + hostAddrs[1] = ed1.FindMatchingAddress(omrPrefix.ToString().AsCString()); } - SuccessOrQuit(ed1.Get().SetHostAddresses(ed1.mSrpHostAddresses, addrsCount)); + SuccessOrQuit(ed1.Get().SetHostAddresses(hostAddrs, 2)); ClearAllBytes(service); service.mName = kSrpServiceType; @@ -374,8 +373,8 @@ void Test_1_3_SRP_TC_1(const char *aJsonFileName) ed1.Get().ClearHostAndServices(); SuccessOrQuit(ed1.Get().SetHostName(kSrpHostName)); - ed1.mSrpHostAddresses[0] = ed1.Get().GetMeshLocalEid(); - SuccessOrQuit(ed1.Get().SetHostAddresses(ed1.mSrpHostAddresses, 1)); + hostAddrs[0] = ed1.Get().GetMeshLocalEid(); + SuccessOrQuit(ed1.Get().SetHostAddresses(hostAddrs, 1)); // Update existing service ClearAllBytes(service);