From 5b8b36ab1173c06de40840423f927b512aa5e2e6 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Fri, 8 May 2020 17:41:54 -0700 Subject: [PATCH] [sntp-client] change SendCopy() to return void (#4941) --- src/core/net/sntp_client.cpp | 15 +++++++++------ src/core/net/sntp_client.hpp | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/net/sntp_client.cpp b/src/core/net/sntp_client.cpp index 2ce316670..c6a4cda9b 100644 --- a/src/core/net/sntp_client.cpp +++ b/src/core/net/sntp_client.cpp @@ -229,7 +229,7 @@ otError Client::SendMessage(Message &aMessage, const Ip6::MessageInfo &aMessageI return mSocket.SendTo(aMessage, aMessageInfo); } -otError Client::SendCopy(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo) +void Client::SendCopy(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { otError error; Message *messageCopy = NULL; @@ -243,12 +243,15 @@ otError Client::SendCopy(const Message &aMessage, const Ip6::MessageInfo &aMessa exit: - if (error != OT_ERROR_NONE && messageCopy != NULL) + if (error != OT_ERROR_NONE) { - messageCopy->Free(); - } + otLogWarnIp6("Failed to send SNTP request: %s", otThreadErrorToString(error)); - return error; + if (messageCopy != NULL) + { + messageCopy->Free(); + } + } } Message *Client::FindRelatedQuery(const Header &aResponseHeader, QueryMetadata &aQueryMetadata) @@ -325,7 +328,7 @@ void Client::HandleRetransmissionTimer(void) messageInfo.SetPeerPort(queryMetadata.mDestinationPort); messageInfo.SetSockAddr(queryMetadata.mSourceAddress); - IgnoreError(SendCopy(*message, messageInfo)); + SendCopy(*message, messageInfo); } if (nextTime > queryMetadata.mTransmissionTime) diff --git a/src/core/net/sntp_client.hpp b/src/core/net/sntp_client.hpp index 33a6fff2b..76d4a9ca2 100644 --- a/src/core/net/sntp_client.hpp +++ b/src/core/net/sntp_client.hpp @@ -572,7 +572,7 @@ private: Message *CopyAndEnqueueMessage(const Message &aMessage, const QueryMetadata &aQueryMetadata); void DequeueMessage(Message &aMessage); otError SendMessage(Message &aMessage, const Ip6::MessageInfo &aMessageInfo); - otError SendCopy(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo); + void SendCopy(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo); Message *FindRelatedQuery(const Header &aResponseHeader, QueryMetadata &aQueryMetadata); void FinalizeSntpTransaction(Message &aQuery, const QueryMetadata &aQueryMetadata, uint64_t aTime, otError aResult);