Skip to content

Commit

Permalink
lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Jan 26, 2025
1 parent 20b978c commit 2620f56
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const char * Command::return_code_string(const uint8_t return_code) {
default:
break;
}
static char s[4];
static char s[4]; // static to avoid allocation on each call and loosing scope
return Helpers::smallitoa(s, return_code);
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/emsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ void EMSdevice::add_device_value(int8_t tag, // to b
if ((entityCustomization.product_id == product_id()) && (entityCustomization.device_id == device_id())) {
char entity[70];
if (tag < DeviceValueTAG::TAG_HC1) {
strncpy(entity, short_name, sizeof(entity));
strncpy(entity, short_name, sizeof(entity)-1);
} else {
snprintf(entity, sizeof(entity), "%s/%s", tag_to_mqtt(tag), short_name);
}
Expand Down Expand Up @@ -1201,7 +1201,7 @@ void EMSdevice::setCustomizationEntity(const std::string & entity_id) {
for (auto & dv : devicevalues_) {
char entity_name[70];
if (dv.tag < DeviceValueTAG::TAG_HC1) {
strncpy(entity_name, dv.short_name, sizeof(entity_name));
strncpy(entity_name, dv.short_name, sizeof(entity_name)-1);
} else {
snprintf(entity_name, sizeof(entity_name), "%s/%s", tag_to_mqtt(dv.tag), dv.short_name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/emsdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class EMSdevice {
}

void has_update(char * value, const char * newvalue, size_t len) {
if (strcmp(value, newvalue) != 0) {
if (value && strcmp(value, newvalue) != 0) {
strlcpy(value, newvalue, len);
has_update_ = true;
publish_value(value);
Expand Down
10 changes: 7 additions & 3 deletions src/devices/boiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,9 @@ void Boiler::process_UBAFactory(std::shared_ptr<const Telegram> telegram) {
return;
}
toggle_fetch(telegram->type_id, false); // only read once
uint8_t min, max, nomPower;
uint8_t min = 0;
uint8_t max = 0;
uint8_t nomPower = 0;
telegram->read_value(nomPower, 4);
telegram->read_value(min, 5);
telegram->read_value(max, 6);
Expand Down Expand Up @@ -1777,7 +1779,9 @@ void Boiler::process_UBAOutdoorTemp(std::shared_ptr<const Telegram> telegram) {

// UBASetPoint 0x1A
void Boiler::process_UBASetPoints(std::shared_ptr<const Telegram> telegram) {
uint8_t setFlowTemp_, setBurnPow_, wwSetBurnPow_;
uint8_t setFlowTemp_ = 0;
uint8_t setBurnPow_ = 0;
uint8_t wwSetBurnPow_ = 0;
telegram->read_value(setFlowTemp_, 0);
telegram->read_value(setBurnPow_, 1);
telegram->read_value(wwSetBurnPow_, 2);
Expand Down Expand Up @@ -2936,7 +2940,7 @@ bool Boiler::set_HpInLogic(const char * value, const int8_t id) {
return true;
}
char option[] = {"xxxxxxxxxxxxxxx"};
strncpy(option, value, strlen(value)); // copy without termination
strncpy(option, value, strlen(option)); // copy without termination
// inputs 1,2,3 <inv>[<evu1><evu2><evu3><comp><aux><cool><heat><dhw><pv><prot><pres><mod>]
if (id < 4) {
uint8_t index[] = {0, 3, 6, 9, 12, 15, 18, 21, 24, 39, 36, 30};
Expand Down

0 comments on commit 2620f56

Please sign in to comment.