From 26743fae04183582c13b708ea91feedf708fa7f4 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 23 Sep 2019 15:53:15 -0700 Subject: [PATCH] [dns-client] remove memset(zero) from constructor (#4195) --- src/core/net/dns_client.cpp | 24 ++++++++++++++++++++++++ src/core/net/dns_client.hpp | 9 ++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/core/net/dns_client.cpp b/src/core/net/dns_client.cpp index e55c075db..a9f43ea3a 100644 --- a/src/core/net/dns_client.cpp +++ b/src/core/net/dns_client.cpp @@ -49,6 +49,30 @@ using ot::Encoding::BigEndian::HostSwap16; namespace ot { namespace Dns { +QueryMetadata::QueryMetadata(void) + : mHostname(NULL) + , mResponseHandler(NULL) + , mResponseContext(NULL) + , mTransmissionTime() + , mDestinationPort(0) + , mRetransmissionCount(0) +{ + mSourceAddress.Clear(); + mDestinationAddress.Clear(); +} + +QueryMetadata::QueryMetadata(otDnsResponseHandler aHandler, void *aContext) + : mHostname(NULL) + , mResponseHandler(aHandler) + , mResponseContext(aContext) + , mTransmissionTime() + , mDestinationPort(0) + , mRetransmissionCount(0) +{ + mSourceAddress.Clear(); + mDestinationAddress.Clear(); +} + Client::Client(Ip6::Netif &aNetif) : mSocket(aNetif.Get()) , mMessageId(0) diff --git a/src/core/net/dns_client.hpp b/src/core/net/dns_client.hpp index 51fc8c852..5e74c0e36 100644 --- a/src/core/net/dns_client.hpp +++ b/src/core/net/dns_client.hpp @@ -60,7 +60,7 @@ public: * Default constructor for the object. * */ - QueryMetadata(void) { memset(this, 0, sizeof(*this)); } + QueryMetadata(void); /** * This constructor initializes the object with specific values. @@ -69,12 +69,7 @@ public: * @param[in] aContext Context for the handler function. * */ - QueryMetadata(otDnsResponseHandler aHandler, void *aContext) - { - memset(this, 0, sizeof(*this)); - mResponseHandler = aHandler; - mResponseContext = aContext; - } + QueryMetadata(otDnsResponseHandler aHandler, void *aContext); /** * This method appends request data to the message.