fix(zigbeeEP): review of names and memory allocation#11199
fix(zigbeeEP): review of names and memory allocation#11199
Conversation
👋 Hello SuGlider, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Test Results 76 files 76 suites 13m 45s ⏱️ Results for commit 8e03dd0. ♻️ This comment has been updated with latest results. |
P-R-O-C-H-Y
left a comment
There was a problem hiding this comment.
Looking good at first sight, will test and approve if its working fine :)
|
@me-no-dev | @P-R-O-C-H-Y :: Changes done as discussed today. PTAL. Thanks! |
P-R-O-C-H-Y
left a comment
There was a problem hiding this comment.
LGTM! Tested with HomeAssistant + Light and switch examples. Both working
There was a problem hiding this comment.
Pull Request Overview
This PR revisits memory allocation routines and renames a variable to avoid reserved words.
- Introduces a constant for maximum name length.
- Updates memory allocation in setManufacturerAndModel to use stack arrays.
- Revises the handling of manufacturer and model string pointers in zbReadBasicCluster.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| libraries/Zigbee/src/ZigbeeEP.h | Added a constant ZB_MAX_NAME_LENGTH and updated comments. |
| libraries/Zigbee/src/ZigbeeEP.cpp | Modified memory allocation for name/model handling and adjusted pointer logic. |
Comments suppressed due to low confidence (1)
libraries/Zigbee/src/ZigbeeEP.cpp:39
- Using stack-allocated arrays for zb_name and zb_model may lead to invalid memory references if esp_zb_basic_cluster_add_attr does not copy the data. Consider allocating memory on the heap or ensuring the data is copied safely.
char zb_name[ZB_MAX_NAME_LENGTH + 2];
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
libraries/Zigbee/src/ZigbeeEP.cpp:39
- Using stack-allocated arrays for zb_name and zb_model could lead to undefined behavior if esp_zb_basic_cluster_add_attr does not internally copy the data. Please verify that the attribute addition function safely duplicates the input data or consider switching to dynamic allocation.
char zb_name[ZB_MAX_NAME_LENGTH + 2];
libraries/Zigbee/src/ZigbeeEP.cpp:171
- [nitpick] For consistency with modern C++ conventions, consider using nullptr instead of NULL for pointer comparisons and assignments.
if (_read_manufacturer != NULL) {
Description of Change
Just a general review of memory allocation routines and changing
stringvariable name to avoid using reserved words.Tests scenarios
CI only
Related links
#11196