From 1099147a6f0be426e44ab522f14d249ea2ff122f Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 16 Mar 2022 17:41:39 -0400 Subject: [PATCH] Modernize use nullptr (#16306) * use clang-tidy to modernize-use-nullptr * Use BLE_CONNECTION_UNINITIALIZED instead of NULL for ble comparisons * Define BLE_CONNECTION_UNINITIALIZED as nullptr instead of NULL * Restyle --- src/app/MessageDef/Builder.cpp | 2 +- src/app/util/af-event.cpp | 12 ++-- src/app/util/attribute-size-util.cpp | 2 +- src/app/util/attribute-storage.cpp | 68 +++++++++---------- src/app/util/attribute-table.cpp | 22 +++--- src/app/util/client-api.cpp | 10 +-- src/app/util/message.cpp | 14 ++-- src/app/util/util.cpp | 20 +++--- src/ble/BleConfig.h | 2 +- src/crypto/CHIPCryptoPALOpenSSL.cpp | 53 ++++++++------- src/lib/core/CHIPTLVUpdater.cpp | 6 +- src/lib/support/UnitTestUtils.cpp | 2 +- .../Linux/ConfigurationManagerImpl.cpp | 4 +- .../Linux/ConnectivityManagerImpl.cpp | 10 +-- .../Linux/DiagnosticDataProviderImpl.cpp | 2 +- src/platform/Linux/DnssdImpl.cpp | 2 +- src/platform/Linux/PlatformManagerImpl.cpp | 12 ++-- src/protocols/secure_channel/PASESession.cpp | 2 +- .../secure_channel/RendezvousParameters.h | 4 +- src/system/SystemTimer.cpp | 2 +- 20 files changed, 126 insertions(+), 125 deletions(-) diff --git a/src/app/MessageDef/Builder.cpp b/src/app/MessageDef/Builder.cpp index e93582412f1922..ef804028566406 100644 --- a/src/app/MessageDef/Builder.cpp +++ b/src/app/MessageDef/Builder.cpp @@ -32,7 +32,7 @@ using namespace chip::TLV; namespace chip { namespace app { -Builder::Builder() : mError(CHIP_ERROR_INCORRECT_STATE), mpWriter(NULL), mOuterContainerType(chip::TLV::kTLVType_NotSpecified) {} +Builder::Builder() : mError(CHIP_ERROR_INCORRECT_STATE), mpWriter(nullptr), mOuterContainerType(chip::TLV::kTLVType_NotSpecified) {} void Builder::Init(chip::TLV::TLVWriter * const apWriter, chip::TLV::TLVType aOuterContainerType) { diff --git a/src/app/util/af-event.cpp b/src/app/util/af-event.cpp index 0ced20d5af59aa..9cc2b8495a71d4 100644 --- a/src/app/util/af-event.cpp +++ b/src/app/util/af-event.cpp @@ -84,7 +84,7 @@ const char * emAfEventStrings[] = { EMBER_AF_GENERATED_EVENT_STRINGS #endif - NULL, + nullptr, }; EmberEventData emAfEvents[] = { @@ -93,7 +93,7 @@ EmberEventData emAfEvents[] = { EMBER_AF_GENERATED_EVENTS #endif - { NULL, NULL } + { nullptr, nullptr } }; void EventControlHandler(chip::System::Layer * systemLayer, void * appState) @@ -103,7 +103,7 @@ void EventControlHandler(chip::System::Layer * systemLayer, void * appState) { control->status = EMBER_EVENT_INACTIVE; - if (control->callback != NULL) + if (control->callback != nullptr) { (control->callback)(control->endpoint); return; @@ -146,7 +146,7 @@ static EmberAfEventContext * findEventContext(EndpointId endpoint, ClusterId clu } } #endif // EMBER_AF_GENERATED_EVENT_CONTEXT - return NULL; + return nullptr; } EmberStatus emberEventControlSetDelayMS(EmberEventControl * control, uint32_t delayMs) @@ -218,7 +218,7 @@ EmberStatus emberAfScheduleTickExtended(EndpointId endpoint, ClusterId clusterId // simulation. EMBER_TEST_ASSERT(emberAfEndpointIsEnabled(endpoint)); - if (context != NULL && emberAfEndpointIsEnabled(endpoint) && + if (context != nullptr && emberAfEndpointIsEnabled(endpoint) && (emberEventControlSetDelayMS(context->eventControl, delayMs) == EMBER_SUCCESS)) { context->pollControl = pollControl; @@ -261,7 +261,7 @@ EmberStatus emberAfScheduleServerTick(EndpointId endpoint, ClusterId clusterId, EmberStatus emberAfDeactivateClusterTick(EndpointId endpoint, ClusterId clusterId, bool isClient) { EmberAfEventContext * context = findEventContext(endpoint, clusterId, isClient); - if (context != NULL) + if (context != nullptr) { emberEventControlSetInactive(context->eventControl); return EMBER_SUCCESS; diff --git a/src/app/util/attribute-size-util.cpp b/src/app/util/attribute-size-util.cpp index c5b7f467598b11..a318befcdc1500 100644 --- a/src/app/util/attribute-size-util.cpp +++ b/src/app/util/attribute-size-util.cpp @@ -75,7 +75,7 @@ uint16_t emberAfAttributeValueSize(ClusterId clusterId, AttributeId attrId, Embe uint16_t dataSize = 0; if (emberAfIsThisDataTypeAStringType(dataType)) { - if (buffer != 0) + if (buffer != nullptr) { if (emberAfIsStringAttributeType(dataType)) { diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 8340282cedf51a..748ac1c84cddf3 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -316,10 +316,10 @@ void emberAfClusterDefaultResponseCallback(EndpointId endpoint, ClusterId cluste uint8_t clientServerMask) { const EmberAfCluster * cluster = emberAfFindCluster(endpoint, clusterId, clientServerMask); - if (cluster != NULL) + if (cluster != nullptr) { EmberAfGenericClusterFunction f = emberAfFindClusterFunction(cluster, CLUSTER_MASK_DEFAULT_RESPONSE_FUNCTION); - if (f != NULL) + if (f != nullptr) { ((EmberAfDefaultResponseFunction) f)(endpoint, commandId, status); } @@ -330,16 +330,16 @@ void emberAfClusterDefaultResponseCallback(EndpointId endpoint, ClusterId cluste void emberAfClusterMessageSentCallback(const MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status) { - if (apsFrame != NULL && message != NULL && msgLen != 0) + if (apsFrame != nullptr && message != nullptr && msgLen != 0) { const EmberAfCluster * cluster = emberAfFindCluster( apsFrame->sourceEndpoint, apsFrame->clusterId, (((message[0] & ZCL_FRAME_CONTROL_DIRECTION_MASK) == ZCL_FRAME_CONTROL_SERVER_TO_CLIENT) ? CLUSTER_MASK_SERVER : CLUSTER_MASK_CLIENT)); - if (cluster != NULL) + if (cluster != nullptr) { EmberAfGenericClusterFunction f = emberAfFindClusterFunction(cluster, CLUSTER_MASK_MESSAGE_SENT_FUNCTION); - if (f != NULL) + if (f != nullptr) { ((EmberAfMessageSentFunction) f)(destination, apsFrame, msgLen, message, status); } @@ -351,10 +351,10 @@ void emberAfClusterMessageSentCallback(const MessageSendDestination & destinatio void emAfClusterAttributeChangedCallback(const app::ConcreteAttributePath & attributePath, uint8_t clientServerMask) { const EmberAfCluster * cluster = emberAfFindCluster(attributePath.mEndpointId, attributePath.mClusterId, clientServerMask); - if (cluster != NULL) + if (cluster != nullptr) { EmberAfGenericClusterFunction f = emberAfFindClusterFunction(cluster, CLUSTER_MASK_ATTRIBUTE_CHANGED_FUNCTION); - if (f != NULL) + if (f != nullptr) { ((EmberAfClusterAttributeChangedCallback) f)(attributePath); } @@ -366,7 +366,7 @@ EmberAfStatus emAfClusterPreAttributeChangedCallback(const app::ConcreteAttribut EmberAfAttributeType attributeType, uint16_t size, uint8_t * value) { const EmberAfCluster * cluster = emberAfFindCluster(attributePath.mEndpointId, attributePath.mClusterId, clientServerMask); - if (cluster == NULL) + if (cluster == nullptr) { return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE; } @@ -376,7 +376,7 @@ EmberAfStatus emAfClusterPreAttributeChangedCallback(const app::ConcreteAttribut // of the call on gcc-arm-none-eabi-9-2019-q4-major EmberAfClusterPreAttributeChangedCallback f = (EmberAfClusterPreAttributeChangedCallback)( emberAfFindClusterFunction(cluster, CLUSTER_MASK_PRE_ATTRIBUTE_CHANGED_FUNCTION)); - if (f != NULL) + if (f != nullptr) { status = f(attributePath, attributeType, size, value); } @@ -393,7 +393,7 @@ static void initializeEndpoint(EmberAfDefinedEndpoint * definedEndpoint) EmberAfGenericClusterFunction f; emberAfClusterInitCallback(definedEndpoint->endpoint, cluster->clusterId); f = emberAfFindClusterFunction(cluster, CLUSTER_MASK_INIT_FUNCTION); - if (f != NULL) + if (f != nullptr) { ((EmberAfInitFunction) f)(definedEndpoint->endpoint); } @@ -417,16 +417,16 @@ void emAfCallInits(void) const EmberAfAttributeMetadata * emberAfLocateAttributeMetadata(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask) { - const EmberAfAttributeMetadata * metadata = NULL; + const EmberAfAttributeMetadata * metadata = nullptr; EmberAfAttributeSearchRecord record; record.endpoint = endpoint; record.clusterId = clusterId; record.clusterMask = mask; record.attributeId = attributeId; emAfReadOrWriteAttribute(&record, &metadata, - NULL, // buffer - 0, // buffer size - false); // write? + nullptr, // buffer + 0, // buffer size + false); // write? return metadata; } @@ -491,7 +491,7 @@ static EmberAfStatus typeSensitiveMemCopy(ClusterId clusterId, uint8_t * dest, u { return EMBER_ZCL_STATUS_INSUFFICIENT_SPACE; } - if (src == NULL) + if (src == nullptr) { memset(dest, 0, am->size); } @@ -577,7 +577,7 @@ EmberAfStatus emAfReadOrWriteAttribute(EmberAfAttributeSearchRecord * attRecord, if (emAfMatchAttribute(cluster, am, attRecord)) { // Got the attribute // If passed metadata location is not null, populate - if (metadata != NULL) + if (metadata != nullptr) { *metadata = am; } @@ -599,7 +599,7 @@ EmberAfStatus emAfReadOrWriteAttribute(EmberAfAttributeSearchRecord * attRecord, } else { - if (buffer == NULL) + if (buffer == nullptr) { return EMBER_ZCL_STATUS_SUCCESS; } @@ -698,7 +698,7 @@ const EmberAfCluster * emberAfFindClusterInType(const EmberAfEndpointType * endp } } - return NULL; + return nullptr; } uint8_t emberAfClusterIndex(EndpointId endpoint, ClusterId clusterId, EmberAfClusterMask mask) @@ -711,7 +711,7 @@ uint8_t emberAfClusterIndex(EndpointId endpoint, ClusterId clusterId, EmberAfClu { const EmberAfEndpointType * endpointType = emAfEndpoints[ep].endpointType; uint8_t index = 0xFF; - if (emberAfFindClusterInType(endpointType, clusterId, mask, &index) != NULL) + if (emberAfFindClusterInType(endpointType, clusterId, mask, &index) != nullptr) { return index; } @@ -724,19 +724,19 @@ uint8_t emberAfClusterIndex(EndpointId endpoint, ClusterId clusterId, EmberAfClu // cluster on it. bool emberAfContainsCluster(EndpointId endpoint, ClusterId clusterId) { - return (emberAfFindCluster(endpoint, clusterId, 0) != NULL); + return (emberAfFindCluster(endpoint, clusterId, 0) != nullptr); } // Returns whether the given endpoint has the server of the given cluster on it. bool emberAfContainsServer(EndpointId endpoint, ClusterId clusterId) { - return (emberAfFindCluster(endpoint, clusterId, CLUSTER_MASK_SERVER) != NULL); + return (emberAfFindCluster(endpoint, clusterId, CLUSTER_MASK_SERVER) != nullptr); } // Returns whether the given endpoint has the client of the given cluster on it. bool emberAfContainsClient(EndpointId endpoint, ClusterId clusterId) { - return (emberAfFindCluster(endpoint, clusterId, CLUSTER_MASK_CLIENT) != NULL); + return (emberAfFindCluster(endpoint, clusterId, CLUSTER_MASK_CLIENT) != nullptr); } // This will find the first server that has the clusterId given from the index of endpoint. @@ -789,7 +789,7 @@ const EmberAfCluster * emberAfFindCluster(EndpointId endpoint, ClusterId cluster uint16_t ep = emberAfIndexFromEndpoint(endpoint); if (ep == 0xFFFF) { - return NULL; + return nullptr; } return emberAfFindClusterInType(emAfEndpoints[ep].endpointType, clusterId, mask); @@ -804,7 +804,7 @@ const EmberAfCluster * emberAfFindClusterIncludingDisabledEndpoints(EndpointId e { return emberAfFindClusterInType(emAfEndpoints[ep].endpointType, clusterId, mask); } - return NULL; + return nullptr; } // Server wrapper for findClusterEndpointIndex @@ -824,7 +824,7 @@ static uint16_t findClusterEndpointIndex(EndpointId endpoint, ClusterId clusterI { uint16_t i, epi = 0; - if (emberAfFindCluster(endpoint, clusterId, mask) == NULL) + if (emberAfFindCluster(endpoint, clusterId, mask) == nullptr) { return 0xFFFF; } @@ -836,7 +836,7 @@ static uint16_t findClusterEndpointIndex(EndpointId endpoint, ClusterId clusterI break; } epi = static_cast( - epi + ((emberAfFindClusterIncludingDisabledEndpoints(emAfEndpoints[i].endpoint, clusterId, mask) != NULL) ? 1 : 0)); + epi + ((emberAfFindClusterIncludingDisabledEndpoints(emAfEndpoints[i].endpoint, clusterId, mask) != nullptr) ? 1 : 0)); } return epi; @@ -1002,7 +1002,7 @@ uint8_t emberAfClusterCount(EndpointId endpoint, bool server) uint8_t emberAfClusterCountByIndex(uint16_t endpointIndex, bool server) { const EmberAfDefinedEndpoint * de = &(emAfEndpoints[endpointIndex]); - if (de->endpointType == NULL) + if (de->endpointType == nullptr) { return 0; } @@ -1054,13 +1054,13 @@ const EmberAfCluster * emberAfGetClusterByIndex(EndpointId endpoint, uint8_t clu if (endpointIndex == 0xFFFF) { - return NULL; + return nullptr; } definedEndpoint = &(emAfEndpoints[endpointIndex]); if (clusterIndex >= definedEndpoint->endpointType->clusterCount) { - return NULL; + return nullptr; } return &(definedEndpoint->endpointType->cluster[clusterIndex]); } @@ -1086,7 +1086,7 @@ const EmberAfCluster * emberAfGetNthCluster(EndpointId endpoint, uint8_t n, bool if (index == 0xFFFF) { - return NULL; + return nullptr; } de = &(emAfEndpoints[index]); @@ -1103,7 +1103,7 @@ const EmberAfCluster * emberAfGetNthCluster(EndpointId endpoint, uint8_t n, bool c++; } } - return NULL; + return nullptr; } // Returns the cluster id of Nth server or client cluster, @@ -1133,7 +1133,7 @@ uint8_t emberAfGetClustersFromEndpoint(EndpointId endpoint, ClusterId * clusterL for (i = 0; i < clusterCount; i++) { cluster = emberAfGetNthCluster(endpoint, i, server); - clusterList[i] = (cluster == NULL ? 0xFFFF : cluster->clusterId); + clusterList[i] = (cluster == nullptr ? 0xFFFF : cluster->clusterId); } return clusterCount; } @@ -1267,7 +1267,7 @@ void emAfLoadAttributeDefaults(EndpointId endpoint, bool ignoreStorage, Optional } emAfReadOrWriteAttribute(&record, - NULL, // metadata - unused + nullptr, // metadata - unused ptr, 0, // buffer size - unused true); // write? @@ -1341,7 +1341,7 @@ EmberAfGenericClusterFunction emberAfFindClusterFunction(const EmberAfCluster * if ((cluster->mask & functionMask) == 0) { - return NULL; + return nullptr; } while (mask < functionMask) diff --git a/src/app/util/attribute-table.cpp b/src/app/util/attribute-table.cpp index 617e02b8fbb2e4..13e2efc42bfe83 100644 --- a/src/app/util/attribute-table.cpp +++ b/src/app/util/attribute-table.cpp @@ -127,13 +127,13 @@ EmberAfStatus emberAfReadAttribute(EndpointId endpoint, ClusterId cluster, Attri EmberAfStatus emberAfReadServerAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr, uint16_t readLength) { - return emAfReadAttribute(endpoint, cluster, attributeID, CLUSTER_MASK_SERVER, dataPtr, readLength, NULL); + return emAfReadAttribute(endpoint, cluster, attributeID, CLUSTER_MASK_SERVER, dataPtr, readLength, nullptr); } EmberAfStatus emberAfReadClientAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t * dataPtr, uint16_t readLength) { - return emAfReadAttribute(endpoint, cluster, attributeID, CLUSTER_MASK_CLIENT, dataPtr, readLength, NULL); + return emAfReadAttribute(endpoint, cluster, attributeID, CLUSTER_MASK_CLIENT, dataPtr, readLength, nullptr); } static void emberAfAttributeDecodeAndPrintCluster(ClusterId cluster) @@ -185,7 +185,7 @@ void emberAfPrintAttributeTable(void) emberAfAttributesFlush(); status = emAfReadAttribute(ep->endpoint, cluster->clusterId, metaData->attributeId, (emberAfAttributeIsClient(metaData) ? CLUSTER_MASK_CLIENT : CLUSTER_MASK_SERVER), data, - ATTRIBUTE_LARGEST, NULL); + ATTRIBUTE_LARGEST, nullptr); if (status == EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE) { emberAfAttributesPrintln("Unsupported"); @@ -299,19 +299,19 @@ static bool IsNullValue(const uint8_t * data, uint16_t dataLen, bool isAttribute EmberAfStatus emAfWriteAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t mask, uint8_t * data, EmberAfAttributeType dataType, bool overrideReadOnlyAndDataType, bool justTest) { - const EmberAfAttributeMetadata * metadata = NULL; + const EmberAfAttributeMetadata * metadata = nullptr; EmberAfAttributeSearchRecord record; record.endpoint = endpoint; record.clusterId = cluster; record.clusterMask = mask; record.attributeId = attributeID; emAfReadOrWriteAttribute(&record, &metadata, - NULL, // buffer - 0, // buffer size - false); // write? + nullptr, // buffer + 0, // buffer size + false); // write? // if we dont support that attribute - if (metadata == NULL) + if (metadata == nullptr) { emberAfAttributesPrintln("%pep %x clus " ChipLogFormatMEI " attr " ChipLogFormatMEI " not supported", "WRITE ERR: ", endpoint, ChipLogValueMEI(cluster), ChipLogValueMEI(attributeID)); @@ -402,7 +402,7 @@ EmberAfStatus emAfWriteAttribute(EndpointId endpoint, ClusterId cluster, Attribu // write the attribute status = emAfReadOrWriteAttribute(&record, - NULL, // metadata + nullptr, // metadata data, 0, // buffer size - unused true); // write? @@ -444,7 +444,7 @@ EmberAfStatus emAfWriteAttribute(EndpointId endpoint, ClusterId cluster, Attribu EmberAfStatus emAfReadAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t mask, uint8_t * dataPtr, uint16_t readLength, EmberAfAttributeType * dataType) { - const EmberAfAttributeMetadata * metadata = NULL; + const EmberAfAttributeMetadata * metadata = nullptr; EmberAfAttributeSearchRecord record; EmberAfStatus status; record.endpoint = endpoint; @@ -457,7 +457,7 @@ EmberAfStatus emAfReadAttribute(EndpointId endpoint, ClusterId cluster, Attribut if (status == EMBER_ZCL_STATUS_SUCCESS) { // It worked! If the user asked for the type, set it before returning. - if (dataType != NULL) + if (dataType != nullptr) { (*dataType) = metadata->attributeType; } diff --git a/src/app/util/client-api.cpp b/src/app/util/client-api.cpp index cb2d25038a3e8d..79f1c7243b694e 100644 --- a/src/app/util/client-api.cpp +++ b/src/app/util/client-api.cpp @@ -45,14 +45,14 @@ using namespace chip; -uint8_t * emAfZclBuffer = NULL; +uint8_t * emAfZclBuffer = nullptr; uint16_t emAfZclBufferLen = 0; // Pointer to where this API should put the length -uint16_t * emAfResponseLengthPtr = NULL; +uint16_t * emAfResponseLengthPtr = nullptr; // Pointer to where the API should put the cluster ID -EmberApsFrame * emAfCommandApsFrame = NULL; +EmberApsFrame * emAfCommandApsFrame = nullptr; ///////////////// @@ -101,7 +101,7 @@ static uint16_t vFillBuffer(uint8_t * buffer, uint16_t bufferLen, uint8_t frameC char cmd; value = 0; valueLen = 0; - data = 0; + data = nullptr; cmd = format[i]; if (cmd <= 's') { @@ -231,7 +231,7 @@ static uint16_t vFillBuffer(uint8_t * buffer, uint16_t bufferLen, uint8_t frameC // explicit check. if (dataLen != 0) { - if (data == NULL) + if (data == nullptr) { emberAfDebugPrintln("ERR: Missing data for %d bytes for format '%c'", dataLen, cmd); return 0; diff --git a/src/app/util/message.cpp b/src/app/util/message.cpp index 562211966d5938..97d744ff389296 100644 --- a/src/app/util/message.cpp +++ b/src/app/util/message.cpp @@ -73,7 +73,7 @@ void emberAfClearResponseData(void) emberAfResponseType = ZCL_UTIL_RESP_NORMAL; // To prevent accidentally sending to someone else, // set the destination to ourselves. - emberAfResponseDestination = 0 /* emberAfGetNodeId() */; + emberAfResponseDestination = nullptr /* emberAfGetNodeId() */; memset(appResponseData, 0, EMBER_AF_RESPONSE_BUFFER_LEN); appResponseLength = 0; memset(&emberAfResponseApsFrame, 0, sizeof(EmberApsFrame)); @@ -90,7 +90,7 @@ uint8_t * emberAfPutInt8uInResp(uint8_t value) return &appResponseData[appResponseLength - 1]; } - return NULL; + return nullptr; } uint16_t * emberAfPutInt16uInResp(uint16_t value) @@ -103,7 +103,7 @@ uint16_t * emberAfPutInt16uInResp(uint16_t value) return (uint16_t *) low; } - return NULL; + return nullptr; } uint32_t * emberAfPutInt32uInResp(uint32_t value) @@ -118,7 +118,7 @@ uint32_t * emberAfPutInt32uInResp(uint32_t value) return (uint32_t *) a; } - return NULL; + return nullptr; } uint32_t * emberAfPutInt24uInResp(uint32_t value) @@ -132,7 +132,7 @@ uint32_t * emberAfPutInt24uInResp(uint32_t value) return (uint32_t *) a; } - return NULL; + return nullptr; } uint8_t * emberAfPutBlockInResp(const uint8_t * data, uint16_t length) @@ -144,7 +144,7 @@ uint8_t * emberAfPutBlockInResp(const uint8_t * data, uint16_t length) return &appResponseData[appResponseLength - length]; } - return NULL; + return nullptr; } uint8_t * emberAfPutStringInResp(const uint8_t * buffer) @@ -165,7 +165,7 @@ uint8_t * emberAfPutDateInResp(EmberAfDate * value) return a; } - return NULL; + return nullptr; } void emberAfPutInt16sInResp(int16_t value) diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index 8a1149159692bf..279495dd8ef4e0 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -74,8 +74,8 @@ uint32_t afNumPktsSent; #endif const EmberAfClusterName zclClusterNames[] = { - CLUSTER_IDS_TO_NAMES // defined in print-cluster.h - { ZCL_NULL_CLUSTER_ID, EMBER_AF_NULL_MANUFACTURER_CODE, NULL }, // terminator + CLUSTER_IDS_TO_NAMES // defined in print-cluster.h + { ZCL_NULL_CLUSTER_ID, EMBER_AF_NULL_MANUFACTURER_CODE, nullptr }, // terminator }; // A pointer to the current command being processed @@ -312,7 +312,7 @@ void emberAfDecodeAndPrintCluster(ClusterId cluster) // for references to the standard library. uint16_t emberAfGetMfgCodeFromCurrentCommand(void) { - if (emberAfCurrentCommand() != NULL) + if (emberAfCurrentCommand() != nullptr) { return emberAfCurrentCommand()->mfgCode; } @@ -359,7 +359,7 @@ EmberAfRetryOverride emberAfGetRetryOverride(void) void emAfApplyRetryOverride(EmberApsOption * options) { - if (options == NULL) + if (options == nullptr) { return; } @@ -393,7 +393,7 @@ EmberAfDisableDefaultResponse emberAfGetDisableDefaultResponse(void) void emAfApplyDisableDefaultResponse(uint8_t * frame_control) { - if (frame_control == NULL) + if (frame_control == nullptr) { return; } @@ -457,7 +457,7 @@ void emberAfCopyInt32u(uint8_t * data, uint16_t index, uint32_t x) void emberAfCopyString(uint8_t * dest, const uint8_t * src, size_t size) { - if (src == NULL) + if (src == nullptr) { dest[0] = 0; // Zero out the length of string } @@ -480,7 +480,7 @@ void emberAfCopyString(uint8_t * dest, const uint8_t * src, size_t size) void emberAfCopyLongString(uint8_t * dest, const uint8_t * src, size_t size) { - if (src == NULL) + if (src == nullptr) { dest[0] = dest[1] = 0; // Zero out the length of string } @@ -525,7 +525,7 @@ int8_t emberAfCompareValues(const uint8_t * val1, const uint8_t * val2, uint16_t for (i = 0; i < len; i++) { - j = (val1 == NULL ? 0 : (EM_BIG_ENDIAN ? val1[i] : val1[(len - 1) - i])); + j = (val1 == nullptr ? 0 : (EM_BIG_ENDIAN ? val1[i] : val1[(len - 1) - i])); accum1 |= j << (8 * (len - 1 - i)); k = (EM_BIG_ENDIAN ? val2[i] : val2[(len - 1) - i]); @@ -567,7 +567,7 @@ int8_t emberAfCompareValues(const uint8_t * val1, const uint8_t * val2, uint16_t { // regular unsigned number comparison for (i = 0; i < len; i++) { - j = (val1 == NULL ? 0 : (EM_BIG_ENDIAN ? val1[i] : val1[(len - 1) - i])); + j = (val1 == nullptr ? 0 : (EM_BIG_ENDIAN ? val1[i] : val1[(len - 1) - i])); k = (EM_BIG_ENDIAN ? val2[i] : val2[(len - 1) - i]); if (j > k) @@ -638,7 +638,7 @@ uint8_t emberAfAppendCharacters(uint8_t * zclString, uint8_t zclStringMaxLen, co uint8_t curLen; uint8_t charsToWrite; - if ((zclString == NULL) || (zclStringMaxLen == 0) || (appendingChars == NULL) || (appendingCharsLen == 0)) + if ((zclString == nullptr) || (zclStringMaxLen == 0) || (appendingChars == nullptr) || (appendingCharsLen == 0)) { return 0; } diff --git a/src/ble/BleConfig.h b/src/ble/BleConfig.h index 70340bfff0cfe5..1c514dc21b5807 100644 --- a/src/ble/BleConfig.h +++ b/src/ble/BleConfig.h @@ -122,7 +122,7 @@ * */ #ifndef BLE_CONNECTION_UNINITIALIZED -#define BLE_CONNECTION_UNINITIALIZED NULL +#define BLE_CONNECTION_UNINITIALIZED nullptr #endif // BLE_CONNECTION_UNINITIALIZED /** diff --git a/src/crypto/CHIPCryptoPALOpenSSL.cpp b/src/crypto/CHIPCryptoPALOpenSSL.cpp index 814b90a56980f5..fecd6296b1b4d4 100644 --- a/src/crypto/CHIPCryptoPALOpenSSL.cpp +++ b/src/crypto/CHIPCryptoPALOpenSSL.cpp @@ -1525,9 +1525,9 @@ static void security_free_cert_list(X509_LIST * certs) CHIP_ERROR LoadCertsFromPKCS7(const char * pkcs7, X509DerCertificate * x509list, uint32_t * max_certs) { CHIP_ERROR err = CHIP_NO_ERROR; - X509_LIST * certs = NULL; - BIO * bio_cert = NULL; - PKCS7 * p7 = NULL; + X509_LIST * certs = nullptr; + BIO * bio_cert = nullptr; + PKCS7 * p7 = nullptr; int p7_type = 0; VerifyOrExit(x509list != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); @@ -1535,7 +1535,7 @@ CHIP_ERROR LoadCertsFromPKCS7(const char * pkcs7, X509DerCertificate * x509list, bio_cert = BIO_new_mem_buf(pkcs7, -1); - p7 = PEM_read_bio_PKCS7(bio_cert, NULL, NULL, NULL); + p7 = PEM_read_bio_PKCS7(bio_cert, nullptr, nullptr, nullptr); VerifyOrExit(p7 != nullptr, err = CHIP_ERROR_WRONG_CERT_TYPE); p7_type = OBJ_obj2nid(p7->type); @@ -1548,7 +1548,7 @@ CHIP_ERROR LoadCertsFromPKCS7(const char * pkcs7, X509DerCertificate * x509list, certs = p7->d.signed_and_enveloped->cert; } - VerifyOrExit(certs != NULL, err = CHIP_ERROR_WRONG_CERT_TYPE); + VerifyOrExit(certs != nullptr, err = CHIP_ERROR_WRONG_CERT_TYPE); VerifyOrExit(static_cast(sk_X509_num(certs)) <= *max_certs, err = CHIP_ERROR_WRONG_CERT_TYPE); *max_certs = static_cast(sk_X509_num(certs)); @@ -1579,16 +1579,16 @@ CHIP_ERROR LoadCertsFromPKCS7(const char * pkcs7, X509DerCertificate * x509list, CHIP_ERROR LoadCertFromPKCS7(const char * pkcs7, X509DerCertificate * x509list, uint32_t n_cert) { CHIP_ERROR err = CHIP_NO_ERROR; - X509_LIST * certs = NULL; - BIO * bio_cert = NULL; - PKCS7 * p7 = NULL; + X509_LIST * certs = nullptr; + BIO * bio_cert = nullptr; + PKCS7 * p7 = nullptr; int p7_type = 0; VerifyOrExit(x509list != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); bio_cert = BIO_new_mem_buf(pkcs7, -1); - p7 = PEM_read_bio_PKCS7(bio_cert, NULL, NULL, NULL); + p7 = PEM_read_bio_PKCS7(bio_cert, nullptr, nullptr, nullptr); VerifyOrExit(p7 != nullptr, err = CHIP_ERROR_WRONG_CERT_TYPE); p7_type = OBJ_obj2nid(p7->type); @@ -1601,7 +1601,7 @@ CHIP_ERROR LoadCertFromPKCS7(const char * pkcs7, X509DerCertificate * x509list, certs = p7->d.signed_and_enveloped->cert; } - VerifyOrExit(certs != NULL, err = CHIP_ERROR_WRONG_CERT_TYPE); + VerifyOrExit(certs != nullptr, err = CHIP_ERROR_WRONG_CERT_TYPE); VerifyOrExit(n_cert < static_cast(sk_X509_num(certs)), err = CHIP_ERROR_INVALID_ARGUMENT); certs = X509_chain_up_ref(certs); @@ -1629,16 +1629,16 @@ CHIP_ERROR LoadCertFromPKCS7(const char * pkcs7, X509DerCertificate * x509list, CHIP_ERROR GetNumberOfCertsFromPKCS7(const char * pkcs7, uint32_t * n_certs) { CHIP_ERROR err = CHIP_NO_ERROR; - X509_LIST * certs = NULL; - BIO * bio_cert = NULL; - PKCS7 * p7 = NULL; + X509_LIST * certs = nullptr; + BIO * bio_cert = nullptr; + PKCS7 * p7 = nullptr; int p7_type = 0; VerifyOrExit(n_certs != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); bio_cert = BIO_new_mem_buf(pkcs7, -1); - p7 = PEM_read_bio_PKCS7(bio_cert, NULL, NULL, NULL); + p7 = PEM_read_bio_PKCS7(bio_cert, nullptr, nullptr, nullptr); VerifyOrExit(p7 != nullptr, err = CHIP_ERROR_WRONG_CERT_TYPE); p7_type = OBJ_obj2nid(p7->type); @@ -1651,7 +1651,7 @@ CHIP_ERROR GetNumberOfCertsFromPKCS7(const char * pkcs7, uint32_t * n_certs) certs = p7->d.signed_and_enveloped->cert; } - VerifyOrExit(certs != NULL, err = CHIP_ERROR_WRONG_CERT_TYPE); + VerifyOrExit(certs != nullptr, err = CHIP_ERROR_WRONG_CERT_TYPE); *n_certs = static_cast(sk_X509_num(certs)); @@ -1689,25 +1689,25 @@ CHIP_ERROR ValidateCertificateChain(const uint8_t * rootCertificate, size_t root verifyCtx = X509_STORE_CTX_new(); VerifyOrExit(verifyCtx != nullptr, (result = CertificateChainValidationResult::kNoMemory, err = CHIP_ERROR_NO_MEMORY)); - x509RootCertificate = d2i_X509(NULL, &rootCertificate, static_cast(rootCertificateLen)); + x509RootCertificate = d2i_X509(nullptr, &rootCertificate, static_cast(rootCertificateLen)); VerifyOrExit(x509RootCertificate != nullptr, (result = CertificateChainValidationResult::kRootFormatInvalid, err = CHIP_ERROR_INTERNAL)); status = X509_STORE_add_cert(store, x509RootCertificate); VerifyOrExit(status == 1, (result = CertificateChainValidationResult::kInternalFrameworkError, err = CHIP_ERROR_INTERNAL)); - x509CACertificate = d2i_X509(NULL, &caCertificate, static_cast(caCertificateLen)); + x509CACertificate = d2i_X509(nullptr, &caCertificate, static_cast(caCertificateLen)); VerifyOrExit(x509CACertificate != nullptr, (result = CertificateChainValidationResult::kICAFormatInvalid, err = CHIP_ERROR_INTERNAL)); status = X509_STORE_add_cert(store, x509CACertificate); VerifyOrExit(status == 1, (result = CertificateChainValidationResult::kInternalFrameworkError, err = CHIP_ERROR_INTERNAL)); - x509LeafCertificate = d2i_X509(NULL, &leafCertificate, static_cast(leafCertificateLen)); + x509LeafCertificate = d2i_X509(nullptr, &leafCertificate, static_cast(leafCertificateLen)); VerifyOrExit(x509LeafCertificate != nullptr, (result = CertificateChainValidationResult::kLeafFormatInvalid, err = CHIP_ERROR_INTERNAL)); - status = X509_STORE_CTX_init(verifyCtx, store, x509LeafCertificate, NULL); + status = X509_STORE_CTX_init(verifyCtx, store, x509LeafCertificate, nullptr); VerifyOrExit(status == 1, (result = CertificateChainValidationResult::kInternalFrameworkError, err = CHIP_ERROR_INTERNAL)); status = X509_verify_cert(verifyCtx); @@ -1740,10 +1740,11 @@ CHIP_ERROR IsCertificateValidAtIssuance(const ByteSpan & referenceCertificate, c VerifyOrReturnError(!referenceCertificate.empty() && !toBeEvaluatedCertificate.empty(), CHIP_ERROR_INVALID_ARGUMENT); - x509ReferenceCertificate = d2i_X509(NULL, &pReferenceCertificate, static_cast(referenceCertificate.size())); + x509ReferenceCertificate = d2i_X509(nullptr, &pReferenceCertificate, static_cast(referenceCertificate.size())); VerifyOrExit(x509ReferenceCertificate != nullptr, error = CHIP_ERROR_NO_MEMORY); - x509toBeEvaluatedCertificate = d2i_X509(NULL, &pToBeEvaluatedCertificate, static_cast(toBeEvaluatedCertificate.size())); + x509toBeEvaluatedCertificate = + d2i_X509(nullptr, &pToBeEvaluatedCertificate, static_cast(toBeEvaluatedCertificate.size())); VerifyOrExit(x509toBeEvaluatedCertificate != nullptr, error = CHIP_ERROR_NO_MEMORY); refNotBeforeTime = X509_get_notBefore(x509ReferenceCertificate); @@ -1777,7 +1778,7 @@ CHIP_ERROR IsCertificateValidAtCurrentTime(const ByteSpan & certificate) VerifyOrReturnError(!certificate.empty(), CHIP_ERROR_INVALID_ARGUMENT); - x509Certificate = d2i_X509(NULL, &pCertificate, static_cast(certificate.size())); + x509Certificate = d2i_X509(nullptr, &pCertificate, static_cast(certificate.size())); VerifyOrExit(x509Certificate != nullptr, error = CHIP_ERROR_NO_MEMORY); time = X509_get_notBefore(x509Certificate); @@ -1811,7 +1812,7 @@ CHIP_ERROR ExtractPubkeyFromX509Cert(const ByteSpan & certificate, Crypto::P256P unsigned char ** ppPubkey = &pPubkey; int pkeyLen; - x509certificate = d2i_X509(NULL, ppCertificate, static_cast(certificate.size())); + x509certificate = d2i_X509(nullptr, ppCertificate, static_cast(certificate.size())); VerifyOrExit(x509certificate != nullptr, err = CHIP_ERROR_NO_MEMORY); pkey = X509_get_pubkey(x509certificate); @@ -1819,7 +1820,7 @@ CHIP_ERROR ExtractPubkeyFromX509Cert(const ByteSpan & certificate, Crypto::P256P VerifyOrExit(EVP_PKEY_base_id(pkey) == EVP_PKEY_EC, err = CHIP_ERROR_INTERNAL); VerifyOrExit(EVP_PKEY_bits(pkey) == 256, err = CHIP_ERROR_INTERNAL); - pkeyLen = i2d_PublicKey(pkey, NULL); + pkeyLen = i2d_PublicKey(pkey, nullptr); VerifyOrExit(pkeyLen == static_cast(pubkey.Length()), err = CHIP_ERROR_INTERNAL); VerifyOrExit(i2d_PublicKey(pkey, ppPubkey) == pkeyLen, err = CHIP_ERROR_INTERNAL); @@ -1841,7 +1842,7 @@ CHIP_ERROR ExtractKIDFromX509Cert(bool isSKID, const ByteSpan & certificate, Mut const unsigned char ** ppCertificate = &pCertificate; const ASN1_OCTET_STRING * kidString = nullptr; - x509certificate = d2i_X509(NULL, ppCertificate, static_cast(certificate.size())); + x509certificate = d2i_X509(nullptr, ppCertificate, static_cast(certificate.size())); VerifyOrExit(x509certificate != nullptr, err = CHIP_ERROR_NO_MEMORY); kidString = isSKID ? X509_get0_subject_key_id(x509certificate) : X509_get0_authority_key_id(x509certificate); @@ -1886,7 +1887,7 @@ CHIP_ERROR ExtractDNAttributeFromX509Cert(const char * oidString, const ByteSpan VerifyOrReturnError(oidStringSize == sOidStringSize, CHIP_ERROR_INVALID_ARGUMENT); - x509certificate = d2i_X509(NULL, &pCertificate, static_cast(certificate.size())); + x509certificate = d2i_X509(nullptr, &pCertificate, static_cast(certificate.size())); VerifyOrExit(x509certificate != nullptr, err = CHIP_ERROR_NO_MEMORY); subject = X509_get_subject_name(x509certificate); diff --git a/src/lib/core/CHIPTLVUpdater.cpp b/src/lib/core/CHIPTLVUpdater.cpp index c9d489072cb5d5..a41abc1532843e 100644 --- a/src/lib/core/CHIPTLVUpdater.cpp +++ b/src/lib/core/CHIPTLVUpdater.cpp @@ -63,7 +63,7 @@ CHIP_ERROR TLVUpdater::Init(TLVReader & aReader, uint32_t freeLen) uint32_t readDataLen = aReader.GetLengthRead(); // TLVUpdater does not support backing stores yet - VerifyOrReturnError(aReader.mBackingStore == 0, CHIP_ERROR_NOT_IMPLEMENTED); + VerifyOrReturnError(aReader.mBackingStore == nullptr, CHIP_ERROR_NOT_IMPLEMENTED); // TLVReader should point to a non-NULL buffer VerifyOrReturnError(buf != nullptr, CHIP_ERROR_INVALID_ARGUMENT); @@ -84,7 +84,7 @@ CHIP_ERROR TLVUpdater::Init(TLVReader & aReader, uint32_t freeLen) memmove(buf + freeLen, buf, remainingDataLen); // Initialize the internal reader object - mUpdaterReader.mBackingStore = 0; + mUpdaterReader.mBackingStore = nullptr; mUpdaterReader.mReadPoint = buf + freeLen; mUpdaterReader.mBufEnd = buf + freeLen + remainingDataLen; mUpdaterReader.mLenRead = readDataLen; @@ -99,7 +99,7 @@ CHIP_ERROR TLVUpdater::Init(TLVReader & aReader, uint32_t freeLen) mUpdaterReader.AppData = aReader.AppData; // Initialize the internal writer object - mUpdaterWriter.mBackingStore = 0; + mUpdaterWriter.mBackingStore = nullptr; mUpdaterWriter.mBufStart = buf - readDataLen; mUpdaterWriter.mWritePoint = buf; mUpdaterWriter.mRemainingLen = freeLen; diff --git a/src/lib/support/UnitTestUtils.cpp b/src/lib/support/UnitTestUtils.cpp index a5435fe425cd7d..c63bd5be015596 100644 --- a/src/lib/support/UnitTestUtils.cpp +++ b/src/lib/support/UnitTestUtils.cpp @@ -75,7 +75,7 @@ void SleepMillis(uint64_t millisecs) uint64_t TimeMonotonicMillis() { - return static_cast(time(NULL) * 1000); + return static_cast(time(nullptr) * 1000); } #endif diff --git a/src/platform/Linux/ConfigurationManagerImpl.cpp b/src/platform/Linux/ConfigurationManagerImpl.cpp index c0f997ef1dd7e9..fed2f6d723a56f 100644 --- a/src/platform/Linux/ConfigurationManagerImpl.cpp +++ b/src/platform/Linux/ConfigurationManagerImpl.cpp @@ -121,12 +121,12 @@ CHIP_ERROR ConfigurationManagerImpl::Init() CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) { - struct ifaddrs * addresses = NULL; + struct ifaddrs * addresses = nullptr; CHIP_ERROR error = CHIP_NO_ERROR; bool found = false; VerifyOrExit(getifaddrs(&addresses) == 0, error = CHIP_ERROR_INTERNAL); - for (auto addr = addresses; addr != NULL; addr = addr->ifa_next) + for (auto addr = addresses; addr != nullptr; addr = addr->ifa_next) { if ((addr->ifa_addr) && (addr->ifa_addr->sa_family == AF_PACKET) && strncmp(addr->ifa_name, "lo", IFNAMSIZ) != 0) { diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index c8ae0a77878300..0d6d4de61f427b 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -283,7 +283,7 @@ CHIP_ERROR ConnectivityManagerImpl::_SetWiFiAPMode(WiFiAPMode val) ChipLogProgress(DeviceLayer, "WiFi AP mode change: %s -> %s", WiFiAPModeToStr(mWiFiAPMode), WiFiAPModeToStr(val)); mWiFiAPMode = val; - DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, NULL); + DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, nullptr); } exit: @@ -296,7 +296,7 @@ void ConnectivityManagerImpl::_DemandStartWiFiAP() { ChipLogProgress(DeviceLayer, "wpa_supplicant: Demand start WiFi AP"); mLastAPDemandTime = System::SystemClock().GetMonotonicTimestamp(); - DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, NULL); + DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, nullptr); } else { @@ -310,7 +310,7 @@ void ConnectivityManagerImpl::_StopOnDemandWiFiAP() { ChipLogProgress(DeviceLayer, "wpa_supplicant: Demand stop WiFi AP"); mLastAPDemandTime = System::Clock::kZero; - DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, NULL); + DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, nullptr); } else { @@ -332,7 +332,7 @@ void ConnectivityManagerImpl::_MaintainOnDemandWiFiAP() void ConnectivityManagerImpl::_SetWiFiAPIdleTimeout(System::Clock::Timeout val) { mWiFiAPIdleTimeout = val; - DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, NULL); + DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, nullptr); } void ConnectivityManagerImpl::UpdateNetworkStatus() @@ -758,7 +758,7 @@ void ConnectivityManagerImpl::DriveAPState() // Compute the amount of idle time before the AP should be deactivated and // arm a timer to fire at that time. System::Clock::Timeout apTimeout = (mLastAPDemandTime + mWiFiAPIdleTimeout) - now; - err = DeviceLayer::SystemLayer().StartTimer(apTimeout, DriveAPState, NULL); + err = DeviceLayer::SystemLayer().StartTimer(apTimeout, DriveAPState, nullptr); SuccessOrExit(err); ChipLogProgress(DeviceLayer, "Next WiFi AP timeout in %" PRIu32 " s", std::chrono::duration_cast(apTimeout).count()); diff --git a/src/platform/Linux/DiagnosticDataProviderImpl.cpp b/src/platform/Linux/DiagnosticDataProviderImpl.cpp index b2e0e0cd0948f9..12beb5a882589a 100644 --- a/src/platform/Linux/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Linux/DiagnosticDataProviderImpl.cpp @@ -281,7 +281,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetThreadMetrics(ThreadMetrics ** threadM struct dirent * entry; /* proc available, iterate through tasks... */ - while ((entry = readdir(proc_dir)) != NULL) + while ((entry = readdir(proc_dir)) != nullptr) { if (entry->d_name[0] == '.') continue; diff --git a/src/platform/Linux/DnssdImpl.cpp b/src/platform/Linux/DnssdImpl.cpp index 1d17d67ef2079a..3f5b5258c51344 100644 --- a/src/platform/Linux/DnssdImpl.cpp +++ b/src/platform/Linux/DnssdImpl.cpp @@ -569,7 +569,7 @@ DnssdServiceProtocol GetProtocolInType(const char * type) { const char * deliminator = strrchr(type, '.'); - if (deliminator == NULL) + if (deliminator == nullptr) { ChipLogError(Discovery, "Failed to find protocol in type: %s", type); return DnssdServiceProtocol::kDnssdProtocolUnknown; diff --git a/src/platform/Linux/PlatformManagerImpl.cpp b/src/platform/Linux/PlatformManagerImpl.cpp index 473653d4562c11..e6ad974847a081 100644 --- a/src/platform/Linux/PlatformManagerImpl.cpp +++ b/src/platform/Linux/PlatformManagerImpl.cpp @@ -136,7 +136,7 @@ void PlatformManagerImpl::WiFIIPChangeListener() if (routeInfo->rta_type == IFA_LOCAL) { char name[IFNAMSIZ]; - if (if_indextoname(addressMessage->ifa_index, name) == NULL) + if (if_indextoname(addressMessage->ifa_index, name) == nullptr) { ChipLogError(DeviceLayer, "Error %d when getting the interface name at index: %d", errno, addressMessage->ifa_index); @@ -178,11 +178,11 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack() memset(&action, 0, sizeof(action)); action.sa_handler = SignalHandler; - sigaction(SIGHUP, &action, NULL); - sigaction(SIGTERM, &action, NULL); - sigaction(SIGUSR1, &action, NULL); - sigaction(SIGUSR2, &action, NULL); - sigaction(SIGTSTP, &action, NULL); + sigaction(SIGHUP, &action, nullptr); + sigaction(SIGTERM, &action, nullptr); + sigaction(SIGUSR1, &action, nullptr); + sigaction(SIGUSR2, &action, nullptr); + sigaction(SIGTSTP, &action, nullptr); #if CHIP_WITH_GIO GError * error = nullptr; diff --git a/src/protocols/secure_channel/PASESession.cpp b/src/protocols/secure_channel/PASESession.cpp index 183e99bce604a6..c714f860225ae4 100644 --- a/src/protocols/secure_channel/PASESession.cpp +++ b/src/protocols/secure_channel/PASESession.cpp @@ -609,7 +609,7 @@ CHIP_ERROR PASESession::SendMsg1() constexpr uint8_t kPake1_pA = 1; - ReturnErrorOnFailure(mSpake2p.ComputeRoundOne(NULL, 0, X, &X_len)); + ReturnErrorOnFailure(mSpake2p.ComputeRoundOne(nullptr, 0, X, &X_len)); VerifyOrReturnError(X_len == sizeof(X), CHIP_ERROR_INTERNAL); ReturnErrorOnFailure(tlvWriter.Put(TLV::ContextTag(kPake1_pA), ByteSpan(X))); ReturnErrorOnFailure(tlvWriter.EndContainer(outerContainerType)); diff --git a/src/protocols/secure_channel/RendezvousParameters.h b/src/protocols/secure_channel/RendezvousParameters.h index f08082d2deb725..e81162cb237c29 100644 --- a/src/protocols/secure_channel/RendezvousParameters.h +++ b/src/protocols/secure_channel/RendezvousParameters.h @@ -80,7 +80,7 @@ class RendezvousParameters return *this; } - bool HasConnectionObject() const { return mConnectionObject != 0; } + bool HasConnectionObject() const { return mConnectionObject != BLE_CONNECTION_UNINITIALIZED; } BLE_CONNECTION_OBJECT GetConnectionObject() const { return mConnectionObject; } RendezvousParameters & SetConnectionObject(BLE_CONNECTION_OBJECT connObj) { @@ -101,7 +101,7 @@ class RendezvousParameters #if CONFIG_NETWORK_LAYER_BLE Ble::BleLayer * mBleLayer = nullptr; - BLE_CONNECTION_OBJECT mConnectionObject = 0; + BLE_CONNECTION_OBJECT mConnectionObject = BLE_CONNECTION_UNINITIALIZED; #endif // CONFIG_NETWORK_LAYER_BLE }; diff --git a/src/system/SystemTimer.cpp b/src/system/SystemTimer.cpp index f966564e788418..cb54d075ee23e1 100644 --- a/src/system/SystemTimer.cpp +++ b/src/system/SystemTimer.cpp @@ -41,7 +41,7 @@ namespace System { TimerList::Node * TimerList::Add(TimerList::Node * add) { VerifyOrDie(add != mEarliestTimer); - if (mEarliestTimer == NULL || (add->AwakenTime() < mEarliestTimer->AwakenTime())) + if (mEarliestTimer == nullptr || (add->AwakenTime() < mEarliestTimer->AwakenTime())) { add->mNextTimer = mEarliestTimer; mEarliestTimer = add;