diff --git a/src/core/api/backbone_router_api.cpp b/src/core/api/backbone_router_api.cpp index 179249a0c..cedb3785b 100644 --- a/src/core/api/backbone_router_api.cpp +++ b/src/core/api/backbone_router_api.cpp @@ -44,7 +44,7 @@ using namespace ot; otError otBackboneRouterGetPrimary(otInstance *aInstance, otBackboneRouterConfig *aConfig) { - OT_ASSERT(aConfig != nullptr); + AssertPointerIsNotNull(aConfig); return AsCoreType(aInstance).Get().GetConfig(*aConfig); } diff --git a/src/core/api/backbone_router_ftd_api.cpp b/src/core/api/backbone_router_ftd_api.cpp index d8e516905..37c4065ea 100644 --- a/src/core/api/backbone_router_ftd_api.cpp +++ b/src/core/api/backbone_router_ftd_api.cpp @@ -55,14 +55,14 @@ otBackboneRouterState otBackboneRouterGetState(otInstance *aInstance) void otBackboneRouterGetConfig(otInstance *aInstance, otBackboneRouterConfig *aConfig) { - OT_ASSERT(aConfig != nullptr); + AssertPointerIsNotNull(aConfig); AsCoreType(aInstance).Get().GetConfig(*aConfig); } otError otBackboneRouterSetConfig(otInstance *aInstance, const otBackboneRouterConfig *aConfig) { - OT_ASSERT(aConfig != nullptr); + AssertPointerIsNotNull(aConfig); return AsCoreType(aInstance).Get().SetConfig(*aConfig); } @@ -84,8 +84,6 @@ void otBackboneRouterSetRegistrationJitter(otInstance *aInstance, uint8_t aJitte otError otBackboneRouterGetDomainPrefix(otInstance *aInstance, otBorderRouterConfig *aConfig) { - OT_ASSERT(aConfig != nullptr); - return AsCoreType(aInstance).Get().GetDomainPrefix(AsCoreType(aConfig)); } @@ -108,6 +106,8 @@ otError otBackboneRouterGetNdProxyInfo(otInstance * aInstance, const otIp6Address * aDua, otBackboneRouterNdProxyInfo *aNdProxyInfo) { + AssertPointerIsNotNull(aNdProxyInfo); + return AsCoreType(aInstance).Get().GetInfo( reinterpret_cast(*aDua), *aNdProxyInfo); } @@ -125,8 +125,8 @@ otError otBackboneRouterMulticastListenerGetNext(otInstance * otChildIp6AddressIterator * aIterator, otBackboneRouterMulticastListenerInfo *aListenerInfo) { - OT_ASSERT(aIterator != nullptr); - OT_ASSERT(aListenerInfo != nullptr); + AssertPointerIsNotNull(aIterator); + AssertPointerIsNotNull(aListenerInfo); return AsCoreType(aInstance).Get().GetNext(*aIterator, *aListenerInfo); } @@ -159,8 +159,6 @@ void otBackboneRouterMulticastListenerClear(otInstance *aInstance) otError otBackboneRouterMulticastListenerAdd(otInstance *aInstance, const otIp6Address *aAddress, uint32_t aTimeout) { - OT_ASSERT(aAddress != nullptr); - if (aTimeout == 0) { BackboneRouter::BackboneRouterConfig config; diff --git a/src/core/api/border_router_api.cpp b/src/core/api/border_router_api.cpp index 2ef3c4d91..150e4ff6a 100644 --- a/src/core/api/border_router_api.cpp +++ b/src/core/api/border_router_api.cpp @@ -53,8 +53,6 @@ otError otBorderRouterAddOnMeshPrefix(otInstance *aInstance, const otBorderRoute { Error error = kErrorNone; - OT_ASSERT(aConfig != nullptr); - #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE if (aConfig->mDp) { @@ -73,8 +71,6 @@ otError otBorderRouterRemoveOnMeshPrefix(otInstance *aInstance, const otIp6Prefi { Error error = kErrorNone; - OT_ASSERT(aPrefix != nullptr); - #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE error = AsCoreType(aInstance).Get().RemoveDomainPrefix(AsCoreType(aPrefix)); @@ -91,22 +87,18 @@ otError otBorderRouterGetNextOnMeshPrefix(otInstance * aInstance, otNetworkDataIterator *aIterator, otBorderRouterConfig * aConfig) { - OT_ASSERT(aIterator != nullptr && aConfig != nullptr); + AssertPointerIsNotNull(aIterator); return AsCoreType(aInstance).Get().GetNextOnMeshPrefix(*aIterator, AsCoreType(aConfig)); } otError otBorderRouterAddRoute(otInstance *aInstance, const otExternalRouteConfig *aConfig) { - OT_ASSERT(aConfig != nullptr); - return AsCoreType(aInstance).Get().AddHasRoutePrefix(AsCoreType(aConfig)); } otError otBorderRouterRemoveRoute(otInstance *aInstance, const otIp6Prefix *aPrefix) { - OT_ASSERT(aPrefix != nullptr); - return AsCoreType(aInstance).Get().RemoveHasRoutePrefix(AsCoreType(aPrefix)); } @@ -114,7 +106,7 @@ otError otBorderRouterGetNextRoute(otInstance * aInstance, otNetworkDataIterator *aIterator, otExternalRouteConfig *aConfig) { - OT_ASSERT(aIterator != nullptr && aConfig != nullptr); + AssertPointerIsNotNull(aIterator); return AsCoreType(aInstance).Get().GetNextExternalRoute(*aIterator, AsCoreType(aConfig)); } diff --git a/src/core/api/border_routing_api.cpp b/src/core/api/border_routing_api.cpp index bfc92515d..7261339be 100644 --- a/src/core/api/border_routing_api.cpp +++ b/src/core/api/border_routing_api.cpp @@ -74,6 +74,8 @@ otError otBorderRoutingGetFavoredOmrPrefix(otInstance *aInstance, otIp6Prefix *a otError error; BorderRouter::RoutingManager::RoutePreference preference; + AssertPointerIsNotNull(aPreference); + SuccessOrExit(error = AsCoreType(aInstance).Get().GetFavoredOmrPrefix( AsCoreType(aPrefix), preference)); *aPreference = static_cast(preference); @@ -100,6 +102,8 @@ otError otBorderRoutingGetFavoredNat64Prefix(otInstance * aInstance, otError error; BorderRouter::RoutingManager::RoutePreference preference; + AssertPointerIsNotNull(aPreference); + SuccessOrExit(error = AsCoreType(aInstance).Get().GetFavoredNat64Prefix( AsCoreType(aPrefix), preference)); *aPreference = static_cast(preference); @@ -111,6 +115,8 @@ exit: void otBorderRoutingPrefixTableInitIterator(otInstance *aInstance, otBorderRoutingPrefixTableIterator *aIterator) { + AssertPointerIsNotNull(aIterator); + AsCoreType(aInstance).Get().InitPrefixTableIterator(*aIterator); } @@ -118,6 +124,9 @@ otError otBorderRoutingGetNextPrefixTableEntry(otInstance * otBorderRoutingPrefixTableIterator *aIterator, otBorderRoutingPrefixTableEntry * aEntry) { + AssertPointerIsNotNull(aIterator); + AssertPointerIsNotNull(aEntry); + return AsCoreType(aInstance).Get().GetNextPrefixTableEntry(*aIterator, *aEntry); } diff --git a/src/core/api/coap_secure_api.cpp b/src/core/api/coap_secure_api.cpp index 0a0c6aac2..adf01e7de 100644 --- a/src/core/api/coap_secure_api.cpp +++ b/src/core/api/coap_secure_api.cpp @@ -57,8 +57,6 @@ void otCoapSecureSetCertificate(otInstance * aInstance, const uint8_t *aPrivateKey, uint32_t aPrivateKeyLength) { - OT_ASSERT(aX509Cert != nullptr && aX509Length != 0 && aPrivateKey != nullptr && aPrivateKeyLength != 0); - AsCoreType(aInstance).GetApplicationCoapSecure().SetCertificate(aX509Cert, aX509Length, aPrivateKey, aPrivateKeyLength); } @@ -67,8 +65,6 @@ void otCoapSecureSetCaCertificateChain(otInstance * aInstance, const uint8_t *aX509CaCertificateChain, uint32_t aX509CaCertChainLength) { - OT_ASSERT(aX509CaCertificateChain != nullptr && aX509CaCertChainLength != 0); - AsCoreType(aInstance).GetApplicationCoapSecure().SetCaCertificateChain(aX509CaCertificateChain, aX509CaCertChainLength); } @@ -81,7 +77,8 @@ void otCoapSecureSetPsk(otInstance * aInstance, const uint8_t *aPskIdentity, uint16_t aPskIdLength) { - OT_ASSERT(aPsk != nullptr && aPskLength != 0 && aPskIdentity != nullptr && aPskIdLength != 0); + AssertPointerIsNotNull(aPsk); + AssertPointerIsNotNull(aPskIdentity); AsCoreType(aInstance).GetApplicationCoapSecure().SetPreSharedKey(aPsk, aPskLength, aPskIdentity, aPskIdLength); } @@ -93,6 +90,8 @@ otError otCoapSecureGetPeerCertificateBase64(otInstance * aInstance, size_t * aCertLength, size_t aCertBufferSize) { + AssertPointerIsNotNull(aPeerCert); + return AsCoreType(aInstance).GetApplicationCoapSecure().GetPeerCertificateBase64(aPeerCert, aCertLength, aCertBufferSize); } diff --git a/src/core/api/crypto_api.cpp b/src/core/api/crypto_api.cpp index 8a96d466a..42b8e2a51 100644 --- a/src/core/api/crypto_api.cpp +++ b/src/core/api/crypto_api.cpp @@ -51,11 +51,11 @@ void otCryptoHmacSha256(const otCryptoKey *aKey, const uint8_t *aBuf, uint16_t a { HmacSha256 hmac; - OT_ASSERT((aKey != nullptr) && (aBuf != nullptr) && (aHash != nullptr)); + AssertPointerIsNotNull(aBuf); hmac.Start(AsCoreType(aKey)); hmac.Update(aBuf, aBufLength); - hmac.Finish(ot::AsCoreType(aHash)); + hmac.Finish(AsCoreType(aHash)); } void otCryptoAesCcm(const otCryptoKey *aKey, @@ -71,7 +71,11 @@ void otCryptoAesCcm(const otCryptoKey *aKey, void * aTag) { AesCcm aesCcm; - OT_ASSERT((aNonce != nullptr) && (aPlainText != nullptr) && (aCipherText != nullptr) && (aTag != nullptr)); + + AssertPointerIsNotNull(aNonce); + AssertPointerIsNotNull(aPlainText); + AssertPointerIsNotNull(aCipherText); + AssertPointerIsNotNull(aTag); aesCcm.SetKey(AsCoreType(aKey)); aesCcm.Init(aHeaderLength, aLength, aTagLength, aNonce, aNonceLength); @@ -95,6 +99,11 @@ otError otCryptoEcdsaSign(uint8_t * aOutput, const uint8_t *aPrivateKey, uint16_t aPrivateKeyLength) { + AssertPointerIsNotNull(aOutput); + AssertPointerIsNotNull(aOutputLength); + AssertPointerIsNotNull(aInputHash); + AssertPointerIsNotNull(aPrivateKey); + return Ecdsa::Sign(aOutput, *aOutputLength, aInputHash, aInputHashLength, aPrivateKey, aPrivateKeyLength); } diff --git a/src/core/api/dataset_api.cpp b/src/core/api/dataset_api.cpp index 457c78350..f8d14f608 100644 --- a/src/core/api/dataset_api.cpp +++ b/src/core/api/dataset_api.cpp @@ -49,56 +49,48 @@ bool otDatasetIsCommissioned(otInstance *aInstance) otError otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset) { - OT_ASSERT(aDataset != nullptr); - return AsCoreType(aInstance).Get().Read(AsCoreType(aDataset)); } otError otDatasetGetActiveTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset) { - OT_ASSERT(aDataset != nullptr); + AssertPointerIsNotNull(aDataset); return AsCoreType(aInstance).Get().Read(*aDataset); } otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aDataset) { - OT_ASSERT(aDataset != nullptr); - return AsCoreType(aInstance).Get().Save(AsCoreType(aDataset)); } otError otDatasetSetActiveTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset) { - OT_ASSERT(aDataset != nullptr); + AssertPointerIsNotNull(aDataset); return AsCoreType(aInstance).Get().Save(*aDataset); } otError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDataset) { - OT_ASSERT(aDataset != nullptr); - return AsCoreType(aInstance).Get().Read(AsCoreType(aDataset)); } otError otDatasetGetPendingTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset) { - OT_ASSERT(aDataset != nullptr); + AssertPointerIsNotNull(aDataset); return AsCoreType(aInstance).Get().Read(*aDataset); } otError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *aDataset) { - OT_ASSERT(aDataset != nullptr); - return AsCoreType(aInstance).Get().Save(AsCoreType(aDataset)); } otError otDatasetSetPendingTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset) { - OT_ASSERT(aDataset != nullptr); + AssertPointerIsNotNull(aDataset); return AsCoreType(aInstance).Get().Save(*aDataset); } @@ -153,7 +145,7 @@ otError otDatasetGeneratePskc(const char * aPassPhrase, { return MeshCoP::GeneratePskc(aPassPhrase, AsCoreType(aNetworkName), AsCoreType(aExtPanId), AsCoreType(aPskc)); } -#endif // OPENTHREAD_FTD +#endif otError otNetworkNameFromString(otNetworkName *aNetworkName, const char *aNameString) { @@ -167,6 +159,8 @@ otError otDatasetParseTlvs(const otOperationalDatasetTlvs *aDatasetTlvs, otOpera Error error = kErrorNone; MeshCoP::Dataset dataset; + AssertPointerIsNotNull(aDatasetTlvs); + dataset.SetFrom(*aDatasetTlvs); VerifyOrExit(dataset.IsValid(), error = kErrorInvalidArgs); dataset.ConvertTo(AsCoreType(aDataset)); diff --git a/src/core/api/diags_api.cpp b/src/core/api/diags_api.cpp index a012d1adc..7883e12d2 100644 --- a/src/core/api/diags_api.cpp +++ b/src/core/api/diags_api.cpp @@ -44,6 +44,8 @@ using namespace ot; void otDiagProcessCmdLine(otInstance *aInstance, const char *aString, char *aOutput, size_t aOutputMaxLen) { + AssertPointerIsNotNull(aString); + AsCoreType(aInstance).Get().ProcessLine(aString, aOutput, aOutputMaxLen); } diff --git a/src/core/api/dns_api.cpp b/src/core/api/dns_api.cpp index d9bdda700..4437b1948 100644 --- a/src/core/api/dns_api.cpp +++ b/src/core/api/dns_api.cpp @@ -87,6 +87,8 @@ otError otDnsClientResolveAddress(otInstance * aInstance, void * aContext, const otDnsQueryConfig *aConfig) { + AssertPointerIsNotNull(aHostName); + return AsCoreType(aInstance).Get().ResolveAddress(aHostName, aCallback, aContext, AsCoreTypePtr(aConfig)); } @@ -98,6 +100,8 @@ otError otDnsClientResolveIp4Address(otInstance * aInstance, void * aContext, const otDnsQueryConfig *aConfig) { + AssertPointerIsNotNull(aHostName); + return AsCoreType(aInstance).Get().ResolveIp4Address(aHostName, aCallback, aContext, AsCoreTypePtr(aConfig)); } @@ -107,6 +111,8 @@ otError otDnsAddressResponseGetHostName(const otDnsAddressResponse *aResponse, char * aNameBuffer, uint16_t aNameBufferSize) { + AssertPointerIsNotNull(aNameBuffer); + return AsCoreType(aResponse).GetHostName(aNameBuffer, aNameBufferSize); } @@ -128,6 +134,8 @@ otError otDnsClientBrowse(otInstance * aInstance, void * aContext, const otDnsQueryConfig *aConfig) { + AssertPointerIsNotNull(aServiceName); + return AsCoreType(aInstance).Get().Browse(aServiceName, aCallback, aContext, AsCoreTypePtr(aConfig)); } @@ -135,6 +143,8 @@ otError otDnsBrowseResponseGetServiceName(const otDnsBrowseResponse *aResponse, char * aNameBuffer, uint16_t aNameBufferSize) { + AssertPointerIsNotNull(aNameBuffer); + return AsCoreType(aResponse).GetServiceName(aNameBuffer, aNameBufferSize); } @@ -143,6 +153,8 @@ otError otDnsBrowseResponseGetServiceInstance(const otDnsBrowseResponse *aRespon char * aLabelBuffer, uint8_t aLabelBufferSize) { + AssertPointerIsNotNull(aLabelBuffer); + return AsCoreType(aResponse).GetServiceInstance(aIndex, aLabelBuffer, aLabelBufferSize); } @@ -150,6 +162,8 @@ otError otDnsBrowseResponseGetServiceInfo(const otDnsBrowseResponse *aResponse, const char * aInstanceLabel, otDnsServiceInfo * aServiceInfo) { + AssertPointerIsNotNull(aInstanceLabel); + return AsCoreType(aResponse).GetServiceInfo(aInstanceLabel, AsCoreType(aServiceInfo)); } @@ -161,6 +175,8 @@ otError otDnsBrowseResponseGetHostAddress(const otDnsBrowseResponse *aResponse, { uint32_t ttl; + AssertPointerIsNotNull(aHostName); + return AsCoreType(aResponse).GetHostAddress(aHostName, aIndex, AsCoreType(aAddress), aTtl != nullptr ? *aTtl : ttl); } @@ -171,6 +187,9 @@ otError otDnsClientResolveService(otInstance * aInstance, void * aContext, const otDnsQueryConfig *aConfig) { + AssertPointerIsNotNull(aInstanceLabel); + AssertPointerIsNotNull(aServiceName); + return AsCoreType(aInstance).Get().ResolveService(aInstanceLabel, aServiceName, aCallback, aContext, AsCoreTypePtr(aConfig)); } @@ -181,6 +200,9 @@ otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse char * aNameBuffer, uint16_t aNameBufferSize) { + AssertPointerIsNotNull(aLabelBuffer); + AssertPointerIsNotNull(aNameBuffer); + return AsCoreType(aResponse).GetServiceName(aLabelBuffer, aLabelBufferSize, aNameBuffer, aNameBufferSize); } @@ -197,6 +219,8 @@ otError otDnsServiceResponseGetHostAddress(const otDnsServiceResponse *aResponse { uint32_t ttl; + AssertPointerIsNotNull(aHostName); + return AsCoreType(aResponse).GetHostAddress(aHostName, aIndex, AsCoreType(aAddress), (aTtl != nullptr) ? *aTtl : ttl); } diff --git a/src/core/api/dns_server_api.cpp b/src/core/api/dns_server_api.cpp index 5b094487d..83220c181 100644 --- a/src/core/api/dns_server_api.cpp +++ b/src/core/api/dns_server_api.cpp @@ -53,8 +53,8 @@ void otDnssdQueryHandleDiscoveredServiceInstance(otInstance * aIn const char * aServiceFullName, otDnssdServiceInstanceInfo *aInstanceInfo) { - OT_ASSERT(aServiceFullName != nullptr); - OT_ASSERT(aInstanceInfo != nullptr); + AssertPointerIsNotNull(aServiceFullName); + AssertPointerIsNotNull(aInstanceInfo); AsCoreType(aInstance).Get().HandleDiscoveredServiceInstance(aServiceFullName, *aInstanceInfo); @@ -62,8 +62,8 @@ void otDnssdQueryHandleDiscoveredServiceInstance(otInstance * aIn void otDnssdQueryHandleDiscoveredHost(otInstance *aInstance, const char *aHostFullName, otDnssdHostInfo *aHostInfo) { - OT_ASSERT(aHostFullName != nullptr); - OT_ASSERT(aHostInfo != nullptr); + AssertPointerIsNotNull(aHostFullName); + AssertPointerIsNotNull(aHostInfo); AsCoreType(aInstance).Get().HandleDiscoveredHost(aHostFullName, *aHostInfo); } @@ -75,8 +75,8 @@ const otDnssdQuery *otDnssdGetNextQuery(otInstance *aInstance, const otDnssdQuer otDnssdQueryType otDnssdGetQueryTypeAndName(const otDnssdQuery *aQuery, char (*aNameOutput)[OT_DNS_MAX_NAME_SIZE]) { - OT_ASSERT(aQuery != nullptr); - OT_ASSERT(aNameOutput != nullptr); + AssertPointerIsNotNull(aQuery); + AssertPointerIsNotNull(aNameOutput); return MapEnum(Dns::ServiceDiscovery::Server::GetQueryTypeAndName(aQuery, *aNameOutput)); } diff --git a/src/core/api/history_tracker_api.cpp b/src/core/api/history_tracker_api.cpp index 5e52b36a7..4dd56a4c5 100644 --- a/src/core/api/history_tracker_api.cpp +++ b/src/core/api/history_tracker_api.cpp @@ -52,6 +52,8 @@ const otHistoryTrackerNetworkInfo *otHistoryTrackerIterateNetInfoHistory(otInsta otHistoryTrackerIterator *aIterator, uint32_t * aEntryAge) { + AssertPointerIsNotNull(aEntryAge); + return AsCoreType(aInstance).Get().IterateNetInfoHistory(AsCoreType(aIterator), *aEntryAge); } @@ -60,6 +62,8 @@ const otHistoryTrackerUnicastAddressInfo *otHistoryTrackerIterateUnicastAddressH otHistoryTrackerIterator *aIterator, uint32_t * aEntryAge) { + AssertPointerIsNotNull(aEntryAge); + return AsCoreType(aInstance).Get().IterateUnicastAddressHistory(AsCoreType(aIterator), *aEntryAge); } @@ -69,6 +73,8 @@ const otHistoryTrackerMulticastAddressInfo *otHistoryTrackerIterateMulticastAddr otHistoryTrackerIterator *aIterator, uint32_t * aEntryAge) { + AssertPointerIsNotNull(aEntryAge); + return AsCoreType(aInstance).Get().IterateMulticastAddressHistory(AsCoreType(aIterator), *aEntryAge); } @@ -77,6 +83,8 @@ const otHistoryTrackerMessageInfo *otHistoryTrackerIterateRxHistory(otInstance * otHistoryTrackerIterator *aIterator, uint32_t * aEntryAge) { + AssertPointerIsNotNull(aEntryAge); + return AsCoreType(aInstance).Get().IterateRxHistory(AsCoreType(aIterator), *aEntryAge); } @@ -84,6 +92,8 @@ const otHistoryTrackerMessageInfo *otHistoryTrackerIterateTxHistory(otInstance * otHistoryTrackerIterator *aIterator, uint32_t * aEntryAge) { + AssertPointerIsNotNull(aEntryAge); + return AsCoreType(aInstance).Get().IterateTxHistory(AsCoreType(aIterator), *aEntryAge); } @@ -91,6 +101,8 @@ const otHistoryTrackerNeighborInfo *otHistoryTrackerIterateNeighborHistory(otIns otHistoryTrackerIterator *aIterator, uint32_t * aEntryAge) { + AssertPointerIsNotNull(aEntryAge); + return AsCoreType(aInstance).Get().IterateNeighborHistory(AsCoreType(aIterator), *aEntryAge); } @@ -98,6 +110,8 @@ const otHistoryTrackerOnMeshPrefixInfo *otHistoryTrackerIterateOnMeshPrefixHisto otHistoryTrackerIterator *aIterator, uint32_t * aEntryAge) { + AssertPointerIsNotNull(aEntryAge); + return AsCoreType(aInstance).Get().IterateOnMeshPrefixHistory(AsCoreType(aIterator), *aEntryAge); } @@ -107,6 +121,8 @@ const otHistoryTrackerExternalRouteInfo *otHistoryTrackerIterateExternalRouteHis otHistoryTrackerIterator *aIterator, uint32_t * aEntryAge) { + AssertPointerIsNotNull(aEntryAge); + return AsCoreType(aInstance).Get().IterateExternalRouteHistory(AsCoreType(aIterator), *aEntryAge); } diff --git a/src/core/api/instance_api.cpp b/src/core/api/instance_api.cpp index 5557f687f..9cc35c96c 100644 --- a/src/core/api/instance_api.cpp +++ b/src/core/api/instance_api.cpp @@ -101,6 +101,8 @@ uint64_t otInstanceGetUptime(otInstance *aInstance) void otInstanceGetUptimeAsString(otInstance *aInstance, char *aBuffer, uint16_t aSize) { + AssertPointerIsNotNull(aBuffer); + AsCoreType(aInstance).Get().GetUptime(aBuffer, aSize); } #endif diff --git a/src/core/api/ip6_api.cpp b/src/core/api/ip6_api.cpp index 2b54e8ddf..ebdc85098 100644 --- a/src/core/api/ip6_api.cpp +++ b/src/core/api/ip6_api.cpp @@ -168,6 +168,8 @@ void otIp6RemoveAllUnsecurePorts(otInstance *aInstance) const uint16_t *otIp6GetUnsecurePorts(otInstance *aInstance, uint8_t *aNumEntries) { + AssertPointerIsNotNull(aNumEntries); + return AsCoreType(aInstance).Get().GetUnsecurePorts(*aNumEntries); } @@ -188,23 +190,27 @@ otError otIp6AddressFromString(const char *aString, otIp6Address *aAddress) void otIp6AddressToString(const otIp6Address *aAddress, char *aBuffer, uint16_t aSize) { + AssertPointerIsNotNull(aBuffer); + AsCoreType(aAddress).ToString(aBuffer, aSize); } void otIp6SockAddrToString(const otSockAddr *aSockAddr, char *aBuffer, uint16_t aSize) { + AssertPointerIsNotNull(aBuffer); + AsCoreType(aSockAddr).ToString(aBuffer, aSize); } void otIp6PrefixToString(const otIp6Prefix *aPrefix, char *aBuffer, uint16_t aSize) { + AssertPointerIsNotNull(aBuffer); + AsCoreType(aPrefix).ToString(aBuffer, aSize); } uint8_t otIp6PrefixMatch(const otIp6Address *aFirst, const otIp6Address *aSecond) { - OT_ASSERT(aFirst != nullptr && aSecond != nullptr); - return AsCoreType(aFirst).PrefixMatch(AsCoreType(aSecond)); } diff --git a/src/core/api/link_api.cpp b/src/core/api/link_api.cpp index ff5922dea..b1897be2a 100644 --- a/src/core/api/link_api.cpp +++ b/src/core/api/link_api.cpp @@ -112,7 +112,6 @@ otError otLinkSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExt Error error = kErrorNone; Instance &instance = AsCoreType(aInstance); - OT_ASSERT(aExtAddress != nullptr); VerifyOrExit(instance.Get().IsDisabled(), error = kErrorInvalidState); instance.Get().SetExtAddress(AsCoreType(aExtAddress)); @@ -206,15 +205,11 @@ void otLinkFilterSetAddressMode(otInstance *aInstance, otMacFilterAddressMode aM otError otLinkFilterAddAddress(otInstance *aInstance, const otExtAddress *aExtAddress) { - OT_ASSERT(aExtAddress != nullptr); - return AsCoreType(aInstance).Get().AddAddress(AsCoreType(aExtAddress)); } void otLinkFilterRemoveAddress(otInstance *aInstance, const otExtAddress *aExtAddress) { - OT_ASSERT(aExtAddress != nullptr); - AsCoreType(aInstance).Get().RemoveAddress(AsCoreType(aExtAddress)); } @@ -225,22 +220,19 @@ void otLinkFilterClearAddresses(otInstance *aInstance) otError otLinkFilterGetNextAddress(otInstance *aInstance, otMacFilterIterator *aIterator, otMacFilterEntry *aEntry) { - OT_ASSERT(aIterator != nullptr && aEntry != nullptr); + AssertPointerIsNotNull(aIterator); + AssertPointerIsNotNull(aEntry); return AsCoreType(aInstance).Get().GetNextAddress(*aIterator, *aEntry); } otError otLinkFilterAddRssIn(otInstance *aInstance, const otExtAddress *aExtAddress, int8_t aRss) { - OT_ASSERT(aExtAddress != nullptr); - return AsCoreType(aInstance).Get().AddRssIn(AsCoreType(aExtAddress), aRss); } void otLinkFilterRemoveRssIn(otInstance *aInstance, const otExtAddress *aExtAddress) { - OT_ASSERT(aExtAddress != nullptr); - AsCoreType(aInstance).Get().RemoveRssIn(AsCoreType(aExtAddress)); } @@ -261,7 +253,8 @@ void otLinkFilterClearAllRssIn(otInstance *aInstance) otError otLinkFilterGetNextRssIn(otInstance *aInstance, otMacFilterIterator *aIterator, otMacFilterEntry *aEntry) { - OT_ASSERT(aIterator != nullptr && aEntry != nullptr); + AssertPointerIsNotNull(aIterator); + AssertPointerIsNotNull(aEntry); return AsCoreType(aInstance).Get().GetNextRssIn(*aIterator, *aEntry); } @@ -294,6 +287,8 @@ int8_t otLinkConvertLinkQualityToRss(otInstance *aInstance, uint8_t aLinkQuality #if OPENTHREAD_CONFIG_MAC_RETRY_SUCCESS_HISTOGRAM_ENABLE const uint32_t *otLinkGetTxDirectRetrySuccessHistogram(otInstance *aInstance, uint8_t *aNumberOfEntries) { + AssertPointerIsNotNull(aNumberOfEntries); + return AsCoreType(aInstance).Get().GetDirectRetrySuccessHistogram(*aNumberOfEntries); } @@ -301,6 +296,8 @@ const uint32_t *otLinkGetTxIndirectRetrySuccessHistogram(otInstance *aInstance, { const uint32_t *histogram = nullptr; + AssertPointerIsNotNull(aNumberOfEntries); + #if OPENTHREAD_FTD histogram = AsCoreType(aInstance).Get().GetIndirectRetrySuccessHistogram(*aNumberOfEntries); #else diff --git a/src/core/api/link_metrics_api.cpp b/src/core/api/link_metrics_api.cpp index b14a915a0..081e9684e 100644 --- a/src/core/api/link_metrics_api.cpp +++ b/src/core/api/link_metrics_api.cpp @@ -49,8 +49,6 @@ otError otLinkMetricsQuery(otInstance * aInstance, otLinkMetricsReportCallback aCallback, void * aCallbackContext) { - OT_ASSERT(aDestination != nullptr); - AsCoreType(aInstance).Get().SetReportCallback(aCallback, aCallbackContext); return AsCoreType(aInstance).Get().Query(AsCoreType(aDestination), aSeriesId, @@ -65,8 +63,6 @@ otError otLinkMetricsConfigForwardTrackingSeries(otInstance * otLinkMetricsMgmtResponseCallback aCallback, void * aCallbackContext) { - OT_ASSERT(aDestination != nullptr); - LinkMetrics::LinkMetrics &linkMetrics = AsCoreType(aInstance).Get(); linkMetrics.SetMgmtResponseCallback(aCallback, aCallbackContext); @@ -85,8 +81,6 @@ otError otLinkMetricsConfigEnhAckProbing(otInstance * otLinkMetricsEnhAckProbingIeReportCallback aEnhAckCallback, void * aEnhAckCallbackContext) { - OT_ASSERT(aDestination != nullptr); - LinkMetrics::LinkMetrics &linkMetrics = AsCoreType(aInstance).Get(); linkMetrics.SetMgmtResponseCallback(aCallback, aCallbackContext); @@ -101,7 +95,6 @@ otError otLinkMetricsSendLinkProbe(otInstance * aInstance, uint8_t aSeriesId, uint8_t aLength) { - OT_ASSERT(aDestination != nullptr); LinkMetrics::LinkMetrics &linkMetrics = AsCoreType(aInstance).Get(); return linkMetrics.SendLinkProbe(AsCoreType(aDestination), aSeriesId, aLength); diff --git a/src/core/api/link_raw_api.cpp b/src/core/api/link_raw_api.cpp index fafe69c38..e28b4cd49 100644 --- a/src/core/api/link_raw_api.cpp +++ b/src/core/api/link_raw_api.cpp @@ -159,6 +159,8 @@ otError otLinkRawSrcMatchAddExtEntry(otInstance *aInstance, const otExtAddress * Error error = kErrorNone; Instance & instance = AsCoreType(aInstance); + AssertPointerIsNotNull(aExtAddress); + VerifyOrExit(instance.Get().IsEnabled(), error = kErrorInvalidState); address.Set(aExtAddress->m8, Mac::ExtAddress::kReverseByteOrder); @@ -186,6 +188,8 @@ otError otLinkRawSrcMatchClearExtEntry(otInstance *aInstance, const otExtAddress Error error = kErrorNone; Instance & instance = AsCoreType(aInstance); + AssertPointerIsNotNull(aExtAddress); + VerifyOrExit(instance.Get().IsEnabled(), error = kErrorInvalidState); address.Set(aExtAddress->m8, Mac::ExtAddress::kReverseByteOrder); @@ -288,6 +292,8 @@ uint16_t otLinkGetShortAddress(otInstance *aInstance) void otLinkGetFactoryAssignedIeeeEui64(otInstance *aInstance, otExtAddress *aEui64) { + AssertPointerIsNotNull(aEui64); + otPlatRadioGetIeeeEui64(aInstance, aEui64->m8); } diff --git a/src/core/api/message_api.cpp b/src/core/api/message_api.cpp index ecc3bfc4d..fe1a76e78 100644 --- a/src/core/api/message_api.cpp +++ b/src/core/api/message_api.cpp @@ -89,16 +89,22 @@ int8_t otMessageGetRss(const otMessage *aMessage) otError otMessageAppend(otMessage *aMessage, const void *aBuf, uint16_t aLength) { + AssertPointerIsNotNull(aBuf); + return AsCoreType(aMessage).AppendBytes(aBuf, aLength); } uint16_t otMessageRead(const otMessage *aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength) { + AssertPointerIsNotNull(aBuf); + return AsCoreType(aMessage).ReadBytes(aOffset, aBuf, aLength); } int otMessageWrite(otMessage *aMessage, uint16_t aOffset, const void *aBuf, uint16_t aLength) { + AssertPointerIsNotNull(aBuf); + AsCoreType(aMessage).WriteBytes(aOffset, aBuf, aLength); return aLength; @@ -106,6 +112,8 @@ int otMessageWrite(otMessage *aMessage, uint16_t aOffset, const void *aBuf, uint void otMessageQueueInit(otMessageQueue *aQueue) { + AssertPointerIsNotNull(aQueue); + aQueue->mData = nullptr; } diff --git a/src/core/api/netdata_api.cpp b/src/core/api/netdata_api.cpp index c28b98727..fa0eabcb1 100644 --- a/src/core/api/netdata_api.cpp +++ b/src/core/api/netdata_api.cpp @@ -42,6 +42,9 @@ using namespace ot; otError otNetDataGet(otInstance *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength) { + AssertPointerIsNotNull(aData); + AssertPointerIsNotNull(aDataLength); + return AsCoreType(aInstance).Get().CopyNetworkData( aStable ? NetworkData::kStableSubset : NetworkData::kFullSet, aData, *aDataLength); } @@ -50,14 +53,9 @@ otError otNetDataGetNextOnMeshPrefix(otInstance * aInstance, otNetworkDataIterator *aIterator, otBorderRouterConfig * aConfig) { - Error error = kErrorNone; + AssertPointerIsNotNull(aIterator); - VerifyOrExit(aIterator && aConfig, error = kErrorInvalidArgs); - - error = AsCoreType(aInstance).Get().GetNextOnMeshPrefix(*aIterator, AsCoreType(aConfig)); - -exit: - return error; + return AsCoreType(aInstance).Get().GetNextOnMeshPrefix(*aIterator, AsCoreType(aConfig)); } #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE @@ -69,26 +67,16 @@ bool otNetDataContainsOmrPrefix(otInstance *aInstance, const otIp6Prefix *aPrefi otError otNetDataGetNextRoute(otInstance *aInstance, otNetworkDataIterator *aIterator, otExternalRouteConfig *aConfig) { - Error error = kErrorNone; + AssertPointerIsNotNull(aIterator); - VerifyOrExit(aIterator && aConfig, error = kErrorInvalidArgs); - - error = AsCoreType(aInstance).Get().GetNextExternalRoute(*aIterator, AsCoreType(aConfig)); - -exit: - return error; + return AsCoreType(aInstance).Get().GetNextExternalRoute(*aIterator, AsCoreType(aConfig)); } otError otNetDataGetNextService(otInstance *aInstance, otNetworkDataIterator *aIterator, otServiceConfig *aConfig) { - Error error = kErrorNone; + AssertPointerIsNotNull(aIterator); - VerifyOrExit(aIterator && aConfig, error = kErrorInvalidArgs); - - error = AsCoreType(aInstance).Get().GetNextService(*aIterator, AsCoreType(aConfig)); - -exit: - return error; + return AsCoreType(aInstance).Get().GetNextService(*aIterator, AsCoreType(aConfig)); } uint8_t otNetDataGetVersion(otInstance *aInstance) diff --git a/src/core/api/netdiag_api.cpp b/src/core/api/netdiag_api.cpp index ff09c8e8f..dddbec47b 100644 --- a/src/core/api/netdiag_api.cpp +++ b/src/core/api/netdiag_api.cpp @@ -46,6 +46,9 @@ otError otThreadGetNextDiagnosticTlv(const otMessage * aMessage, otNetworkDiagIterator *aIterator, otNetworkDiagTlv * aNetworkDiagTlv) { + AssertPointerIsNotNull(aIterator); + AssertPointerIsNotNull(aNetworkDiagTlv); + return NetworkDiagnostic::NetworkDiagnostic::GetNextDiagTlv(AsCoapMessage(aMessage), *aIterator, *aNetworkDiagTlv); } diff --git a/src/core/api/network_time_api.cpp b/src/core/api/network_time_api.cpp index 128aff478..add205416 100644 --- a/src/core/api/network_time_api.cpp +++ b/src/core/api/network_time_api.cpp @@ -44,6 +44,8 @@ using namespace ot; otNetworkTimeStatus otNetworkTimeGet(otInstance *aInstance, uint64_t *aNetworkTime) { + AssertPointerIsNotNull(aNetworkTime); + return AsCoreType(aInstance).Get().GetTime(*aNetworkTime); } diff --git a/src/core/api/srp_client_buffers_api.cpp b/src/core/api/srp_client_buffers_api.cpp index 51c91a86a..35b26054c 100644 --- a/src/core/api/srp_client_buffers_api.cpp +++ b/src/core/api/srp_client_buffers_api.cpp @@ -44,11 +44,15 @@ using namespace ot; char *otSrpClientBuffersGetHostNameString(otInstance *aInstance, uint16_t *aSize) { + AssertPointerIsNotNull(aSize); + return AsCoreType(aInstance).Get().GetHostNameString(*aSize); } otIp6Address *otSrpClientBuffersGetHostAddressesArray(otInstance *aInstance, uint8_t *aArrayLength) { + AssertPointerIsNotNull(aArrayLength); + return AsCoreType(aInstance).Get().GetHostAddressesArray(*aArrayLength); } @@ -69,21 +73,29 @@ void otSrpClientBuffersFreeAllServices(otInstance *aInstance) char *otSrpClientBuffersGetServiceEntryServiceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize) { + AssertPointerIsNotNull(aSize); + return AsCoreType(aEntry).GetServiceNameString(*aSize); } char *otSrpClientBuffersGetServiceEntryInstanceNameString(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize) { + AssertPointerIsNotNull(aSize); + return AsCoreType(aEntry).GetInstanceNameString(*aSize); } uint8_t *otSrpClientBuffersGetServiceEntryTxtBuffer(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aSize) { + AssertPointerIsNotNull(aSize); + return AsCoreType(aEntry).GetTxtBuffer(*aSize); } const char **otSrpClientBuffersGetSubTypeLabelsArray(otSrpClientBuffersServiceEntry *aEntry, uint16_t *aArrayLength) { + AssertPointerIsNotNull(aArrayLength); + return AsCoreType(aEntry).GetSubTypeLabelsArray(*aArrayLength); } diff --git a/src/core/api/thread_api.cpp b/src/core/api/thread_api.cpp index c8056e274..54960cc2c 100644 --- a/src/core/api/thread_api.cpp +++ b/src/core/api/thread_api.cpp @@ -78,8 +78,6 @@ exit: otError otThreadGetLeaderRloc(otInstance *aInstance, otIp6Address *aLeaderRloc) { - OT_ASSERT(aLeaderRloc != nullptr); - return AsCoreType(aInstance).Get().GetLeaderAddress(AsCoreType(aLeaderRloc)); } @@ -114,8 +112,6 @@ otError otThreadSetNetworkKey(otInstance *aInstance, const otNetworkKey *aKey) Error error = kErrorNone; Instance &instance = AsCoreType(aInstance); - OT_ASSERT(aKey != nullptr); - VerifyOrExit(instance.Get().IsDisabled(), error = kErrorInvalidState); instance.Get().SetNetworkKey(AsCoreType(aKey)); @@ -297,7 +293,7 @@ otError otThreadBecomeChild(otInstance *aInstance) otError otThreadGetNextNeighborInfo(otInstance *aInstance, otNeighborInfoIterator *aIterator, otNeighborInfo *aInfo) { - OT_ASSERT((aInfo != nullptr) && (aIterator != nullptr)); + AssertPointerIsNotNull(aIterator); return AsCoreType(aInstance).Get().GetNextNeighborInfo(*aIterator, AsCoreType(aInfo)); } @@ -316,7 +312,7 @@ otError otThreadGetLeaderData(otInstance *aInstance, otLeaderData *aLeaderData) { Error error = kErrorNone; - OT_ASSERT(aLeaderData != nullptr); + AssertPointerIsNotNull(aLeaderData); VerifyOrExit(AsCoreType(aInstance).Get().IsAttached(), error = kErrorDetached); *aLeaderData = AsCoreType(aInstance).Get().GetLeaderData(); @@ -354,7 +350,7 @@ otError otThreadGetParentAverageRssi(otInstance *aInstance, int8_t *aParentRssi) { Error error = kErrorNone; - OT_ASSERT(aParentRssi != nullptr); + AssertPointerIsNotNull(aParentRssi); *aParentRssi = AsCoreType(aInstance).Get().GetParent().GetLinkInfo().GetAverageRss(); @@ -368,7 +364,7 @@ otError otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi) { Error error = kErrorNone; - OT_ASSERT(aLastRssi != nullptr); + AssertPointerIsNotNull(aLastRssi); *aLastRssi = AsCoreType(aInstance).Get().GetParent().GetLinkInfo().GetLastRss(); diff --git a/src/core/api/thread_ftd_api.cpp b/src/core/api/thread_ftd_api.cpp index e8d3a4b8e..0ec09b659 100644 --- a/src/core/api/thread_ftd_api.cpp +++ b/src/core/api/thread_ftd_api.cpp @@ -205,15 +205,11 @@ void otThreadSetRouterSelectionJitter(otInstance *aInstance, uint8_t aRouterJitt otError otThreadGetChildInfoById(otInstance *aInstance, uint16_t aChildId, otChildInfo *aChildInfo) { - OT_ASSERT(aChildInfo != nullptr); - return AsCoreType(aInstance).Get().GetChildInfoById(aChildId, AsCoreType(aChildInfo)); } otError otThreadGetChildInfoByIndex(otInstance *aInstance, uint16_t aChildIndex, otChildInfo *aChildInfo) { - OT_ASSERT(aChildInfo != nullptr); - return AsCoreType(aInstance).Get().GetChildInfoByIndex(aChildIndex, AsCoreType(aChildInfo)); } @@ -225,7 +221,8 @@ otError otThreadGetChildNextIp6Address(otInstance * aInstance, Error error = kErrorNone; const Child *child; - OT_ASSERT(aIterator != nullptr && aAddress != nullptr); + AssertPointerIsNotNull(aIterator); + AssertPointerIsNotNull(aAddress); child = AsCoreType(aInstance).Get().GetChildAtIndex(aChildIndex); VerifyOrExit(child != nullptr, error = kErrorInvalidArgs); @@ -258,14 +255,13 @@ uint8_t otThreadGetMaxRouterId(otInstance *aInstance) otError otThreadGetRouterInfo(otInstance *aInstance, uint16_t aRouterId, otRouterInfo *aRouterInfo) { - OT_ASSERT(aRouterInfo != nullptr); - return AsCoreType(aInstance).Get().GetRouterInfo(aRouterId, AsCoreType(aRouterInfo)); } otError otThreadGetNextCacheEntry(otInstance *aInstance, otCacheEntryInfo *aEntryInfo, otCacheEntryIterator *aIterator) { - OT_ASSERT((aIterator != nullptr) && (aEntryInfo != nullptr)); + AssertPointerIsNotNull(aIterator); + AssertPointerIsNotNull(aEntryInfo); return AsCoreType(aInstance).Get().GetNextCacheEntry(*aEntryInfo, *aIterator); } diff --git a/src/core/api/udp_api.cpp b/src/core/api/udp_api.cpp index fad774bd3..331e62b04 100644 --- a/src/core/api/udp_api.cpp +++ b/src/core/api/udp_api.cpp @@ -95,8 +95,6 @@ void otUdpForwardReceive(otInstance * aInstance, { Ip6::MessageInfo messageInfo; - OT_ASSERT(aMessage != nullptr && aPeerAddr != nullptr); - messageInfo.SetSockAddr(AsCoreType(aInstance).Get().GetMeshLocal16()); messageInfo.SetSockPort(aSockPort); messageInfo.SetPeerAddr(AsCoreType(aPeerAddr)); diff --git a/src/core/common/as_core_type.hpp b/src/core/common/as_core_type.hpp index e5ad9bc8e..521cabbc4 100644 --- a/src/core/common/as_core_type.hpp +++ b/src/core/common/as_core_type.hpp @@ -36,6 +36,8 @@ #include "openthread-core-config.h" +#include "common/debug.hpp" + namespace ot { /** @@ -63,6 +65,8 @@ template struct CoreType; */ template typename CoreType::Type &AsCoreType(Type *aObject) { + AssertPointerIsNotNull(aObject); + return *static_cast::Type *>(aObject); } @@ -78,6 +82,8 @@ template typename CoreType::Type &AsCoreType(Type *aObject */ template const typename CoreType::Type &AsCoreType(const Type *aObject) { + AssertPointerIsNotNull(aObject); + return *static_cast::Type *>(aObject); } diff --git a/src/core/common/debug.hpp b/src/core/common/debug.hpp index 4febe3442..8bb21997a 100644 --- a/src/core/common/debug.hpp +++ b/src/core/common/debug.hpp @@ -108,4 +108,19 @@ } \ } while (false) +/** + * @def AssertPointerIsNotNull + * + * This macro asserts that a given pointer (API input parameter) is not `nullptr`. This macro checks the pointer only + * when `OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL` is enabled. Otherwise it is an empty macro. + * + * @param[in] aPointer The pointer variable (API input parameter) to check. + * + */ +#if OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL +#define AssertPointerIsNotNull(aPointer) OT_ASSERT((aPointer) != nullptr) +#else +#define AssertPointerIsNotNull(aPointer) +#endif + #endif // DEBUG_HPP_ diff --git a/src/core/config/misc.h b/src/core/config/misc.h index e915a0acc..f825a104a 100644 --- a/src/core/config/misc.h +++ b/src/core/config/misc.h @@ -346,6 +346,19 @@ #define OPENTHREAD_CONFIG_ASSERT_ENABLE 1 #endif +/** + * @def OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL + * + * Define as 1 to enable assert check of pointer-type API input parameters against null. + * + * Enabling this feature can increase code-size significantly due to many assert checks added for all API pointer + * parameters. It is recommended to enable and use this feature during debugging only. + * + */ +#ifndef OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL +#define OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL 0 +#endif + /** * @def OPENTHREAD_CONFIG_ENABLE_DEBUG_UART * diff --git a/src/posix/platform/openthread-core-posix-config.h b/src/posix/platform/openthread-core-posix-config.h index 6708751f2..325ae52da 100644 --- a/src/posix/platform/openthread-core-posix-config.h +++ b/src/posix/platform/openthread-core-posix-config.h @@ -299,4 +299,14 @@ #define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_SERVICES 20 #endif +/** + * @def OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL + * + * Define as 1 to enable assert check of pointer-type API input parameters against null. + * + */ +#ifndef OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL +#define OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL 1 +#endif + #endif // OPENTHREAD_CORE_POSIX_CONFIG_H_