Skip to content

Commit b35892c

Browse files
Apply suggestions from code review
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 0b28c78 commit b35892c

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/platform/Darwin/DnssdContexts.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ ResolveContext::ResolveContext(CommissioningResolveDelegate * delegate, chip::In
491491

492492
ResolveContext::~ResolveContext()
493493
{
494-
if (this->isSRPTimerRunning)
494+
if (isSRPTimerRunning)
495495
{
496496
CancelSRPTimer(this);
497497
}
@@ -568,7 +568,7 @@ void ResolveContext::DispatchSuccess()
568568
}
569569
}
570570

571-
bool ResolveContext::TryReportingResultsForInterfaceIndex(uint32_t interfaceIndex, std::string hostname, bool isSRPType)
571+
bool ResolveContext::TryReportingResultsForInterfaceIndex(uint32_t interfaceIndex, const std::string & hostname, bool isSRPType)
572572
{
573573
if (interfaceIndex == 0)
574574
{
@@ -687,7 +687,7 @@ bool ResolveContext::HasAddress()
687687
}
688688

689689
void ResolveContext::OnNewInterface(uint32_t interfaceId, const char * fullname, const char * hostnameWithDomain, uint16_t port,
690-
uint16_t txtLen, const unsigned char * txtRecord, bool isSRPType)
690+
uint16_t txtLen, const unsigned char * txtRecord, bool isFromSRPResolve)
691691
{
692692
#if CHIP_PROGRESS_LOGGING
693693
std::string txtString;

src/platform/Darwin/DnssdImpl.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ std::shared_ptr<uint32_t> GetCounterHolder(const char * name)
131131
return std::make_shared<uint32_t>(0);
132132
}
133133

134-
bool IsSRPType(const char * domain)
134+
bool IsSRPDomain(const char * domain)
135135
{
136136
return strcmp(kSRPDot, domain) == 0;
137137
}
@@ -164,7 +164,7 @@ CHIP_ERROR StartSRPTimer(uint16_t timeoutInMSecs, ResolveContext * ctx)
164164
{
165165
VerifyOrReturnValue(ctx != nullptr, CHIP_ERROR_INCORRECT_STATE);
166166
return DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds16(timeoutInMSecs), SRPTimerExpiredCallback,
167-
reinterpret_cast<void *>(ctx));
167+
static_cast<void *>(ctx));
168168
}
169169

170170
/**
@@ -174,7 +174,7 @@ CHIP_ERROR StartSRPTimer(uint16_t timeoutInMSecs, ResolveContext * ctx)
174174
*/
175175
void CancelSRPTimer(ResolveContext * ctx)
176176
{
177-
DeviceLayer::SystemLayer().CancelTimer(SRPTimerExpiredCallback, reinterpret_cast<void *>(ctx));
177+
DeviceLayer::SystemLayer().CancelTimer(SRPTimerExpiredCallback, static_cast<void *>(ctx));
178178
}
179179

180180
Global<MdnsContexts> MdnsContexts::sInstance;
@@ -285,7 +285,7 @@ static void OnGetAddrInfo(DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t i
285285

286286
if (kDNSServiceErr_NoError == err)
287287
{
288-
InterfaceKey interfaceKey = { interfaceId, hostname, contextWithType->isSRPType };
288+
InterfaceKey interfaceKey = { interfaceId, hostname, contextWithType->isSRP };
289289
sdCtx->OnNewAddress(interfaceKey, address);
290290

291291
// Set the flag to start the timer for resolve on SRP domain to complete if the key has the SRP type requested flag set to
@@ -339,7 +339,7 @@ static void GetAddrInfo(ResolveContext * sdCtx)
339339
if (!interface.second.isDNSLookUpRequested)
340340
{
341341
ResolveContextWithType * contextWithType =
342-
(interface.first.isSRPTypeRequested) ? &sdCtx->resolveContextWithSRPType : &sdCtx->resolveContextWithNonSRPType;
342+
(interface.first.isSRPResult) ? &sdCtx->resolveContextWithSRPType : &sdCtx->resolveContextWithNonSRPType;
343343
auto err = DNSServiceGetAddrInfo(&sdRefCopy, kGetAddrInfoFlags, interfaceId, protocol, hostname, OnGetAddrInfo,
344344
contextWithType);
345345
VerifyOrReturn(kDNSServiceErr_NoError == err, sdCtx->Finalize(err));

src/platform/Darwin/DnssdImpl.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,16 @@ struct InterfaceKey
240240

241241
uint32_t interfaceId;
242242
std::string hostname;
243-
bool isSRPTypeRequested = false;
243+
bool isSRPResult = false;
244244
};
245245

246246
struct ResolveContextWithType
247247
{
248248
ResolveContextWithType() = default;
249249
~ResolveContextWithType() = default;
250250

251-
ResolveContext * context;
252-
bool isSRPType = false;
251+
ResolveContext * const context;
252+
const bool isSRPResolve;
253253
};
254254

255255
struct ResolveContext : public GenericContext
@@ -263,7 +263,7 @@ struct ResolveContext : public GenericContext
263263

264264
// Indicates whether the timer for 250 msecs should be started
265265
// to give the resolve on SRP domain some extra time to complete.
266-
bool shoulStartSRPTimerForResolve = false;
266+
bool shouldStartSRPTimerForResolve = false;
267267
bool isSRPTimerRunning = false;
268268

269269
ResolveContextWithType resolveContextWithSRPType;
@@ -284,7 +284,7 @@ struct ResolveContext : public GenericContext
284284
bool HasAddress();
285285

286286
void OnNewInterface(uint32_t interfaceId, const char * fullname, const char * hostname, uint16_t port, uint16_t txtLen,
287-
const unsigned char * txtRecord, bool isSRPType);
287+
const unsigned char * txtRecord, bool isSRPResult);
288288
bool HasInterface();
289289
bool Matches(const char * otherInstanceName) const { return instanceName == otherInstanceName; }
290290

@@ -294,7 +294,7 @@ struct ResolveContext : public GenericContext
294294
* Returns true if information was reported, false if not (e.g. if there
295295
* were no IP addresses, etc).
296296
*/
297-
bool TryReportingResultsForInterfaceIndex(uint32_t interfaceIndex, std::string hostname, bool isSRPType);
297+
bool TryReportingResultsForInterfaceIndex(uint32_t interfaceIndex, const std::string & hostname, bool isSRPResult);
298298

299299
bool TryReportingResultsForInterfaceIndex(uint32_t interfaceIndex);
300300
};

0 commit comments

Comments
 (0)