mirror of
https://github.com/espressif/openthread.git
synced 2026-08-05 18:37:45 +00:00
[style] mark single-arg constructors as explicit (#3705)
Avoids unintentional implicit conversions.
This commit is contained in:
committed by
Jonathan Hui
parent
f2d93917c2
commit
e00114b3f1
+1
-1
@@ -263,7 +263,7 @@ template <class T> class otPtr
|
||||
T *ptr;
|
||||
|
||||
public:
|
||||
otPtr(T *_ptr)
|
||||
explicit otPtr(T *_ptr)
|
||||
: ptr(_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ public:
|
||||
*
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*/
|
||||
Interpreter(Instance *aInstance);
|
||||
explicit Interpreter(Instance *aInstance);
|
||||
|
||||
/**
|
||||
* This method interprets a CLI command.
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
* @param[in] aInterpreter The CLI interpreter.
|
||||
*
|
||||
*/
|
||||
Coap(Interpreter &aInterpreter);
|
||||
explicit Coap(Interpreter &aInterpreter);
|
||||
|
||||
/**
|
||||
* This method interprets a list of CLI arguments.
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
* @param[in] aInterpreter The CLI interpreter.
|
||||
*
|
||||
*/
|
||||
CoapSecure(Interpreter &aInterpreter);
|
||||
explicit CoapSecure(Interpreter &aInterpreter);
|
||||
|
||||
/**
|
||||
* This method interprets a list of CLI arguments.
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
Console(Instance *aInstance);
|
||||
explicit Console(Instance *aInstance);
|
||||
|
||||
/**
|
||||
* This method delivers raw characters to the client.
|
||||
|
||||
@@ -52,7 +52,7 @@ class Interpreter;
|
||||
class Dataset
|
||||
{
|
||||
public:
|
||||
Dataset(Interpreter &aInterpreter)
|
||||
explicit Dataset(Interpreter &aInterpreter)
|
||||
: mInterpreter(aInterpreter)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Cli {
|
||||
class Server
|
||||
{
|
||||
public:
|
||||
Server(Instance *aInstance)
|
||||
explicit Server(Instance *aInstance)
|
||||
: mInterpreter(aInstance)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
Uart(Instance *aInstance);
|
||||
explicit Uart(Instance *aInstance);
|
||||
|
||||
/**
|
||||
* This method delivers raw characters to the client.
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public:
|
||||
* @param[in] aInterpreter The CLI interpreter.
|
||||
*
|
||||
*/
|
||||
UdpExample(Interpreter &aInterpreter);
|
||||
explicit UdpExample(Interpreter &aInterpreter);
|
||||
|
||||
/**
|
||||
* This method interprets a list of CLI arguments.
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <openthread/link.h>
|
||||
|
||||
#include "common/instance.hpp"
|
||||
#include "mac/mac.hpp"
|
||||
#include "phy/phy.hpp"
|
||||
|
||||
using namespace ot;
|
||||
@@ -101,7 +102,7 @@ otError otLinkSetSupportedChannelMask(otInstance *aInstance, uint32_t aChannelMa
|
||||
VerifyOrExit(instance.GetThreadNetif().GetMle().GetRole() == OT_DEVICE_ROLE_DISABLED,
|
||||
error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
instance.GetThreadNetif().GetMac().SetSupportedChannelMask(aChannelMask);
|
||||
instance.GetThreadNetif().GetMac().SetSupportedChannelMask(static_cast<Mac::ChannelMask>(aChannelMask));
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -507,8 +507,8 @@ otError otThreadDiscover(otInstance * aInstance,
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.GetThreadNetif().GetMle().Discover(aScanChannels, aPanId, aJoiner, aEnableEui64Filtering, aCallback,
|
||||
aCallbackContext);
|
||||
return instance.GetThreadNetif().GetMle().Discover(static_cast<Mac::ChannelMask>(aScanChannels), aPanId, aJoiner,
|
||||
aEnableEui64Filtering, aCallback, aCallbackContext);
|
||||
}
|
||||
|
||||
bool otThreadIsDiscoverInProgress(otInstance *aInstance)
|
||||
|
||||
@@ -267,7 +267,7 @@ public:
|
||||
* @param[in] aMessageInfo The message info containing source endpoint identification.
|
||||
*
|
||||
*/
|
||||
EnqueuedResponseHeader(const Ip6::MessageInfo &aMessageInfo)
|
||||
explicit EnqueuedResponseHeader(const Ip6::MessageInfo &aMessageInfo)
|
||||
: mDequeueTime(TimerMilli::GetNow() + TimerMilli::SecToMsec(kExchangeLifetime))
|
||||
, mMessageInfo(aMessageInfo)
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
* @param[in] aPolynomial The polynomial value.
|
||||
*
|
||||
*/
|
||||
Crc16(Polynomial aPolynomial);
|
||||
explicit Crc16(Polynomial aPolynomial);
|
||||
|
||||
/**
|
||||
* This method initializes the CRC16 computation.
|
||||
|
||||
@@ -114,7 +114,7 @@ protected:
|
||||
* @param[in] aInstance A pointer to the otInstance.
|
||||
*
|
||||
*/
|
||||
InstanceLocator(Instance &aInstance)
|
||||
explicit InstanceLocator(Instance &aInstance)
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
: mInstance(aInstance)
|
||||
#endif
|
||||
@@ -162,7 +162,7 @@ protected:
|
||||
* @param[in] aOwner A pointer to the owner object (as `void *`).
|
||||
*
|
||||
*/
|
||||
OwnerLocator(void *aOwner)
|
||||
explicit OwnerLocator(void *aOwner)
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
: mOwner(aOwner)
|
||||
#endif
|
||||
|
||||
@@ -1244,7 +1244,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
Iterator(Message *aMessage)
|
||||
explicit Iterator(Message *aMessage)
|
||||
: mMessage(aMessage)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ public:
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
*
|
||||
*/
|
||||
ChildInfoIterator(Instance &aInstance);
|
||||
explicit ChildInfoIterator(Instance &aInstance);
|
||||
|
||||
/**
|
||||
* This method resets the iterator to start from the first Child Info entry in the list.
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
* @param[in] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
String(const char *aFormat, ...)
|
||||
explicit String(const char *aFormat, ...)
|
||||
: mLength(0)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
@@ -295,7 +295,7 @@ protected:
|
||||
* @param[in] aInstance A reference to the instance object.
|
||||
*
|
||||
*/
|
||||
TimerScheduler(Instance &aInstance)
|
||||
explicit TimerScheduler(Instance &aInstance)
|
||||
: InstanceLocator(aInstance)
|
||||
, mHead(NULL)
|
||||
{
|
||||
@@ -351,7 +351,7 @@ public:
|
||||
* @param[in] aInstance A reference to the instance object.
|
||||
*
|
||||
*/
|
||||
TimerMilliScheduler(Instance &aInstance)
|
||||
explicit TimerMilliScheduler(Instance &aInstance)
|
||||
: TimerScheduler(aInstance)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
* @param[in] aMask A channel mask (as a `uint32_t` bit-vector mask with bit 0 (lsb) -> channel 0, and so on).
|
||||
*
|
||||
*/
|
||||
ChannelMask(uint32_t aMask)
|
||||
explicit ChannelMask(uint32_t aMask)
|
||||
: mMask(aMask)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ void Mac::SetSupportedChannelMask(const ChannelMask &aMask)
|
||||
{
|
||||
ChannelMask newMask = aMask;
|
||||
|
||||
newMask.Intersect(Phy::kSupportedChannels);
|
||||
newMask.Intersect(ChannelMask(Phy::kSupportedChannels));
|
||||
VerifyOrExit(newMask != mSupportedChannelMask, GetNotifier().SignalIfFirst(OT_CHANGED_SUPPORTED_CHANNEL_MASK));
|
||||
|
||||
mSupportedChannelMask = newMask;
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
* @param[in] aType The type of the dataset, active or pending.
|
||||
*
|
||||
*/
|
||||
Dataset(const Tlv::Type aType);
|
||||
explicit Dataset(const Tlv::Type aType);
|
||||
|
||||
/**
|
||||
* This method clears the Dataset.
|
||||
|
||||
@@ -127,8 +127,8 @@ otError Joiner::Start(const char * aPSKd,
|
||||
|
||||
memset(mJoinerRouters, 0, sizeof(mJoinerRouters));
|
||||
|
||||
SuccessOrExit(error =
|
||||
netif.GetMle().Discover(0, netif.GetMac().GetPanId(), true, false, HandleDiscoverResult, this));
|
||||
SuccessOrExit(error = netif.GetMle().Discover(Mac::ChannelMask(0), netif.GetMac().GetPanId(), true, false,
|
||||
HandleDiscoverResult, this));
|
||||
|
||||
mVendorName = aVendorName;
|
||||
mVendorModel = aVendorModel;
|
||||
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
* @param[in] aNetif A reference to the network interface that DNS client should be assigned to.
|
||||
*
|
||||
*/
|
||||
Client(Ip6::Netif &aNetif)
|
||||
explicit Client(Ip6::Netif &aNetif)
|
||||
: mSocket(aNetif.GetIp6().GetUdp())
|
||||
, mMessageId(0)
|
||||
, mRetransmissionTimer(aNetif.GetInstance(), &Client::HandleRetransmissionTimer, this){};
|
||||
|
||||
@@ -528,7 +528,7 @@ public:
|
||||
* @param[in] aNetif A reference to the network interface that SNTP client should be assigned to.
|
||||
*
|
||||
*/
|
||||
Client(Ip6::Netif &aNetif)
|
||||
explicit Client(Ip6::Netif &aNetif)
|
||||
: mSocket(aNetif.GetIp6().GetUdp())
|
||||
, mRetransmissionTimer(aNetif.GetInstance(), &Client::HandleRetransmissionTimer, this)
|
||||
, mUnixEra(0){};
|
||||
|
||||
@@ -66,7 +66,7 @@ otError AnnounceSenderBase::SendAnnounce(Mac::ChannelMask aMask, uint8_t aCount,
|
||||
VerifyOrExit(aPeriod != 0, error = OT_ERROR_INVALID_ARGS);
|
||||
VerifyOrExit(aJitter < aPeriod, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
aMask.Intersect(Phy::kSupportedChannels);
|
||||
aMask.Intersect(Mac::ChannelMask(Phy::kSupportedChannels));
|
||||
VerifyOrExit(!aMask.IsEmpty(), error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
mChannelMask = aMask;
|
||||
|
||||
@@ -488,7 +488,7 @@ private:
|
||||
};
|
||||
|
||||
public:
|
||||
NetworkDataIterator(otNetworkDataIterator *aIterator)
|
||||
explicit NetworkDataIterator(otNetworkDataIterator *aIterator)
|
||||
: mIteratorBuffer(reinterpret_cast<uint8_t *>(aIterator))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
*
|
||||
*/
|
||||
Iterator(Instance &aInstance);
|
||||
explicit Iterator(Instance &aInstance);
|
||||
|
||||
/**
|
||||
* This method resets the iterator to start over.
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
*
|
||||
*/
|
||||
RouterTable(Instance &aInstance);
|
||||
explicit RouterTable(Instance &aInstance);
|
||||
|
||||
/**
|
||||
* This method clears the router table.
|
||||
@@ -371,7 +371,7 @@ public:
|
||||
class Iterator
|
||||
{
|
||||
public:
|
||||
Iterator(Instance &) {}
|
||||
explicit Iterator(Instance &) {}
|
||||
void Reset(void) {}
|
||||
bool IsDone(void) const { return true; }
|
||||
void Advance(void) {}
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
*
|
||||
*/
|
||||
ChannelMonitor(Instance &aInstance);
|
||||
explicit ChannelMonitor(Instance &aInstance);
|
||||
|
||||
/**
|
||||
* This method starts the Channel Monitoring operation.
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
NcpBase(Instance *aInstance);
|
||||
explicit NcpBase(Instance *aInstance);
|
||||
|
||||
/**
|
||||
* This static method returns the pointer to the single NCP instance.
|
||||
|
||||
+2
-2
@@ -58,7 +58,7 @@ public:
|
||||
* @param[in] aBuffer Pointer to buffer containing the frame.
|
||||
*
|
||||
*/
|
||||
SpiFrame(uint8_t *aBuffer)
|
||||
explicit SpiFrame(uint8_t *aBuffer)
|
||||
: mBuffer(aBuffer)
|
||||
{
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public:
|
||||
* @param[in] aInstance A pointer to the OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
NcpSpi(Instance *aInstance);
|
||||
explicit NcpSpi(Instance *aInstance);
|
||||
|
||||
private:
|
||||
enum
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
* @param[in] aInstance The OpenThread instance structure.
|
||||
*
|
||||
*/
|
||||
NcpUart(Instance *aInstance);
|
||||
explicit NcpUart(Instance *aInstance);
|
||||
|
||||
/**
|
||||
* This method is called when uart tx is finished. It prepares and sends the next data chunk (if any) to uart.
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
* @param[in] aNcpBuffer A reference to a `NcpFrameBuffer` where the frames are written.
|
||||
*
|
||||
*/
|
||||
SpinelEncoder(NcpFrameBuffer &aNcpBuffer)
|
||||
explicit SpinelEncoder(NcpFrameBuffer &aNcpBuffer)
|
||||
: mNcpBuffer(aNcpBuffer)
|
||||
, mNumOpenStructs(0)
|
||||
, mSavedNumOpenStructs(0)
|
||||
|
||||
Reference in New Issue
Block a user