clang-tidy: Apply fixes "modernize-use-nullptr" (#2770)
diff --git a/src/inet/AsyncDNSResolverSockets.cpp b/src/inet/AsyncDNSResolverSockets.cpp
index 36dde6b..53f1fa1 100644
--- a/src/inet/AsyncDNSResolverSockets.cpp
+++ b/src/inet/AsyncDNSResolverSockets.cpp
@@ -56,19 +56,19 @@
mInet = aInet;
- mAsyncDNSQueueHead = NULL;
- mAsyncDNSQueueTail = NULL;
+ mAsyncDNSQueueHead = nullptr;
+ mAsyncDNSQueueTail = nullptr;
- pthreadErr = pthread_cond_init(&mAsyncDNSCondVar, NULL);
+ pthreadErr = pthread_cond_init(&mAsyncDNSCondVar, nullptr);
VerifyOrDie(pthreadErr == 0);
- pthreadErr = pthread_mutex_init(&mAsyncDNSMutex, NULL);
+ pthreadErr = pthread_mutex_init(&mAsyncDNSMutex, nullptr);
VerifyOrDie(pthreadErr == 0);
// Create the thread pool for asynchronous DNS resolution.
for (int i = 0; i < INET_CONFIG_DNS_ASYNC_MAX_THREAD_COUNT; i++)
{
- pthreadErr = pthread_create(&mAsyncDNSThreadHandle[i], NULL, &AsyncDNSThreadRun, this);
+ pthreadErr = pthread_create(&mAsyncDNSThreadHandle[i], nullptr, &AsyncDNSThreadRun, this);
VerifyOrDie(pthreadErr == 0);
}
@@ -100,7 +100,7 @@
// Have the CHIP thread join the thread pool for asynchronous DNS resolution.
for (int i = 0; i < INET_CONFIG_DNS_ASYNC_MAX_THREAD_COUNT; i++)
{
- pthreadErr = pthread_join(mAsyncDNSThreadHandle[i], NULL);
+ pthreadErr = pthread_join(mAsyncDNSThreadHandle[i], nullptr);
VerifyOrDie(pthreadErr == 0);
}
@@ -152,7 +152,7 @@
resolver.OnComplete = onComplete;
resolver.asyncDNSResolveResult = INET_NO_ERROR;
resolver.mState = DNSResolver::kState_Active;
- resolver.pNextAsyncDNSResolver = NULL;
+ resolver.pNextAsyncDNSResolver = nullptr;
return err;
}
@@ -177,12 +177,12 @@
AsyncMutexLock();
// Add the DNSResolver object to the queue.
- if (mAsyncDNSQueueHead == NULL)
+ if (mAsyncDNSQueueHead == nullptr)
{
mAsyncDNSQueueHead = &resolver;
}
- if (mAsyncDNSQueueTail != NULL)
+ if (mAsyncDNSQueueTail != nullptr)
{
mAsyncDNSQueueTail->pNextAsyncDNSResolver = &resolver;
}
@@ -210,7 +210,7 @@
AsyncMutexLock();
// block until there is work to do or we detect a shutdown
- while ((mAsyncDNSQueueHead == NULL) && (mInet->State == InetLayer::kState_Initialized))
+ while ((mAsyncDNSQueueHead == nullptr) && (mInet->State == InetLayer::kState_Initialized))
{
pthreadErr = pthread_cond_wait(&mAsyncDNSCondVar, &mAsyncDNSMutex);
VerifyOrDie(pthreadErr == 0);
@@ -221,7 +221,7 @@
// on shutdown, return NULL. Otherwise, pop the head of the DNS request queue
if (mInet->State != InetLayer::kState_Initialized)
{
- *outResolver = NULL;
+ *outResolver = nullptr;
}
else
{
@@ -229,10 +229,10 @@
mAsyncDNSQueueHead = mAsyncDNSQueueHead->pNextAsyncDNSResolver;
- if (mAsyncDNSQueueHead == NULL)
+ if (mAsyncDNSQueueHead == nullptr)
{
// Queue is empty
- mAsyncDNSQueueTail = NULL;
+ mAsyncDNSQueueTail = nullptr;
}
}
@@ -263,7 +263,7 @@
{
resolver.NumAddrs = 0;
- for (struct addrinfo * addr = inLookupRes; addr != NULL && resolver.NumAddrs < resolver.MaxAddrs;
+ for (struct addrinfo * addr = inLookupRes; addr != nullptr && resolver.NumAddrs < resolver.MaxAddrs;
addr = addr->ai_next, resolver.NumAddrs++)
{
resolver.AddrArray[resolver.NumAddrs] = IPAddress::FromSockAddr(*addr->ai_addr);
@@ -273,14 +273,14 @@
void AsyncDNSResolverSockets::Resolve(DNSResolver & resolver)
{
struct addrinfo gaiHints;
- struct addrinfo * gaiResults = NULL;
+ struct addrinfo * gaiResults = nullptr;
int gaiReturnCode;
// Configure the hints argument for getaddrinfo()
resolver.InitAddrInfoHints(gaiHints);
// Call getaddrinfo() to perform the name resolution.
- gaiReturnCode = getaddrinfo(resolver.asyncHostNameBuf, NULL, &gaiHints, &gaiResults);
+ gaiReturnCode = getaddrinfo(resolver.asyncHostNameBuf, nullptr, &gaiHints, &gaiResults);
// Mutex protects the read and write operation on resolver->mState
AsyncMutexLock();
@@ -326,7 +326,7 @@
while (true)
{
- DNSResolver * request = NULL;
+ DNSResolver * request = nullptr;
// Dequeue a DNSResolver for resolution. This function would block until there
// is an item in the queue or shutdown has been called.
@@ -334,7 +334,7 @@
// If shutdown has been called, DeQueue would return with an empty request.
// In that case, break out of the loop and exit thread.
- VerifyOrExit(err == INET_NO_ERROR && request != NULL, );
+ VerifyOrExit(err == INET_NO_ERROR && request != nullptr, );
if (request->mState != DNSResolver::kState_Canceled)
{
@@ -346,7 +346,7 @@
exit:
ChipLogDetail(Inet, "Async DNS worker thread exiting.");
- return NULL;
+ return nullptr;
}
void AsyncDNSResolverSockets::AsyncMutexLock(void)
diff --git a/src/inet/DNSResolver.cpp b/src/inet/DNSResolver.cpp
index 63837bc..5bd6ad5 100644
--- a/src/inet/DNSResolver.cpp
+++ b/src/inet/DNSResolver.cpp
@@ -210,14 +210,14 @@
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS
struct addrinfo gaiHints;
- struct addrinfo * gaiResults = NULL;
+ struct addrinfo * gaiResults = nullptr;
int gaiReturnCode;
// Configure the hints argument for getaddrinfo()
InitAddrInfoHints(gaiHints);
// Call getaddrinfo() to perform the name resolution.
- gaiReturnCode = getaddrinfo(hostNameBuf, NULL, &gaiHints, &gaiResults);
+ gaiReturnCode = getaddrinfo(hostNameBuf, nullptr, &gaiHints, &gaiResults);
// Process the return code and results list returned by getaddrinfo(). If the call
// was successful this will copy the resultant addresses into the caller's array.
@@ -276,8 +276,8 @@
InetLayer & inet = Layer();
- OnComplete = NULL;
- AppState = NULL;
+ OnComplete = nullptr;
+ AppState = nullptr;
inet.mAsyncDNSResolver.Cancel(*this);
#endif // INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS
@@ -486,7 +486,7 @@
}
// Free the results structure.
- if (results != NULL)
+ if (results != nullptr)
freeaddrinfo(results);
return err;
@@ -494,7 +494,7 @@
void DNSResolver::CopyAddresses(int family, uint8_t count, const struct addrinfo * addrs)
{
- for (const struct addrinfo * addr = addrs; addr != NULL && NumAddrs < MaxAddrs && count > 0; addr = addr->ai_next)
+ for (const struct addrinfo * addr = addrs; addr != nullptr && NumAddrs < MaxAddrs && count > 0; addr = addr->ai_next)
{
if (family == AF_UNSPEC || addr->ai_addr->sa_family == family)
{
@@ -508,7 +508,7 @@
{
uint8_t count = 0;
- for (const struct addrinfo * addr = addrs; addr != NULL && count < UINT8_MAX; addr = addr->ai_next)
+ for (const struct addrinfo * addr = addrs; addr != nullptr && count < UINT8_MAX; addr = addr->ai_next)
{
if (family == AF_UNSPEC || addr->ai_addr->sa_family == family)
{
diff --git a/src/inet/EndPointBasis.h b/src/inet/EndPointBasis.h
index c958abe..4e859e4 100644
--- a/src/inet/EndPointBasis.h
+++ b/src/inet/EndPointBasis.h
@@ -130,7 +130,7 @@
void DeferredFree(chip::System::Object::ReleaseDeferralErrorTactic aTactic);
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
- void InitEndPointBasis(InetLayer & aInetLayer, void * aAppState = NULL);
+ void InitEndPointBasis(InetLayer & aInetLayer, void * aAppState = nullptr);
};
#if CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
diff --git a/src/inet/IPAddress-StringFuncts.cpp b/src/inet/IPAddress-StringFuncts.cpp
index 238241f..68cfd3a 100644
--- a/src/inet/IPAddress-StringFuncts.cpp
+++ b/src/inet/IPAddress-StringFuncts.cpp
@@ -84,7 +84,7 @@
bool IPAddress::FromString(const char * str, IPAddress & output)
{
#if INET_CONFIG_ENABLE_IPV4
- if (strchr(str, ':') == NULL)
+ if (strchr(str, ':') == nullptr)
{
#if CHIP_SYSTEM_CONFIG_USE_LWIP
#if LWIP_VERSION_MAJOR > 1 || LWIP_VERSION_MINOR >= 5
diff --git a/src/inet/IPEndPointBasis.cpp b/src/inet/IPEndPointBasis.cpp
index e75a9d8..b3d2846 100644
--- a/src/inet/IPEndPointBasis.cpp
+++ b/src/inet/IPEndPointBasis.cpp
@@ -810,7 +810,7 @@
VerifyOrExit(mAddrType == aPktInfo->DestAddress.Type(), res = INET_ERROR_BAD_ARGS);
// For now the entire message must fit within a single buffer.
- VerifyOrExit(aBuffer->Next() == NULL, res = INET_ERROR_MESSAGE_TOO_LONG);
+ VerifyOrExit(aBuffer->Next() == nullptr, res = INET_ERROR_MESSAGE_TOO_LONG);
memset(&msgHeader, 0, sizeof(msgHeader));
@@ -1045,7 +1045,7 @@
{
SocketEvents res;
- if (mState == kState_Listening && OnMessageReceived != NULL)
+ if (mState == kState_Listening && OnMessageReceived != nullptr)
res.SetRead();
return res;
@@ -1062,7 +1062,7 @@
lBuffer = PacketBuffer::New(0);
- if (lBuffer != NULL)
+ if (lBuffer != nullptr)
{
struct iovec msgIOV;
PeerSockAddr lPeerSockAddr;
@@ -1117,7 +1117,7 @@
if (lStatus == INET_NO_ERROR)
{
- for (struct cmsghdr * controlHdr = CMSG_FIRSTHDR(&msgHeader); controlHdr != NULL;
+ for (struct cmsghdr * controlHdr = CMSG_FIRSTHDR(&msgHeader); controlHdr != nullptr;
controlHdr = CMSG_NXTHDR(&msgHeader, controlHdr))
{
#if INET_CONFIG_ENABLE_IPV4
@@ -1164,8 +1164,8 @@
else
{
PacketBuffer::Free(lBuffer);
- if (OnReceiveError != NULL && lStatus != chip::System::MapErrorPOSIX(EAGAIN))
- OnReceiveError(this, lStatus, NULL);
+ if (OnReceiveError != nullptr && lStatus != chip::System::MapErrorPOSIX(EAGAIN))
+ OnReceiveError(this, lStatus, nullptr);
}
return;
diff --git a/src/inet/InetError.cpp b/src/inet/InetError.cpp
index a968622..363481b 100644
--- a/src/inet/InetError.cpp
+++ b/src/inet/InetError.cpp
@@ -38,7 +38,7 @@
*/
void RegisterLayerErrorFormatter(void)
{
- static chip::ErrorFormatter sInetLayerErrorFormatter = { FormatLayerError, NULL };
+ static chip::ErrorFormatter sInetLayerErrorFormatter = { FormatLayerError, nullptr };
RegisterErrorFormatter(&sInetLayerErrorFormatter);
}
@@ -57,7 +57,7 @@
*/
bool FormatLayerError(char * buf, uint16_t bufSize, int32_t err)
{
- const char * desc = NULL;
+ const char * desc = nullptr;
if (err < INET_ERROR_MIN || err > INET_ERROR_MAX)
{
diff --git a/src/inet/InetInterface.cpp b/src/inet/InetInterface.cpp
index a7468eb..24828f7 100644
--- a/src/inet/InetInterface.cpp
+++ b/src/inet/InetInterface.cpp
@@ -97,7 +97,7 @@
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
char intfName[IF_NAMESIZE];
- if (if_indextoname(intfId, intfName) == NULL)
+ if (if_indextoname(intfId, intfName) == nullptr)
return chip::System::MapErrorPOSIX(errno);
if (strlen(intfName) >= nameBufSize)
return INET_ERROR_NO_MEMORY;
@@ -394,7 +394,7 @@
InterfaceIterator::InterfaceIterator(void)
{
- mIntfArray = NULL;
+ mIntfArray = nullptr;
mCurIntf = 0;
mIntfFlags = 0;
mIntfFlagsCached = 0;
@@ -419,14 +419,14 @@
InterfaceIterator::~InterfaceIterator(void)
{
- if (mIntfArray != NULL)
+ if (mIntfArray != nullptr)
{
#if __ANDROID__ && __ANDROID_API__ < 24
backport_if_freenameindex(mIntfArray);
#else
if_freenameindex(mIntfArray);
#endif
- mIntfArray = NULL;
+ mIntfArray = nullptr;
}
}
@@ -444,7 +444,7 @@
#if CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
bool InterfaceIterator::HasCurrent(void)
{
- return (mIntfArray != NULL) ? mIntfArray[mCurIntf].if_index != 0 : Next();
+ return (mIntfArray != nullptr) ? mIntfArray[mCurIntf].if_index != 0 : Next();
}
#endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
@@ -479,7 +479,7 @@
{
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
- if (mIntfArray == NULL)
+ if (mIntfArray == nullptr)
{
#if __ANDROID__ && __ANDROID_API__ < 24
mIntfArray = backport_if_nameindex();
@@ -493,7 +493,7 @@
mIntfFlags = 0;
mIntfFlagsCached = false;
}
- return (mIntfArray != NULL && mIntfArray[mCurIntf].if_index != 0);
+ return (mIntfArray != nullptr && mIntfArray[mCurIntf].if_index != 0);
#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS && CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
@@ -705,8 +705,8 @@
*/
InterfaceAddressIterator::InterfaceAddressIterator(void)
{
- mAddrsList = NULL;
- mCurAddr = NULL;
+ mAddrsList = nullptr;
+ mCurAddr = nullptr;
}
#endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
@@ -726,10 +726,10 @@
#if CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
InterfaceAddressIterator::~InterfaceAddressIterator(void)
{
- if (mAddrsList != NULL)
+ if (mAddrsList != nullptr)
{
freeifaddrs(mAddrsList);
- mAddrsList = mCurAddr = NULL;
+ mAddrsList = mCurAddr = nullptr;
}
}
#endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
@@ -745,7 +745,7 @@
bool InterfaceAddressIterator::HasCurrent(void)
{
#if CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
- return (mAddrsList != NULL) ? (mCurAddr != NULL) : Next();
+ return (mAddrsList != nullptr) ? (mCurAddr != nullptr) : Next();
#endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
#if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
@@ -778,7 +778,7 @@
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS && CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
while (true)
{
- if (mAddrsList == NULL)
+ if (mAddrsList == nullptr)
{
int res = getifaddrs(&mAddrsList);
if (res < 0)
@@ -787,17 +787,17 @@
}
mCurAddr = mAddrsList;
}
- else if (mCurAddr != NULL)
+ else if (mCurAddr != nullptr)
{
mCurAddr = mCurAddr->ifa_next;
}
- if (mCurAddr == NULL)
+ if (mCurAddr == nullptr)
{
return false;
}
- if (mCurAddr->ifa_addr != NULL &&
+ if (mCurAddr->ifa_addr != nullptr &&
(mCurAddr->ifa_addr->sa_family == AF_INET6
#if INET_CONFIG_ENABLE_IPV4
|| mCurAddr->ifa_addr->sa_family == AF_INET
diff --git a/src/inet/InetLayer.cpp b/src/inet/InetLayer.cpp
index 8555c4e..84da8cd 100644
--- a/src/inet/InetLayer.cpp
+++ b/src/inet/InetLayer.cpp
@@ -262,7 +262,7 @@
// member. Ensure it is set to a sane default value before
// invoking platform-specific initialization.
- mPlatformData = NULL;
+ mPlatformData = nullptr;
err = Platform::InetLayer::WillInit(this, aContext);
SuccessOrExit(err);
@@ -322,7 +322,7 @@
for (size_t i = 0; i < DNSResolver::sPool.Size(); i++)
{
DNSResolver * lResolver = DNSResolver::sPool.Get(*mSystemLayer, i);
- if ((lResolver != NULL) && lResolver->IsCreatedByInetLayer(*this))
+ if ((lResolver != nullptr) && lResolver->IsCreatedByInetLayer(*this))
{
lResolver->Cancel();
}
@@ -340,7 +340,7 @@
for (size_t i = 0; i < RawEndPoint::sPool.Size(); i++)
{
RawEndPoint * lEndPoint = RawEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
{
lEndPoint->Close();
}
@@ -352,7 +352,7 @@
for (size_t i = 0; i < TCPEndPoint::sPool.Size(); i++)
{
TCPEndPoint * lEndPoint = TCPEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
{
lEndPoint->Abort();
}
@@ -364,7 +364,7 @@
for (size_t i = 0; i < UDPEndPoint::sPool.Size(); i++)
{
UDPEndPoint * lEndPoint = UDPEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
{
lEndPoint->Close();
}
@@ -415,7 +415,7 @@
{
TCPEndPoint * lEndPoint = TCPEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && (lEndPoint->mIdleTimeout != 0))
+ if ((lEndPoint != nullptr) && (lEndPoint->mIdleTimeout != 0))
{
timerRunning = true;
break;
@@ -452,7 +452,7 @@
#endif //! LWIP_IPV6
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
- if (llAddr == NULL)
+ if (llAddr == nullptr)
{
err = INET_ERROR_BAD_ARGS;
goto exit;
@@ -487,10 +487,10 @@
if (rv != -1)
{
struct ifaddrs * ifaddr_iter = ifaddr;
- while (ifaddr_iter != NULL)
+ while (ifaddr_iter != nullptr)
{
- if (ifaddr_iter->ifa_addr != NULL)
+ if (ifaddr_iter->ifa_addr != nullptr)
{
if ((ifaddr_iter->ifa_addr->sa_family == AF_INET6) &&
((link == INET_NULL_INTERFACEID) || (if_nametoindex(ifaddr_iter->ifa_name) == link)))
@@ -555,12 +555,12 @@
INET_ERROR InetLayer::NewRawEndPoint(IPVersion ipVer, IPProtocol ipProto, RawEndPoint ** retEndPoint)
{
INET_ERROR err = INET_NO_ERROR;
- *retEndPoint = NULL;
+ *retEndPoint = nullptr;
VerifyOrExit(State == kState_Initialized, err = INET_ERROR_INCORRECT_STATE);
*retEndPoint = RawEndPoint::sPool.TryCreate(*mSystemLayer);
- if (*retEndPoint != NULL)
+ if (*retEndPoint != nullptr)
{
(*retEndPoint)->Inet::RawEndPoint::Init(this, ipVer, ipProto);
SYSTEM_STATS_INCREMENT(chip::System::Stats::kInetLayer_NumRawEps);
@@ -597,12 +597,12 @@
INET_ERROR InetLayer::NewTCPEndPoint(TCPEndPoint ** retEndPoint)
{
INET_ERROR err = INET_NO_ERROR;
- *retEndPoint = NULL;
+ *retEndPoint = nullptr;
VerifyOrExit(State == kState_Initialized, err = INET_ERROR_INCORRECT_STATE);
*retEndPoint = TCPEndPoint::sPool.TryCreate(*mSystemLayer);
- if (*retEndPoint != NULL)
+ if (*retEndPoint != nullptr)
{
(*retEndPoint)->Init(this);
SYSTEM_STATS_INCREMENT(chip::System::Stats::kInetLayer_NumTCPEps);
@@ -639,12 +639,12 @@
INET_ERROR InetLayer::NewUDPEndPoint(UDPEndPoint ** retEndPoint)
{
INET_ERROR err = INET_NO_ERROR;
- *retEndPoint = NULL;
+ *retEndPoint = nullptr;
VerifyOrExit(State == kState_Initialized, err = INET_ERROR_INCORRECT_STATE);
*retEndPoint = UDPEndPoint::sPool.TryCreate(*mSystemLayer);
- if (*retEndPoint != NULL)
+ if (*retEndPoint != nullptr)
{
(*retEndPoint)->Init(this);
SYSTEM_STATS_INCREMENT(chip::System::Stats::kInetLayer_NumUDPEps);
@@ -809,7 +809,7 @@
IPAddress * addrArray, DNSResolveCompleteFunct onComplete, void * appState)
{
INET_ERROR err = INET_NO_ERROR;
- DNSResolver * resolver = NULL;
+ DNSResolver * resolver = nullptr;
VerifyOrExit(State == kState_Initialized, err = INET_ERROR_INCORRECT_STATE);
@@ -820,7 +820,7 @@
VerifyOrExit(maxAddrs > 0, err = INET_ERROR_NO_MEMORY);
resolver = DNSResolver::sPool.TryCreate(*mSystemLayer);
- if (resolver != NULL)
+ if (resolver != nullptr)
{
resolver->InitInetLayerBasis(*this);
}
@@ -852,7 +852,7 @@
}
resolver->Release();
- resolver = NULL;
+ resolver = nullptr;
ExitNow(err = INET_NO_ERROR);
}
@@ -905,7 +905,7 @@
{
DNSResolver * lResolver = DNSResolver::sPool.Get(*mSystemLayer, i);
- if (lResolver == NULL)
+ if (lResolver == nullptr)
{
continue;
}
@@ -1017,7 +1017,7 @@
{
TCPEndPoint * lEndPoint = TCPEndPoint::sPool.Get(*aSystemLayer, i);
- if (lEndPoint == NULL)
+ if (lEndPoint == nullptr)
continue;
if (!lEndPoint->IsCreatedByInetLayer(lInetLayer))
continue;
@@ -1139,7 +1139,7 @@
for (size_t i = 0; i < RawEndPoint::sPool.Size(); i++)
{
RawEndPoint * lEndPoint = RawEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
lEndPoint->PrepareIO().SetFDs(lEndPoint->mSocket, nfds, readfds, writefds, exceptfds);
}
#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT
@@ -1148,7 +1148,7 @@
for (size_t i = 0; i < TCPEndPoint::sPool.Size(); i++)
{
TCPEndPoint * lEndPoint = TCPEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
lEndPoint->PrepareIO().SetFDs(lEndPoint->mSocket, nfds, readfds, writefds, exceptfds);
}
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
@@ -1157,7 +1157,7 @@
for (size_t i = 0; i < UDPEndPoint::sPool.Size(); i++)
{
UDPEndPoint * lEndPoint = UDPEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
lEndPoint->PrepareIO().SetFDs(lEndPoint->mSocket, nfds, readfds, writefds, exceptfds);
}
#endif // INET_CONFIG_ENABLE_UDP_ENDPOINT
@@ -1205,7 +1205,7 @@
for (size_t i = 0; i < RawEndPoint::sPool.Size(); i++)
{
RawEndPoint * lEndPoint = RawEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
{
lEndPoint->mPendingIO = SocketEvents::FromFDs(lEndPoint->mSocket, readfds, writefds, exceptfds);
}
@@ -1216,7 +1216,7 @@
for (size_t i = 0; i < TCPEndPoint::sPool.Size(); i++)
{
TCPEndPoint * lEndPoint = TCPEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
{
lEndPoint->mPendingIO = SocketEvents::FromFDs(lEndPoint->mSocket, readfds, writefds, exceptfds);
}
@@ -1227,7 +1227,7 @@
for (size_t i = 0; i < UDPEndPoint::sPool.Size(); i++)
{
UDPEndPoint * lEndPoint = UDPEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
{
lEndPoint->mPendingIO = SocketEvents::FromFDs(lEndPoint->mSocket, readfds, writefds, exceptfds);
}
@@ -1239,7 +1239,7 @@
for (size_t i = 0; i < RawEndPoint::sPool.Size(); i++)
{
RawEndPoint * lEndPoint = RawEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
{
lEndPoint->HandlePendingIO();
}
@@ -1250,7 +1250,7 @@
for (size_t i = 0; i < TCPEndPoint::sPool.Size(); i++)
{
TCPEndPoint * lEndPoint = TCPEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
{
lEndPoint->HandlePendingIO();
}
@@ -1261,7 +1261,7 @@
for (size_t i = 0; i < UDPEndPoint::sPool.Size(); i++)
{
UDPEndPoint * lEndPoint = UDPEndPoint::sPool.Get(*mSystemLayer, i);
- if ((lEndPoint != NULL) && lEndPoint->IsCreatedByInetLayer(*this))
+ if ((lEndPoint != nullptr) && lEndPoint->IsCreatedByInetLayer(*this))
{
lEndPoint->HandlePendingIO();
}
diff --git a/src/inet/InetLayerBasis.h b/src/inet/InetLayerBasis.h
index 0774e3c..5423f31 100644
--- a/src/inet/InetLayerBasis.h
+++ b/src/inet/InetLayerBasis.h
@@ -57,7 +57,7 @@
bool IsCreatedByInetLayer(const InetLayer & aInetLayer) const;
protected:
- void InitInetLayerBasis(InetLayer & aInetLayer, void * aAppState = NULL);
+ void InitInetLayerBasis(InetLayer & aInetLayer, void * aAppState = nullptr);
private:
InetLayer * mInetLayer; /**< Pointer to the InetLayer object that owns this object. */
diff --git a/src/inet/InetUtils.cpp b/src/inet/InetUtils.cpp
index 9d0a355..1bb55dd 100644
--- a/src/inet/InetUtils.cpp
+++ b/src/inet/InetUtils.cpp
@@ -82,7 +82,7 @@
{
// Search for the end bracket.
p = (const char *) memchr(aString, ']', aStringLen);
- if (p == NULL)
+ if (p == nullptr)
return INET_ERROR_INVALID_HOST_NAME;
// Return the IPv6 address.
@@ -110,7 +110,7 @@
//
// Note: The cast is safe because p points into the string of p is not
// null, so end - p - 1 can't be negative.
- if (p == NULL || memchr(p + 1, ':', static_cast<size_t>(end - p - 1)) != NULL)
+ if (p == nullptr || memchr(p + 1, ':', static_cast<size_t>(end - p - 1)) != nullptr)
p = end;
// Return the host/address portion.
@@ -201,7 +201,7 @@
{
const char * end = aString + aStringLen;
- aInterface = NULL;
+ aInterface = nullptr;
aInterfaceLen = 0;
for (uint16_t i = 1; i < aStringLen; i++)
diff --git a/src/inet/RawEndPoint.cpp b/src/inet/RawEndPoint.cpp
index dbd3618..ab073e1 100644
--- a/src/inet/RawEndPoint.cpp
+++ b/src/inet/RawEndPoint.cpp
@@ -747,7 +747,8 @@
VerifyOrExit(IPVer == kIPVersion_6, err = INET_ERROR_WRONG_ADDRESS_TYPE);
VerifyOrExit(IPProto == kIPProtocol_ICMPv6, err = INET_ERROR_WRONG_PROTOCOL_TYPE);
- VerifyOrExit((numICMPTypes == 0 && aICMPTypes == NULL) || (numICMPTypes != 0 && aICMPTypes != NULL), err = INET_ERROR_BAD_ARGS);
+ VerifyOrExit((numICMPTypes == 0 && aICMPTypes == nullptr) || (numICMPTypes != 0 && aICMPTypes != nullptr),
+ err = INET_ERROR_BAD_ARGS);
err = INET_NO_ERROR;
@@ -1108,7 +1109,7 @@
void RawEndPoint::HandlePendingIO(void)
{
- if (mState == kState_Listening && OnMessageReceived != NULL && mPendingIO.IsReadable())
+ if (mState == kState_Listening && OnMessageReceived != nullptr && mPendingIO.IsReadable())
{
const uint16_t lPort = 0;
diff --git a/src/inet/TCPEndPoint.cpp b/src/inet/TCPEndPoint.cpp
index 6ccf122..654c3e7 100644
--- a/src/inet/TCPEndPoint.cpp
+++ b/src/inet/TCPEndPoint.cpp
@@ -443,7 +443,7 @@
fcntl(mSocket, F_SETFL, flags | O_NONBLOCK);
socklen_t sockaddrsize = 0;
- const sockaddr * sockaddrptr = NULL;
+ const sockaddr * sockaddrptr = nullptr;
union
{
@@ -494,7 +494,7 @@
if (conRes == 0)
{
State = kState_Connected;
- if (OnConnectComplete != NULL)
+ if (OnConnectComplete != nullptr)
OnConnectComplete(this, INET_NO_ERROR);
}
else
@@ -544,7 +544,7 @@
{
TCPEndPoint * tcpEndPoint = reinterpret_cast<TCPEndPoint *>(aAppState);
- VerifyOrDie((aSystemLayer != NULL) && (tcpEndPoint != NULL));
+ VerifyOrDie((aSystemLayer != nullptr) && (tcpEndPoint != nullptr));
// Close Connection as we have timed out and Connect has not returned to
// stop this timer.
@@ -700,7 +700,7 @@
return INET_ERROR_INCORRECT_STATE;
}
- if (mSendQueue == NULL)
+ if (mSendQueue == nullptr)
mSendQueue = data;
else
mSendQueue->AddToEnd(data);
@@ -1036,7 +1036,7 @@
uint32_t TCPEndPoint::PendingSendLength()
{
- if (mSendQueue != NULL)
+ if (mSendQueue != nullptr)
return mSendQueue->TotalLength();
else
return 0;
@@ -1044,7 +1044,7 @@
uint32_t TCPEndPoint::PendingReceiveLength()
{
- if (mRcvQueue != NULL)
+ if (mRcvQueue != nullptr)
return mRcvQueue->TotalLength();
else
return 0;
@@ -1075,12 +1075,12 @@
{
// Clear the receive queue.
PacketBuffer::Free(mRcvQueue);
- mRcvQueue = NULL;
+ mRcvQueue = nullptr;
// Suppress closing callbacks, since the application explicitly called Close().
- OnConnectionClosed = NULL;
- OnPeerClose = NULL;
- OnConnectComplete = NULL;
+ OnConnectionClosed = nullptr;
+ OnPeerClose = nullptr;
+ OnConnectComplete = nullptr;
// Perform a graceful close.
return DoClose(INET_NO_ERROR, true);
@@ -1089,9 +1089,9 @@
void TCPEndPoint::Abort()
{
// Suppress closing callbacks, since the application explicitly called Abort().
- OnConnectionClosed = NULL;
- OnPeerClose = NULL;
- OnConnectComplete = NULL;
+ OnConnectionClosed = nullptr;
+ OnPeerClose = nullptr;
+ OnConnectComplete = nullptr;
DoClose(INET_ERROR_CONNECTION_ABORTED, true);
}
@@ -1101,13 +1101,13 @@
INET_ERROR err;
// Ensure no callbacks to the app after this point.
- OnAcceptError = NULL;
- OnConnectComplete = NULL;
- OnConnectionReceived = NULL;
- OnConnectionClosed = NULL;
- OnPeerClose = NULL;
- OnDataReceived = NULL;
- OnDataSent = NULL;
+ OnAcceptError = nullptr;
+ OnConnectComplete = nullptr;
+ OnConnectionReceived = nullptr;
+ OnConnectionClosed = nullptr;
+ OnPeerClose = nullptr;
+ OnDataReceived = nullptr;
+ OnDataSent = nullptr;
// Ensure the end point is Closed or Closing.
err = Close();
@@ -1289,7 +1289,7 @@
return err;
});
- while (mSendQueue != NULL)
+ while (mSendQueue != nullptr)
{
uint16_t bufLen = mSendQueue->DataLength();
@@ -1319,7 +1319,7 @@
else
mSendQueue = PacketBuffer::FreeHead(mSendQueue);
- if (OnDataSent != NULL)
+ if (OnDataSent != nullptr)
OnDataSent(this, lenSent);
#if INET_CONFIG_ENABLE_TCP_SEND_IDLE_CALLBACKS
@@ -1362,7 +1362,7 @@
if (err == INET_NO_ERROR)
{
// If we're in the SendShutdown state and the send queue is now empty, shutdown writing on the socket.
- if (State == kState_SendShutdown && mSendQueue == NULL)
+ if (State == kState_SendShutdown && mSendQueue == nullptr)
{
if (shutdown(mSocket, SHUT_WR) != 0)
err = chip::System::MapErrorPOSIX(errno);
@@ -1383,16 +1383,16 @@
{
// If there's data in the receive queue and the app is ready to receive it then call the app's callback
// with the entire receive queue.
- if (mRcvQueue != NULL && ReceiveEnabled && OnDataReceived != NULL)
+ if (mRcvQueue != nullptr && ReceiveEnabled && OnDataReceived != nullptr)
{
PacketBuffer * rcvQueue = mRcvQueue;
- mRcvQueue = NULL;
+ mRcvQueue = nullptr;
OnDataReceived(this, rcvQueue);
}
// If the connection is closing, and the receive queue is now empty, call DoClose() to complete
// the process of closing the connection.
- if (State == kState_Closing && mRcvQueue == NULL)
+ if (State == kState_Closing && mRcvQueue == nullptr)
DoClose(INET_NO_ERROR, false);
}
@@ -1408,7 +1408,7 @@
MarkActive();
State = kState_Connected;
- if (OnConnectComplete != NULL)
+ if (OnConnectComplete != nullptr)
OnConnectComplete(this, INET_NO_ERROR);
}
@@ -1430,7 +1430,7 @@
// AND there is data waiting to be processed on either the send or receive queues
// ... THEN enter the Closing state, allowing the queued data to drain,
// ... OTHERWISE go straight to the Closed state.
- if (IsConnected() && err == INET_NO_ERROR && (mSendQueue != NULL || mRcvQueue != NULL))
+ if (IsConnected() && err == INET_NO_ERROR && (mSendQueue != nullptr || mRcvQueue != nullptr))
State = kState_Closing;
else
State = kState_Closed;
@@ -1520,7 +1520,7 @@
// If entering the Closed state
// OR if entering the Closing state, and there's no unsent data in the send queue
// THEN close the socket.
- if (State == kState_Closed || (State == kState_Closing && mSendQueue == NULL))
+ if (State == kState_Closed || (State == kState_Closing && mSendQueue == nullptr))
{
chip::System::Layer & lSystemLayer = SystemLayer();
@@ -1558,21 +1558,21 @@
{
// Clear clear the send and receive queues.
PacketBuffer::Free(mSendQueue);
- mSendQueue = NULL;
+ mSendQueue = nullptr;
PacketBuffer::Free(mRcvQueue);
- mRcvQueue = NULL;
+ mRcvQueue = nullptr;
// Call the appropriate app callback if allowed.
if (!suppressCallback)
{
if (oldState == kState_Connecting)
{
- if (OnConnectComplete != NULL)
+ if (OnConnectComplete != nullptr)
OnConnectComplete(this, err);
}
else if ((oldState == kState_Connected || oldState == kState_SendShutdown || oldState == kState_ReceiveShutdown ||
oldState == kState_Closing) &&
- OnConnectionClosed != NULL)
+ OnConnectionClosed != nullptr)
OnConnectionClosed(this, err);
}
@@ -1602,7 +1602,7 @@
{
TCPEndPoint * tcpEndPoint = reinterpret_cast<TCPEndPoint *>(aAppState);
- VerifyOrDie((aSystemLayer != NULL) && (tcpEndPoint != NULL));
+ VerifyOrDie((aSystemLayer != nullptr) && (tcpEndPoint != nullptr));
// Set the timer running flag to false
tcpEndPoint->mUserTimeoutTimerRunning = false;
@@ -2259,14 +2259,14 @@
// If initiating a new connection...
// OR if connected and there is data to be sent...
// THEN arrange for the kernel to alert us when the socket is ready to be written.
- if (State == kState_Connecting || (IsConnected() && mSendQueue != NULL))
+ if (State == kState_Connecting || (IsConnected() && mSendQueue != nullptr))
ioType.SetWrite();
// If listening for incoming connections and the app is ready to receive a connection...
// OR if in a state where receiving is allowed, and the app is ready to receive data...
// THEN arrange for the kernel to alert us when the socket is ready to be read.
- if ((State == kState_Listening && OnConnectionReceived != NULL) ||
- ((State == kState_Connected || State == kState_SendShutdown) && ReceiveEnabled && OnDataReceived != NULL))
+ if ((State == kState_Listening && OnConnectionReceived != nullptr) ||
+ ((State == kState_Connected || State == kState_SendShutdown) && ReceiveEnabled && OnDataReceived != nullptr))
ioType.SetRead();
return ioType;
@@ -2281,7 +2281,7 @@
// ready to be received on the socket, process the incoming connection.
if (State == kState_Listening)
{
- if (OnConnectionReceived != NULL && mPendingIO.IsReadable())
+ if (OnConnectionReceived != nullptr && mPendingIO.IsReadable())
HandleIncomingConnection();
}
@@ -2307,12 +2307,12 @@
{
// If in a state where sending is allowed, and there is data to be sent, and the socket is ready for
// writing, drive outbound data into the connection.
- if (IsConnected() && mSendQueue != NULL && mPendingIO.IsWriteable())
+ if (IsConnected() && mSendQueue != nullptr && mPendingIO.IsWriteable())
DriveSending();
// If in a state were receiving is allowed, and the app is ready to receive data, and data is ready
// on the socket, receive inbound data from the connection.
- if ((State == kState_Connected || State == kState_SendShutdown) && ReceiveEnabled && OnDataReceived != NULL &&
+ if ((State == kState_Connected || State == kState_SendShutdown) && ReceiveEnabled && OnDataReceived != nullptr &&
mPendingIO.IsReadable())
ReceiveData();
}
@@ -2327,12 +2327,12 @@
PacketBuffer * rcvBuf;
bool isNewBuf = true;
- if (mRcvQueue == NULL)
+ if (mRcvQueue == nullptr)
rcvBuf = PacketBuffer::New(0);
else
{
rcvBuf = mRcvQueue;
- for (PacketBuffer * nextBuf = rcvBuf->Next(); nextBuf != NULL; rcvBuf = nextBuf, nextBuf = nextBuf->Next())
+ for (PacketBuffer * nextBuf = rcvBuf->Next(); nextBuf != nullptr; rcvBuf = nextBuf, nextBuf = nextBuf->Next())
;
if (rcvBuf->AvailableDataLength() == 0)
@@ -2344,7 +2344,7 @@
}
}
- if (rcvBuf == NULL)
+ if (rcvBuf == nullptr)
{
DoClose(INET_ERROR_NO_MEMORY, false);
return;
@@ -2427,13 +2427,13 @@
// the app to decide whether to keep the send side of the connection open after
// the peer has closed. If no OnPeerClose is provided, we assume that the app
// wants to close both directions and automatically enter the Closing state.
- if (State == kState_Connected && OnPeerClose != NULL)
+ if (State == kState_Connected && OnPeerClose != nullptr)
State = kState_ReceiveShutdown;
else
State = kState_Closing;
// Call the app's OnPeerClose.
- if (OnPeerClose != NULL)
+ if (OnPeerClose != nullptr)
OnPeerClose(this);
}
@@ -2444,7 +2444,7 @@
size_t newDataLength = rcvBuf->DataLength() + static_cast<size_t>(rcvLen);
VerifyOrDie(CanCastTo<uint16_t>(newDataLength));
rcvBuf->SetDataLength(static_cast<uint16_t>(newDataLength));
- if (mRcvQueue == NULL)
+ if (mRcvQueue == nullptr)
mRcvQueue = rcvBuf;
else
mRcvQueue->AddToEnd(rcvBuf);
@@ -2466,7 +2466,7 @@
void TCPEndPoint::HandleIncomingConnection()
{
INET_ERROR err = INET_NO_ERROR;
- TCPEndPoint * conEP = NULL;
+ TCPEndPoint * conEP = nullptr;
IPAddress peerAddr;
uint16_t peerPort;
@@ -2485,7 +2485,7 @@
err = chip::System::MapErrorPOSIX(errno);
// If there's no callback available, fail with an error.
- if (err == INET_NO_ERROR && OnConnectionReceived == NULL)
+ if (err == INET_NO_ERROR && OnConnectionReceived == nullptr)
err = INET_ERROR_NO_CONNECTION_HANDLER;
// Extract the peer's address information.
@@ -2537,13 +2537,13 @@
{
if (conSocket != -1)
close(conSocket);
- if (conEP != NULL)
+ if (conEP != nullptr)
{
if (conEP->State == kState_Connected)
conEP->Release();
conEP->Release();
}
- if (OnAcceptError != NULL)
+ if (OnAcceptError != nullptr)
OnAcceptError(this, err);
}
}
diff --git a/src/inet/UDPEndPoint.cpp b/src/inet/UDPEndPoint.cpp
index dc9f324..c250c44 100644
--- a/src/inet/UDPEndPoint.cpp
+++ b/src/inet/UDPEndPoint.cpp
@@ -979,7 +979,7 @@
void UDPEndPoint::HandlePendingIO(void)
{
- if (mState == kState_Listening && OnMessageReceived != NULL && mPendingIO.IsReadable())
+ if (mState == kState_Listening && OnMessageReceived != nullptr && mPendingIO.IsReadable())
{
const uint16_t lPort = mBoundPort;
diff --git a/src/inet/tests/TestInetCommon.cpp b/src/inet/tests/TestInetCommon.cpp
index d4791ad..e1eac5f 100644
--- a/src/inet/tests/TestInetCommon.cpp
+++ b/src/inet/tests/TestInetCommon.cpp
@@ -153,7 +153,7 @@
{
// Set stdout to be line buffered with a buffer of 512 (will flush on new line
// or when the buffer of 512 is exceeded).
- setvbuf(stdout, NULL, _IOLBF, 512);
+ setvbuf(stdout, nullptr, _IOLBF, 512);
}
void InitTestInetCommon()
@@ -184,7 +184,7 @@
for (i = 0; i < sizeof(signals) / sizeof(signals[0]); i++)
{
- if (sigaction(signals[i], &sa, NULL) == -1)
+ if (sigaction(signals[i], &sa, nullptr) == -1)
{
perror("Can't catch signal");
exit(1);
@@ -199,7 +199,7 @@
gSystemLayer.Init(sLwIPEventQueue);
#else // !CHIP_SYSTEM_CONFIG_USE_LWIP
- gSystemLayer.Init(NULL);
+ gSystemLayer.Init(nullptr);
#endif // !CHIP_SYSTEM_CONFIG_USE_LWIP
}
@@ -265,7 +265,7 @@
void InitNetwork()
{
- void * lContext = NULL;
+ void * lContext = nullptr;
#if CHIP_SYSTEM_CONFIG_USE_LWIP
#if CHIP_SYSTEM_CONFIG_USE_SOCKETS
@@ -624,7 +624,7 @@
void DumpMemory(const uint8_t * mem, uint32_t len, const char * prefix, uint32_t rowWidth)
{
- int indexWidth = snprintf(NULL, 0, "%X", len);
+ int indexWidth = snprintf(nullptr, 0, "%X", len);
if (indexWidth < 4)
indexWidth = 4;
@@ -670,7 +670,7 @@
ExitNow();
}
- for (i = 0; sRestartCallbackCtx.mArgv[i] != NULL; i++)
+ for (i = 0; sRestartCallbackCtx.mArgv[i] != nullptr; i++)
{
if (strcmp(sRestartCallbackCtx.mArgv[i], "--faults") == 0)
{
@@ -681,9 +681,9 @@
lArgv[j++] = sRestartCallbackCtx.mArgv[i];
}
- lArgv[j] = NULL;
+ lArgv[j] = nullptr;
- for (i = 0; lArgv[i] != NULL; i++)
+ for (i = 0; lArgv[i] != nullptr; i++)
{
printf("argv[%d]: %s\n", i, lArgv[i]);
}
@@ -759,7 +759,7 @@
void SetupFaultInjectionContext(int argc, char * argv[])
{
- SetupFaultInjectionContext(argc, argv, NULL, NULL);
+ SetupFaultInjectionContext(argc, argv, nullptr, nullptr);
}
void SetupFaultInjectionContext(int argc, char * argv[], int32_t (*aNumEventsAvailable)(void),
diff --git a/src/inet/tests/TestInetEndPoint.cpp b/src/inet/tests/TestInetEndPoint.cpp
index f7edb7b..81c536d 100644
--- a/src/inet/tests/TestInetEndPoint.cpp
+++ b/src/inet/tests/TestInetEndPoint.cpp
@@ -82,13 +82,13 @@
static void TestInetPre(nlTestSuite * inSuite, void * inContext)
{
#if INET_CONFIG_ENABLE_RAW_ENDPOINT
- RawEndPoint * testRawEP = NULL;
+ RawEndPoint * testRawEP = nullptr;
#endif // INET_CONFIG_ENABLE_RAW_ENDPOINT
#if INET_CONFIG_ENABLE_UDP_ENDPOINT
- UDPEndPoint * testUDPEP = NULL;
+ UDPEndPoint * testUDPEP = nullptr;
#endif // INET_CONFIG_ENABLE_UDP_ENDPOINT
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
- TCPEndPoint * testTCPEP = NULL;
+ TCPEndPoint * testTCPEP = nullptr;
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
INET_ERROR err = INET_NO_ERROR;
IPAddress testDestAddr = IPAddress::Any;
@@ -109,11 +109,11 @@
NL_TEST_ASSERT(inSuite, err == INET_ERROR_INCORRECT_STATE);
#endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
- err = gSystemLayer.StartTimer(10, HandleTimer, NULL);
+ err = gSystemLayer.StartTimer(10, HandleTimer, nullptr);
NL_TEST_ASSERT(inSuite, err == CHIP_SYSTEM_ERROR_UNEXPECTED_STATE);
#if INET_CONFIG_ENABLE_DNS_RESOLVER
- err = gInet.ResolveHostAddress(testHostName, 1, &testDestAddr, HandleDNSResolveComplete, NULL);
+ err = gInet.ResolveHostAddress(testHostName, 1, &testDestAddr, HandleDNSResolveComplete, nullptr);
NL_TEST_ASSERT(inSuite, err == INET_ERROR_INCORRECT_STATE);
#endif // INET_CONFIG_ENABLE_DNS_RESOLVER
@@ -242,7 +242,7 @@
err = gInet.GetInterfaceFromAddr(addr, intId);
NL_TEST_ASSERT(inSuite, intId == INET_NULL_INTERFACEID);
- err = gInet.GetLinkLocalAddr(intId, NULL);
+ err = gInet.GetLinkLocalAddr(intId, nullptr);
NL_TEST_ASSERT(inSuite, err == INET_ERROR_BAD_ARGS);
printf(" Interfaces:\n");
@@ -278,7 +278,7 @@
memset(intName, 42, sizeof(intName));
err = addrIterator.GetInterfaceName(intName, sizeof(intName));
NL_TEST_ASSERT(inSuite, err == INET_NO_ERROR);
- NL_TEST_ASSERT(inSuite, intName[0] != '\0' && memchr(intName, '\0', sizeof(intName)) != NULL);
+ NL_TEST_ASSERT(inSuite, intName[0] != '\0' && memchr(intName, '\0', sizeof(intName)) != nullptr);
printf(" %s/%d, interface id: 0x%" PRIxPTR
", interface name: %s, interface state: %s, %s multicast, %s broadcast addr\n",
addrStr, addrWithPrefix.Length, (uintptr_t)(intId), intName, addrIterator.IsUp() ? "UP" : "DOWN",
@@ -304,12 +304,12 @@
InterfaceId intId;
// EndPoint
- RawEndPoint * testRaw6EP = NULL;
+ RawEndPoint * testRaw6EP = nullptr;
#if INET_CONFIG_ENABLE_IPV4
- RawEndPoint * testRaw4EP = NULL;
+ RawEndPoint * testRaw4EP = nullptr;
#endif // INET_CONFIG_ENABLE_IPV4
- UDPEndPoint * testUDPEP = NULL;
- TCPEndPoint * testTCPEP1 = NULL;
+ UDPEndPoint * testUDPEP = nullptr;
+ TCPEndPoint * testTCPEP1 = nullptr;
PacketBuffer * buf = PacketBuffer::New();
bool didBind = false;
bool didListen = false;
@@ -436,7 +436,7 @@
#endif // INET_CONFIG_ENABLE_IPV4
// TcpEndPoint special cases to cover the error branch
- err = testTCPEP1->GetPeerInfo(NULL, NULL);
+ err = testTCPEP1->GetPeerInfo(nullptr, nullptr);
NL_TEST_ASSERT(inSuite, err == INET_ERROR_INCORRECT_STATE);
buf = PacketBuffer::New();
err = testTCPEP1->Send(buf, false);
@@ -450,7 +450,7 @@
NL_TEST_ASSERT(inSuite, !testTCPEP1->PendingReceiveLength());
err = testTCPEP1->Listen(4);
NL_TEST_ASSERT(inSuite, err == INET_ERROR_INCORRECT_STATE);
- err = testTCPEP1->GetLocalInfo(NULL, NULL);
+ err = testTCPEP1->GetLocalInfo(nullptr, nullptr);
NL_TEST_ASSERT(inSuite, err == INET_ERROR_INCORRECT_STATE);
err = testTCPEP1->Bind(kIPAddressType_Unknown, addr_any, 3000, true);
@@ -477,9 +477,9 @@
// Test the InetLayer resource limitation
static void TestInetEndPointLimit(nlTestSuite * inSuite, void * inContext)
{
- RawEndPoint * testRawEP = NULL;
- UDPEndPoint * testUDPEP = NULL;
- TCPEndPoint * testTCPEP = NULL;
+ RawEndPoint * testRawEP = nullptr;
+ UDPEndPoint * testUDPEP = nullptr;
+ TCPEndPoint * testTCPEP = nullptr;
INET_ERROR err;
char numTimersTest[CHIP_SYSTEM_CONFIG_NUM_TIMERS + 1];
@@ -498,7 +498,7 @@
// Verify same aComplete and aAppState args do not exhaust timer pool
for (int i = 0; i < CHIP_SYSTEM_CONFIG_NUM_TIMERS + 1; i++)
{
- err = gSystemLayer.StartTimer(10, HandleTimer, NULL);
+ err = gSystemLayer.StartTimer(10, HandleTimer, nullptr);
NL_TEST_ASSERT(inSuite, err == CHIP_SYSTEM_NO_ERROR);
}
@@ -561,7 +561,7 @@
// clang-format on
// Run test suite against one context.
- nlTestRunner(&theSuite, NULL);
+ nlTestRunner(&theSuite, nullptr);
return nlTestRunnerStats(&theSuite);
#else // !CHIP_SYSTEM_CONFIG_USE_SOCKETS
diff --git a/src/inet/tests/TestInetErrorStr.cpp b/src/inet/tests/TestInetErrorStr.cpp
index d2b30b3..ca71e10 100644
--- a/src/inet/tests/TestInetErrorStr.cpp
+++ b/src/inet/tests/TestInetErrorStr.cpp
@@ -100,12 +100,12 @@
// Assert that the error string contains the error number in hex.
snprintf(expectedText, sizeof(expectedText), "%08" PRIX32, err);
- NL_TEST_ASSERT(inSuite, (strstr(errStr, expectedText) != NULL));
+ NL_TEST_ASSERT(inSuite, (strstr(errStr, expectedText) != nullptr));
#if !CHIP_CONFIG_SHORT_ERROR_STR
// Assert that the error string contains a description, which is signaled
// by a presence of a colon proceeding the description.
- NL_TEST_ASSERT(inSuite, (strchr(errStr, ':') != NULL));
+ NL_TEST_ASSERT(inSuite, (strchr(errStr, ':') != nullptr));
#endif // !CHIP_CONFIG_SHORT_ERROR_STR
}
}
@@ -130,8 +130,8 @@
{
"Inet-Error-Strings",
&sTests[0],
- NULL,
- NULL
+ nullptr,
+ nullptr
};
// clang-format on
diff --git a/src/inet/tests/TestInetLayer.cpp b/src/inet/tests/TestInetLayer.cpp
index 7186976..46cfce7 100644
--- a/src/inet/tests/TestInetLayer.cpp
+++ b/src/inet/tests/TestInetLayer.cpp
@@ -90,10 +90,10 @@
static const uint32_t kOptFlagsDefault = (kOptFlagUseIPv6 | kOptFlagUseUDPIP);
-static RawEndPoint * sRawIPEndPoint = NULL;
-static TCPEndPoint * sTCPIPEndPoint = NULL; // Used for connect/send/receive
-static TCPEndPoint * sTCPIPListenEndPoint = NULL; // Used for accept/listen
-static UDPEndPoint * sUDPIPEndPoint = NULL;
+static RawEndPoint * sRawIPEndPoint = nullptr;
+static TCPEndPoint * sTCPIPEndPoint = nullptr; // Used for connect/send/receive
+static TCPEndPoint * sTCPIPListenEndPoint = nullptr; // Used for accept/listen
+static UDPEndPoint * sUDPIPEndPoint = nullptr;
static const uint16_t kTCPPort = kUDPPort;
// clang-format off
@@ -105,7 +105,7 @@
// clang-format on
static IPAddress sDestinationAddress = IPAddress::Any;
-static const char * sDestinationString = NULL;
+static const char * sDestinationString = nullptr;
// clang-format off
static OptionDef sToolOptionDefs[] =
@@ -184,7 +184,7 @@
&gNetworkOptions,
&gFaultInjectionOptions,
&sHelpOptions,
- NULL
+ nullptr
};
// clang-format on
@@ -247,7 +247,7 @@
goto exit;
}
- if (!ParseArgsFromEnvVar(kToolName, TOOL_OPTIONS_ENV_VAR_NAME, sToolOptionSets, NULL, true) ||
+ if (!ParseArgsFromEnvVar(kToolName, TOOL_OPTIONS_ENV_VAR_NAME, sToolOptionSets, nullptr, true) ||
!ParseArgs(kToolName, argc, argv, sToolOptionSets, HandleNonOptionArgs))
{
lSuccessful = false;
@@ -262,7 +262,7 @@
// including LwIP TUN/TAP shim interfaces. Validate the
// -I/--interface argument, if present.
- if (gInterfaceName != NULL)
+ if (gInterfaceName != nullptr)
{
lStatus = InterfaceNameToId(gInterfaceName, gInterfaceId);
if (lStatus != INET_NO_ERROR)
@@ -544,7 +544,7 @@
printf("TCP connection established to %s:%u\n", lPeerAddressBuffer, lPeerPort);
if (sTCPIPEndPoint->PendingReceiveLength() == 0)
- sTCPIPEndPoint->PutBackReceivedData(NULL);
+ sTCPIPEndPoint->PutBackReceivedData(nullptr);
sTCPIPEndPoint->DisableReceive();
sTCPIPEndPoint->EnableKeepAlive(10, 100);
@@ -558,11 +558,11 @@
printf("TCP connection FAILED: %s\n", ErrorStr(aError));
aEndPoint->Free();
- aEndPoint = NULL;
+ aEndPoint = nullptr;
gSendIntervalExpired = false;
- gSystemLayer.CancelTimer(Common::HandleSendTimerComplete, NULL);
- gSystemLayer.StartTimer(gSendIntervalMs, Common::HandleSendTimerComplete, NULL);
+ gSystemLayer.CancelTimer(Common::HandleSendTimerComplete, nullptr);
+ gSystemLayer.StartTimer(gSendIntervalMs, Common::HandleSendTimerComplete, nullptr);
SetStatusFailed(sTestState.mStatus);
}
@@ -585,7 +585,7 @@
if (aEndPoint == sTCPIPEndPoint)
{
- sTCPIPEndPoint = NULL;
+ sTCPIPEndPoint = nullptr;
}
}
@@ -608,13 +608,13 @@
// Check that we did not lose information in our narrowing cast.
VerifyOrExit(lFirstValue == lFirstValueReceived, lStatus = INET_ERROR_UNEXPECTED_EVENT);
- VerifyOrExit(aEndPoint != NULL, lStatus = INET_ERROR_BAD_ARGS);
- VerifyOrExit(aBuffer != NULL, lStatus = INET_ERROR_BAD_ARGS);
+ VerifyOrExit(aEndPoint != nullptr, lStatus = INET_ERROR_BAD_ARGS);
+ VerifyOrExit(aBuffer != nullptr, lStatus = INET_ERROR_BAD_ARGS);
if (aEndPoint->State != TCPEndPoint::kState_Connected)
{
lStatus = aEndPoint->PutBackReceivedData(aBuffer);
- aBuffer = NULL;
+ aBuffer = nullptr;
INET_FAIL_ERROR(lStatus, "TCPEndPoint::PutBackReceivedData failed");
goto exit;
}
@@ -634,7 +634,7 @@
INET_FAIL_ERROR(lStatus, "TCPEndPoint::AckReceive failed");
exit:
- if (aBuffer != NULL)
+ if (aBuffer != nullptr)
{
PacketBuffer::Free(aBuffer);
}
@@ -678,9 +678,9 @@
IPAddressType lAddressType;
bool lStatus;
- VerifyOrExit(aEndPoint != NULL, lStatus = false);
- VerifyOrExit(aBuffer != NULL, lStatus = false);
- VerifyOrExit(aPacketInfo != NULL, lStatus = false);
+ VerifyOrExit(aEndPoint != nullptr, lStatus = false);
+ VerifyOrExit(aBuffer != nullptr, lStatus = false);
+ VerifyOrExit(aPacketInfo != nullptr, lStatus = false);
Common::HandleRawMessageReceived(aEndPoint, aBuffer, aPacketInfo);
@@ -709,7 +709,7 @@
}
exit:
- if (aBuffer != NULL)
+ if (aBuffer != nullptr)
{
PacketBuffer::Free(aBuffer);
}
@@ -734,16 +734,16 @@
const bool lCheckBuffer = true;
bool lStatus;
- VerifyOrExit(aEndPoint != NULL, lStatus = false);
- VerifyOrExit(aBuffer != NULL, lStatus = false);
- VerifyOrExit(aPacketInfo != NULL, lStatus = false);
+ VerifyOrExit(aEndPoint != nullptr, lStatus = false);
+ VerifyOrExit(aBuffer != nullptr, lStatus = false);
+ VerifyOrExit(aPacketInfo != nullptr, lStatus = false);
Common::HandleUDPMessageReceived(aEndPoint, aBuffer, aPacketInfo);
lStatus = HandleDataReceived(aBuffer, lCheckBuffer);
exit:
- if (aBuffer != NULL)
+ if (aBuffer != nullptr)
{
PacketBuffer::Free(aBuffer);
}
@@ -767,15 +767,15 @@
if ((gOptFlags & (kOptFlagUseRawIP)) == (kOptFlagUseRawIP))
{
- lStatus = (sRawIPEndPoint != NULL);
+ lStatus = (sRawIPEndPoint != nullptr);
}
else if ((gOptFlags & kOptFlagUseUDPIP) == kOptFlagUseUDPIP)
{
- lStatus = (sUDPIPEndPoint != NULL);
+ lStatus = (sUDPIPEndPoint != nullptr);
}
else if ((gOptFlags & kOptFlagUseTCPIP) == kOptFlagUseTCPIP)
{
- if (sTCPIPEndPoint != NULL)
+ if (sTCPIPEndPoint != nullptr)
{
if (sTCPIPEndPoint->PendingSendLength() == 0)
{
@@ -802,7 +802,7 @@
if (gOptFlags & kOptFlagUseTCPIP)
{
- if (sTCPIPEndPoint == NULL)
+ if (sTCPIPEndPoint == nullptr)
{
lStatus = gInet.NewTCPEndPoint(&sTCPIPEndPoint);
INET_FAIL_ERROR(lStatus, "InetLayer::NewTCPEndPoint failed");
@@ -822,7 +822,7 @@
static INET_ERROR DriveSendForDestination(const IPAddress & aAddress, uint16_t aSize)
{
- PacketBuffer * lBuffer = NULL;
+ PacketBuffer * lBuffer = nullptr;
INET_ERROR lStatus = INET_NO_ERROR;
if ((gOptFlags & (kOptFlagUseRawIP)) == (kOptFlagUseRawIP))
@@ -835,13 +835,13 @@
if ((gOptFlags & kOptFlagUseIPv6) == (kOptFlagUseIPv6))
{
lBuffer = Common::MakeICMPv6DataBuffer(aSize);
- VerifyOrExit(lBuffer != NULL, lStatus = INET_ERROR_NO_MEMORY);
+ VerifyOrExit(lBuffer != nullptr, lStatus = INET_ERROR_NO_MEMORY);
}
#if INET_CONFIG_ENABLE_IPV4
else if ((gOptFlags & kOptFlagUseIPv4) == (kOptFlagUseIPv4))
{
lBuffer = Common::MakeICMPv4DataBuffer(aSize);
- VerifyOrExit(lBuffer != NULL, lStatus = INET_ERROR_NO_MEMORY);
+ VerifyOrExit(lBuffer != nullptr, lStatus = INET_ERROR_NO_MEMORY);
}
#endif // INET_CONFIG_ENABLE_IPV4
@@ -858,7 +858,7 @@
// patterned from zero to aSize - 1.
lBuffer = Common::MakeDataBuffer(aSize, lFirstValue);
- VerifyOrExit(lBuffer != NULL, lStatus = INET_ERROR_NO_MEMORY);
+ VerifyOrExit(lBuffer != nullptr, lStatus = INET_ERROR_NO_MEMORY);
lStatus = sUDPIPEndPoint->SendTo(aAddress, kUDPPort, lBuffer);
SuccessOrExit(lStatus);
@@ -874,7 +874,7 @@
// sTestState.mStats.mTransmit.mExpected - 1.
lBuffer = Common::MakeDataBuffer(aSize, uint8_t(lFirstValue));
- VerifyOrExit(lBuffer != NULL, lStatus = INET_ERROR_NO_MEMORY);
+ VerifyOrExit(lBuffer != nullptr, lStatus = INET_ERROR_NO_MEMORY);
lStatus = sTCPIPEndPoint->Send(lBuffer);
SuccessOrExit(lStatus);
@@ -903,7 +903,7 @@
else
{
gSendIntervalExpired = false;
- gSystemLayer.StartTimer(gSendIntervalMs, Common::HandleSendTimerComplete, NULL);
+ gSystemLayer.StartTimer(gSendIntervalMs, Common::HandleSendTimerComplete, nullptr);
if (sTestState.mStats.mTransmit.mActual < sTestState.mStats.mTransmit.mExpected)
{
@@ -1049,16 +1049,16 @@
INET_ERROR lStatus;
gSendIntervalExpired = false;
- gSystemLayer.CancelTimer(Common::HandleSendTimerComplete, NULL);
+ gSystemLayer.CancelTimer(Common::HandleSendTimerComplete, nullptr);
// Release the resources associated with the allocated end points.
- if (sRawIPEndPoint != NULL)
+ if (sRawIPEndPoint != nullptr)
{
sRawIPEndPoint->Free();
}
- if (sTCPIPEndPoint != NULL)
+ if (sTCPIPEndPoint != nullptr)
{
lStatus = sTCPIPEndPoint->Close();
INET_FAIL_ERROR(lStatus, "TCPEndPoint::Close failed");
@@ -1066,13 +1066,13 @@
sTCPIPEndPoint->Free();
}
- if (sTCPIPListenEndPoint != NULL)
+ if (sTCPIPListenEndPoint != nullptr)
{
sTCPIPListenEndPoint->Shutdown();
sTCPIPListenEndPoint->Free();
}
- if (sUDPIPEndPoint != NULL)
+ if (sUDPIPEndPoint != nullptr)
{
sUDPIPEndPoint->Free();
}
diff --git a/src/inet/tests/TestInetLayerCommon.cpp b/src/inet/tests/TestInetLayerCommon.cpp
index 452b778..b32a489 100644
--- a/src/inet/tests/TestInetLayerCommon.cpp
+++ b/src/inet/tests/TestInetLayerCommon.cpp
@@ -82,7 +82,7 @@
uint32_t gSendIntervalMs = 1000;
-const char * gInterfaceName = NULL;
+const char * gInterfaceName = nullptr;
InterfaceId gInterfaceId = INET_NULL_INTERFACEID;
@@ -164,12 +164,12 @@
static PacketBuffer * MakeDataBuffer(uint16_t aDesiredLength, uint16_t aPatternStartOffset, uint8_t aFirstValue)
{
- PacketBuffer * lBuffer = NULL;
+ PacketBuffer * lBuffer = nullptr;
VerifyOrExit(aPatternStartOffset <= aDesiredLength, );
lBuffer = PacketBuffer::New();
- VerifyOrExit(lBuffer != NULL, );
+ VerifyOrExit(lBuffer != nullptr, );
aDesiredLength = min(lBuffer->MaxDataLength(), aDesiredLength);
@@ -184,10 +184,10 @@
static PacketBuffer * MakeDataBuffer(uint16_t aDesiredLength, uint16_t aPatternStartOffset)
{
const uint8_t lFirstValue = 0;
- PacketBuffer * lBuffer = NULL;
+ PacketBuffer * lBuffer = nullptr;
lBuffer = MakeDataBuffer(aDesiredLength, aPatternStartOffset, lFirstValue);
- VerifyOrExit(lBuffer != NULL, );
+ VerifyOrExit(lBuffer != nullptr, );
exit:
return (lBuffer);
@@ -198,14 +198,14 @@
uint8_t aType)
{
static uint16_t lSequenceNumber = 0;
- PacketBuffer * lBuffer = NULL;
+ PacketBuffer * lBuffer = nullptr;
// To ensure there is enough room for the user data and the ICMP
// header, include both the user data size and the ICMP header length.
lBuffer = MakeDataBuffer(aDesiredUserLength + aHeaderLength, aPatternStartOffset);
- if (lBuffer != NULL)
+ if (lBuffer != nullptr)
{
tType * lHeader = reinterpret_cast<tType *>(lBuffer->Start());
@@ -224,7 +224,7 @@
const uint16_t lICMPHeaderLength = sizeof(ICMPv4EchoHeader);
const uint16_t lPatternStartOffset = lICMPHeaderLength;
const uint8_t lType = gICMPv4Types[kICMP_EchoRequestIndex];
- PacketBuffer * lBuffer = NULL;
+ PacketBuffer * lBuffer = nullptr;
lBuffer = MakeICMPDataBuffer<ICMPv4EchoHeader>(aDesiredUserLength, lICMPHeaderLength, lPatternStartOffset, lType);
@@ -236,7 +236,7 @@
const uint16_t lICMPHeaderLength = sizeof(ICMPv6EchoHeader);
const uint16_t lPatternStartOffset = lICMPHeaderLength;
const uint8_t lType = gICMPv6Types[kICMP_EchoRequestIndex];
- PacketBuffer * lBuffer = NULL;
+ PacketBuffer * lBuffer = nullptr;
lBuffer = MakeICMPDataBuffer<ICMPv6EchoHeader>(aDesiredUserLength, lICMPHeaderLength, lPatternStartOffset, lType);
@@ -246,7 +246,7 @@
PacketBuffer * MakeDataBuffer(uint16_t aDesiredLength, uint8_t aFirstValue)
{
const uint16_t lPatternStartOffset = 0;
- PacketBuffer * lBuffer = NULL;
+ PacketBuffer * lBuffer = nullptr;
lBuffer = MakeDataBuffer(aDesiredLength, lPatternStartOffset, aFirstValue);
@@ -256,7 +256,7 @@
PacketBuffer * MakeDataBuffer(uint16_t aDesiredLength)
{
const uint16_t lPatternStartOffset = 0;
- PacketBuffer * lBuffer = NULL;
+ PacketBuffer * lBuffer = nullptr;
lBuffer = MakeDataBuffer(aDesiredLength, lPatternStartOffset);
@@ -272,7 +272,7 @@
// Walk through each buffer in the packet chain, checking the
// buffer for the expected pattern, if requested.
- for (const PacketBuffer * lBuffer = aBuffer; lBuffer != NULL; lBuffer = lBuffer->Next())
+ for (const PacketBuffer * lBuffer = aBuffer; lBuffer != nullptr; lBuffer = lBuffer->Next())
{
const uint16_t lDataLength = lBuffer->DataLength();
@@ -399,7 +399,7 @@
{
char lAddressBuffer[INET6_ADDRSTRLEN];
- if (aPacketInfo != NULL)
+ if (aPacketInfo != nullptr)
{
aPacketInfo->SrcAddress.ToString(lAddressBuffer, sizeof(lAddressBuffer));
}
@@ -430,7 +430,7 @@
char lAddressBuffer[INET6_ADDRSTRLEN];
uint16_t lSourcePort;
- if (aPacketInfo != NULL)
+ if (aPacketInfo != nullptr)
{
aPacketInfo->SrcAddress.ToString(lAddressBuffer, sizeof(lAddressBuffer));
lSourcePort = aPacketInfo->SrcPort;
diff --git a/src/inet/tests/TestInetLayerDNS.cpp b/src/inet/tests/TestInetLayerDNS.cpp
index 5daccf6..1e7620b 100644
--- a/src/inet/tests/TestInetLayerDNS.cpp
+++ b/src/inet/tests/TestInetLayerDNS.cpp
@@ -685,8 +685,8 @@
{
"DNS",
&DNSTests[0],
- NULL,
- NULL
+ nullptr,
+ nullptr
};
// clang-format on
@@ -697,7 +697,7 @@
// Run all tests in Suite
- nlTestRunner(&DNSTestSuite, NULL);
+ nlTestRunner(&DNSTestSuite, nullptr);
ShutdownNetwork();
ShutdownSystemLayer();
diff --git a/src/inet/tests/TestInetLayerMulticast.cpp b/src/inet/tests/TestInetLayerMulticast.cpp
index 35dc251..fce26d3 100644
--- a/src/inet/tests/TestInetLayerMulticast.cpp
+++ b/src/inet/tests/TestInetLayerMulticast.cpp
@@ -106,8 +106,8 @@
// clang-format off
static const uint32_t kOptFlagsDefault = (kOptFlagUseIPv6 | kOptFlagUseRawIP);
-static RawEndPoint * sRawIPEndPoint = NULL;
-static UDPEndPoint * sUDPIPEndPoint = NULL;
+static RawEndPoint * sRawIPEndPoint = nullptr;
+static UDPEndPoint * sUDPIPEndPoint = nullptr;
static GroupAddresses<4> sGroupAddresses;
@@ -198,7 +198,7 @@
&gNetworkOptions,
&gFaultInjectionOptions,
&sHelpOptions,
- NULL
+ nullptr
};
// clang-format on
@@ -272,7 +272,7 @@
goto exit;
}
- if (!ParseArgsFromEnvVar(kToolName, TOOL_OPTIONS_ENV_VAR_NAME, sToolOptionSets, NULL, true) ||
+ if (!ParseArgsFromEnvVar(kToolName, TOOL_OPTIONS_ENV_VAR_NAME, sToolOptionSets, nullptr, true) ||
!ParseArgs(kToolName, argc, argv, sToolOptionSets, HandleNonOptionArgs))
{
lSuccessful = false;
@@ -287,7 +287,7 @@
// including LwIP TUN/TAP shim interfaces. Validate the
// -I/--interface argument, if present.
- if (gInterfaceName != NULL)
+ if (gInterfaceName != nullptr)
{
lStatus = InterfaceNameToId(gInterfaceName, gInterfaceId);
if (lStatus != INET_NO_ERROR)
@@ -573,7 +573,7 @@
static GroupAddress * FindGroupAddress(const IPAddress & aSourceAddress)
{
- GroupAddress * lResult = NULL;
+ GroupAddress * lResult = nullptr;
for (size_t i = 0; i < sGroupAddresses.mSize; i++)
{
@@ -616,7 +616,7 @@
lGroupAddress = FindGroupAddress(aPacketInfo.DestAddress);
- if (lGroupAddress != NULL)
+ if (lGroupAddress != nullptr)
{
lStatus = HandleDataReceived(aBuffer, *lGroupAddress, aCheckBuffer);
VerifyOrExit(lStatus == true, );
@@ -636,15 +636,15 @@
bool lStatus = true;
GroupAddress * lGroupAddress;
- VerifyOrExit(aEndPoint != NULL, lStatus = false);
- VerifyOrExit(aBuffer != NULL, lStatus = false);
- VerifyOrExit(aPacketInfo != NULL, lStatus = false);
+ VerifyOrExit(aEndPoint != nullptr, lStatus = false);
+ VerifyOrExit(aBuffer != nullptr, lStatus = false);
+ VerifyOrExit(aPacketInfo != nullptr, lStatus = false);
Common::HandleRawMessageReceived(aEndPoint, aBuffer, aPacketInfo);
lGroupAddress = FindGroupAddress(aPacketInfo->DestAddress);
- if (lGroupAddress != NULL)
+ if (lGroupAddress != nullptr)
{
lAddressType = aPacketInfo->DestAddress.Type();
@@ -672,7 +672,7 @@
}
exit:
- if (aBuffer != NULL)
+ if (aBuffer != nullptr)
{
PacketBuffer::Free(aBuffer);
}
@@ -697,16 +697,16 @@
const bool lCheckBuffer = true;
bool lStatus;
- VerifyOrExit(aEndPoint != NULL, lStatus = false);
- VerifyOrExit(aBuffer != NULL, lStatus = false);
- VerifyOrExit(aPacketInfo != NULL, lStatus = false);
+ VerifyOrExit(aEndPoint != nullptr, lStatus = false);
+ VerifyOrExit(aBuffer != nullptr, lStatus = false);
+ VerifyOrExit(aPacketInfo != nullptr, lStatus = false);
Common::HandleUDPMessageReceived(aEndPoint, aBuffer, aPacketInfo);
lStatus = HandleDataReceived(aBuffer, *aPacketInfo, lCheckBuffer);
exit:
- if (aBuffer != NULL)
+ if (aBuffer != nullptr)
{
PacketBuffer::Free(aBuffer);
}
@@ -730,11 +730,11 @@
if ((gOptFlags & (kOptFlagUseRawIP)) == (kOptFlagUseRawIP))
{
- lStatus = (sRawIPEndPoint != NULL);
+ lStatus = (sRawIPEndPoint != nullptr);
}
else if ((gOptFlags & kOptFlagUseUDPIP) == kOptFlagUseUDPIP)
{
- lStatus = (sUDPIPEndPoint != NULL);
+ lStatus = (sUDPIPEndPoint != nullptr);
}
return (lStatus);
@@ -749,7 +749,7 @@
static INET_ERROR DriveSendForDestination(const IPAddress & aAddress, uint16_t aSize)
{
- PacketBuffer * lBuffer = NULL;
+ PacketBuffer * lBuffer = nullptr;
INET_ERROR lStatus = INET_NO_ERROR;
if ((gOptFlags & (kOptFlagUseRawIP)) == (kOptFlagUseRawIP))
@@ -762,13 +762,13 @@
if ((gOptFlags & kOptFlagUseIPv6) == (kOptFlagUseIPv6))
{
lBuffer = Common::MakeICMPv6DataBuffer(aSize);
- VerifyOrExit(lBuffer != NULL, lStatus = INET_ERROR_NO_MEMORY);
+ VerifyOrExit(lBuffer != nullptr, lStatus = INET_ERROR_NO_MEMORY);
}
#if INET_CONFIG_ENABLE_IPV4
else if ((gOptFlags & kOptFlagUseIPv4) == (kOptFlagUseIPv4))
{
lBuffer = Common::MakeICMPv4DataBuffer(aSize);
- VerifyOrExit(lBuffer != NULL, lStatus = INET_ERROR_NO_MEMORY);
+ VerifyOrExit(lBuffer != nullptr, lStatus = INET_ERROR_NO_MEMORY);
}
#endif // INET_CONFIG_ENABLE_IPV4
@@ -785,7 +785,7 @@
// patterned from zero to aSize - 1.
lBuffer = Common::MakeDataBuffer(aSize, lFirstValue);
- VerifyOrExit(lBuffer != NULL, lStatus = INET_ERROR_NO_MEMORY);
+ VerifyOrExit(lBuffer != nullptr, lStatus = INET_ERROR_NO_MEMORY);
lStatus = sUDPIPEndPoint->SendTo(aAddress, kUDPPort, lBuffer);
SuccessOrExit(lStatus);
@@ -853,7 +853,7 @@
else
{
gSendIntervalExpired = false;
- gSystemLayer.StartTimer(gSendIntervalMs, Common::HandleSendTimerComplete, NULL);
+ gSystemLayer.StartTimer(gSendIntervalMs, Common::HandleSendTimerComplete, nullptr);
lStatus = DriveSendForGroups(sGroupAddresses);
SuccessOrExit(lStatus);
@@ -874,7 +874,7 @@
IPProtocol lIPProtocol = kIPProtocol_ICMPv6;
IPVersion lIPVersion = kIPVersion_6;
IPAddress lAddress = IPAddress::Any;
- IPEndPointBasis * lEndPoint = NULL;
+ IPEndPointBasis * lEndPoint = nullptr;
const bool lUseLoopback = ((gOptFlags & kOptFlagNoLoopback) == 0);
INET_ERROR lStatus;
@@ -962,7 +962,7 @@
GroupAddress & lGroupAddress = sGroupAddresses.mAddresses[i];
IPAddress & lMulticastAddress = lGroupAddress.mMulticastAddress;
- if ((lEndPoint != NULL) && IsInterfaceIdPresent(gInterfaceId))
+ if ((lEndPoint != nullptr) && IsInterfaceIdPresent(gInterfaceId))
{
if (gOptFlags & kOptFlagUseIPv4)
{
@@ -990,11 +990,11 @@
static void CleanupTest(void)
{
- IPEndPointBasis * lEndPoint = NULL;
+ IPEndPointBasis * lEndPoint = nullptr;
INET_ERROR lStatus;
gSendIntervalExpired = false;
- gSystemLayer.CancelTimer(Common::HandleSendTimerComplete, NULL);
+ gSystemLayer.CancelTimer(Common::HandleSendTimerComplete, nullptr);
// Leave the multicast groups
@@ -1013,7 +1013,7 @@
GroupAddress & lGroupAddress = sGroupAddresses.mAddresses[i];
IPAddress & lMulticastAddress = lGroupAddress.mMulticastAddress;
- if ((lEndPoint != NULL) && IsInterfaceIdPresent(gInterfaceId))
+ if ((lEndPoint != nullptr) && IsInterfaceIdPresent(gInterfaceId))
{
lMulticastAddress.ToString(lAddressBuffer, sizeof(lAddressBuffer));
@@ -1026,12 +1026,12 @@
// Release the resources associated with the allocated end points.
- if (sRawIPEndPoint != NULL)
+ if (sRawIPEndPoint != nullptr)
{
sRawIPEndPoint->Free();
}
- if (sUDPIPEndPoint != NULL)
+ if (sUDPIPEndPoint != nullptr)
{
sUDPIPEndPoint->Free();
}
diff --git a/src/inet/tests/TestLwIPDNS.cpp b/src/inet/tests/TestLwIPDNS.cpp
index 7ed0b30..d1bd127 100644
--- a/src/inet/tests/TestLwIPDNS.cpp
+++ b/src/inet/tests/TestLwIPDNS.cpp
@@ -56,8 +56,8 @@
static ip_addr_t sIpAddrs[DNS_MAX_ADDRS_PER_NAME];
#endif // INET_LWIP
-static const char * sHostname = NULL;
-static const char * sDNSServerAddr = NULL;
+static const char * sHostname = nullptr;
+static const char * sDNSServerAddr = nullptr;
// clang-format off
static ArgParser::HelpOptions gHelpOptions(TOOL_NAME,
@@ -69,7 +69,7 @@
&gNetworkOptions,
&gFaultInjectionOptions,
&gHelpOptions,
- NULL
+ nullptr
};
// clang-format on