File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -33,16 +33,18 @@ void ZigbeeEP::setVersion(uint8_t version) {
3333}
3434
3535bool ZigbeeEP::setManufacturerAndModel (const char *name, const char *model) {
36+ constexpr size_t ZB_MAX_NAME_LENGTH = 32 ;
37+
3638 // Convert manufacturer to ZCL string
3739 size_t name_length = strlen (name);
3840 size_t model_length = strlen (model);
39- if (name_length > 32 || model_length > 32 ) {
41+ if (name_length > ZB_MAX_NAME_LENGTH || model_length > ZB_MAX_NAME_LENGTH ) {
4042 log_e (" Manufacturer or model name is too long" );
4143 return false ;
4244 }
4345 // Allocate an array of size length + 2 (1 for the length, 1 for null terminator)
44- char zb_name[name_length + 2 ];
45- char zb_model[model_length + 2 ];
46+ char zb_name[ZB_MAX_NAME_LENGTH + 2 ];
47+ char zb_model[ZB_MAX_NAME_LENGTH + 2 ];
4648 // Store the length as the first element
4749 zb_name[0 ] = static_cast <char >(name_length); // Cast size_t to char
4850 zb_model[0 ] = static_cast <char >(model_length);
You can’t perform that action at this time.
0 commit comments