Skip to content

Commit 4b3f58f

Browse files
committed
feat(matter): use C++ nullptr instead of NULL C macro
1 parent 5a2094a commit 4b3f58f

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

libraries/Matter/src/Matter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ constexpr auto k_timeout_seconds = 300;
2828

2929
static bool _matter_has_started = false;
3030
static node::config_t node_config;
31-
static node_t *deviceNode = NULL;
32-
ArduinoMatter::matterEventCB ArduinoMatter::_matterEventCB = NULL;
31+
static node_t *deviceNode = nullptr;
32+
ArduinoMatter::matterEventCB ArduinoMatter::_matterEventCB = nullptr;
3333

3434
// This callback is called for every attribute update. The callback implementation shall
3535
// handle the desired attributes and return an appropriate error code. If the attribute
@@ -43,7 +43,7 @@ static esp_err_t app_attribute_update_cb(
4343
switch (type) {
4444
case PRE_UPDATE: // Callback before updating the value in the database
4545
log_v("Attribute update callback: PRE_UPDATE");
46-
if (ep != NULL) {
46+
if (ep != nullptr) {
4747
err = ep->attributeChangeCB(endpoint_id, cluster_id, attribute_id, val) ? ESP_OK : ESP_FAIL;
4848
}
4949
break;
@@ -79,7 +79,7 @@ static esp_err_t app_identification_cb(identification::callback_type_t type, uin
7979
identifyIsActive = false;
8080
log_v("Identification callback: STOP");
8181
}
82-
if (ep != NULL) {
82+
if (ep != nullptr) {
8383
err = ep->endpointIdentifyCB(endpoint_id, identifyIsActive) ? ESP_OK : ESP_FAIL;
8484
}
8585

@@ -124,7 +124,7 @@ static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) {
124124
default: break;
125125
}
126126
// Check if the user-defined callback is set
127-
if (ArduinoMatter::_matterEventCB != NULL) {
127+
if (ArduinoMatter::_matterEventCB != nullptr) {
128128
ArduinoMatter::_matterEventCB(static_cast<ArduinoMatter::matterEvent_t>(event->Type), event);
129129
}
130130
}

libraries/Matter/src/MatterEndPoint.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,30 @@ class MatterEndPoint {
4141
esp_matter::attribute_t *getAttribute(uint32_t cluster_id, uint32_t attribute_id) {
4242
if (endpoint_id == 0) {
4343
log_e("Endpoint ID is not set");
44-
return NULL;
44+
return nullptr;
4545
}
4646
endpoint_t *endpoint = endpoint::get(node::get(), endpoint_id);
47-
if (endpoint == NULL) {
47+
if (endpoint == nullptr) {
4848
log_e("Endpoint [%d] not found", endpoint_id);
49-
return NULL;
49+
return nullptr;
5050
}
5151
cluster_t *cluster = cluster::get(endpoint, cluster_id);
52-
if (cluster == NULL) {
52+
if (cluster == nullptr) {
5353
log_e("Cluster [%d] not found", cluster_id);
54-
return NULL;
54+
return nullptr;
5555
}
5656
esp_matter::attribute_t *attribute = attribute::get(cluster, attribute_id);
57-
if (attribute == NULL) {
57+
if (attribute == nullptr) {
5858
log_e("Attribute [%d] not found", attribute_id);
59-
return NULL;
59+
return nullptr;
6060
}
6161
return attribute;
6262
}
6363

6464
// get the value of an attribute from its cluster id and attribute it
6565
bool getAttributeVal(uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *attrVal) {
6666
esp_matter::attribute_t *attribute = getAttribute(cluster_id, attribute_id);
67-
if (attribute == NULL) {
67+
if (attribute == nullptr) {
6868
return false;
6969
}
7070
if (attribute::get_val(attribute, attrVal) == ESP_OK) {
@@ -78,7 +78,7 @@ class MatterEndPoint {
7878
// set the value of an attribute from its cluster id and attribute it
7979
bool setAttributeVal(uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *attrVal) {
8080
esp_matter::attribute_t *attribute = getAttribute(cluster_id, attribute_id);
81-
if (attribute == NULL) {
81+
if (attribute == nullptr) {
8282
return false;
8383
}
8484
if (attribute::set_val(attribute, attrVal) == ESP_OK) {
@@ -117,6 +117,6 @@ class MatterEndPoint {
117117

118118
protected:
119119
uint16_t endpoint_id = 0;
120-
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
120+
EndPointIdentifyCB _onEndPointIdentifyCB = nullptr;
121121
};
122122
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

0 commit comments

Comments
 (0)