From 5f623944b215c7ee7907ac96a32d20820ae59b56 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 15 Jul 2025 12:18:53 -0700 Subject: [PATCH] [mle] fix int conversion when setting TLV length (#11727) This commit resolves a potential unsafe integer conversion warning by explicitly casting the size of the status sub-TLV to `uint8_t` before setting the length of the main TLV in `SendLinkMetricsManagementResponse`. Additionally, this change enables MLE_LINK_METRICS_SUBJECT_ENABLE` feature in the `toranj` test configuration, allowing this feature to be covered under its builds. --- src/core/thread/mle.cpp | 2 +- tests/toranj/openthread-core-toranj-config.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 95abaf6c1..ec6163a89 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -2159,7 +2159,7 @@ Error Mle::SendLinkMetricsManagementResponse(const Ip6::Address &aDestination, L tlv.SetType(Tlv::kLinkMetricsManagement); statusSubTlv.SetType(LinkMetrics::SubTlv::kStatus); statusSubTlv.SetLength(sizeof(aStatus)); - tlv.SetLength(statusSubTlv.GetSize()); + tlv.SetLength(static_cast(statusSubTlv.GetSize())); SuccessOrExit(error = message->Append(tlv)); SuccessOrExit(error = message->Append(statusSubTlv)); diff --git a/tests/toranj/openthread-core-toranj-config.h b/tests/toranj/openthread-core-toranj-config.h index 53bae9f8f..4db884191 100644 --- a/tests/toranj/openthread-core-toranj-config.h +++ b/tests/toranj/openthread-core-toranj-config.h @@ -80,6 +80,8 @@ #define OPENTHREAD_CONFIG_DIAG_ENABLE 1 +#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1 + #define OPENTHREAD_CONFIG_JOINER_ENABLE 1 #define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 1