File tree 1 file changed +5
-3
lines changed
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) {
33
33
}
34
34
35
35
bool ZigbeeEP::setManufacturerAndModel (const char *name, const char *model) {
36
+ constexpr size_t ZB_MAX_NAME_LENGTH = 32 ;
37
+
36
38
// Convert manufacturer to ZCL string
37
39
size_t name_length = strlen (name);
38
40
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 ) {
40
42
log_e (" Manufacturer or model name is too long" );
41
43
return false ;
42
44
}
43
45
// 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 ];
46
48
// Store the length as the first element
47
49
zb_name[0 ] = static_cast <char >(name_length); // Cast size_t to char
48
50
zb_model[0 ] = static_cast <char >(model_length);
You can’t perform that action at this time.
0 commit comments