mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
[Cleanup] Fix bugs reported by PVS Studio
This commit is contained in:
+2
-2
@@ -101,10 +101,10 @@ void C013_SendUDPTaskInfo(byte destUnit, byte sourceTaskIndex, byte destTaskInde
|
||||
infoReply.destTaskIndex = destTaskIndex;
|
||||
infoReply.deviceNumber = pluginID;
|
||||
LoadTaskSettings(infoReply.sourceTaskIndex);
|
||||
strcpy(infoReply.taskName, getTaskDeviceName(infoReply.sourceTaskIndex).c_str());
|
||||
safe_strncpy(infoReply.taskName, getTaskDeviceName(infoReply.sourceTaskIndex), sizeof(infoReply.taskName));
|
||||
|
||||
for (byte x = 0; x < VARS_PER_TASK; x++) {
|
||||
strcpy(infoReply.ValueNames[x], ExtraTaskSettings.TaskDeviceValueNames[x]);
|
||||
safe_strncpy(infoReply.ValueNames[x], ExtraTaskSettings.TaskDeviceValueNames[x], sizeof(infoReply.ValueNames[x]));
|
||||
}
|
||||
|
||||
if (destUnit != 0)
|
||||
|
||||
@@ -1189,6 +1189,9 @@ float readMax31856(struct EventStruct *event)
|
||||
float readMax31865(struct EventStruct *event)
|
||||
{
|
||||
P039_data_struct *P039_data = static_cast<P039_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
if (P039_data == nullptr) {
|
||||
return NAN;
|
||||
}
|
||||
|
||||
uint8_t registers[MAX31865_NO_REG] = {0};
|
||||
uint16_t rawValue = 0u;
|
||||
@@ -1262,12 +1265,12 @@ float readMax31865(struct EventStruct *event)
|
||||
//activate BIAS short before read, to reduce power consumption
|
||||
change8BitRegister(CS_pin_no, (MAX31865_READ_ADDR_BASE + MAX31865_CONFIG),(MAX31865_WRITE_ADDR_BASE + MAX31865_CONFIG), MAX31865_SET_VBIAS_ON, P039_SET );
|
||||
|
||||
// save current timer for next calculation
|
||||
P039_data->timer = millis();
|
||||
|
||||
// start time to follow up on BIAS activation before starting the conversion
|
||||
// and start conversion sequence via TIMER API
|
||||
if(nullptr != P039_data){
|
||||
// save current timer for next calculation
|
||||
P039_data->timer = millis();
|
||||
|
||||
// set next state to MAX31865_BIAS_ON_STATE
|
||||
|
||||
Scheduler.setPluginTaskTimer(MAX31865_BIAS_WAIT_TIME, event->TaskIndex, MAX31865_BIAS_ON_STATE);
|
||||
|
||||
@@ -512,7 +512,7 @@ void type_Static_Light() {
|
||||
void type_Simple_Candle() {
|
||||
int r, g, b;
|
||||
if (Candle_color == ColorDefault) {
|
||||
r = 226, g = 042, b = 35; // Regular (orange) flame
|
||||
r = 226, g = 42, b = 35; // Regular (orange) flame
|
||||
//r = 158, g = 8, b = 148; // Purple flame
|
||||
//r = 74, g = 150, b = 12; // Green flame
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -320,7 +320,7 @@ struct P049_data_struct : public PluginTaskData_base {
|
||||
unsigned long lastInitTimestamp = 0;
|
||||
|
||||
ESPeasySerial *easySerial = nullptr;
|
||||
byte mhzResp[9]; // 9 byte response buffer
|
||||
byte mhzResp[9] = {0}; // 9 byte response buffer
|
||||
// Default of the sensor is to run ABC
|
||||
bool ABC_Disable = false;
|
||||
bool ABC_MustApply = false;
|
||||
|
||||
@@ -161,9 +161,8 @@ boolean Plugin_062(byte function, struct EventStruct *event, String& string)
|
||||
if (tbUseCalibration) {
|
||||
addFormCheckBox(F("Clear calibrationdata"), F("p062_clear_calibrate"), false);
|
||||
}
|
||||
} else {
|
||||
delete P062_data;
|
||||
}
|
||||
delete P062_data;
|
||||
}
|
||||
success = true;
|
||||
break;
|
||||
|
||||
+3
-3
@@ -436,10 +436,10 @@ void LogBufferContent(String prefix) {
|
||||
}
|
||||
}
|
||||
|
||||
int dotpos;
|
||||
uint8_t showbuffer[8];
|
||||
int dotpos = 0;
|
||||
uint8_t showbuffer[8] = {0};
|
||||
bool showperiods[8];
|
||||
byte spidata[2];
|
||||
byte spidata[2] = {0};
|
||||
uint8_t pin1, pin2, pin3;
|
||||
byte displayModel;
|
||||
byte output;
|
||||
|
||||
+10
-4
@@ -155,7 +155,7 @@ struct P077_data_struct : public PluginTaskData_base {
|
||||
|
||||
// uint8_t cse_receive_flag = 0;
|
||||
|
||||
uint8_t serial_in_buffer[32];
|
||||
uint8_t serial_in_buffer[32] = {0};
|
||||
long voltage_cycle = 0;
|
||||
long current_cycle = 0;
|
||||
long power_cycle = 0;
|
||||
@@ -168,9 +168,15 @@ struct P077_data_struct : public PluginTaskData_base {
|
||||
float energy_power = 0; // 123.1 W
|
||||
|
||||
// stats
|
||||
long t_max = 0, t_all = 0, t_pkt = 0, t_pkt_tmp = 0;
|
||||
uint16_t count_bytes = 0, count_max = 0, count_pkt = 0;
|
||||
uint8_t checksum = 0, adjustment = 0;
|
||||
long t_max = 0;
|
||||
long t_all = 0;
|
||||
long t_pkt = 0;
|
||||
long t_pkt_tmp = 0;
|
||||
uint16_t count_bytes = 0;
|
||||
uint16_t count_max = 0;
|
||||
uint16_t count_pkt = 0;
|
||||
uint8_t checksum = 0;
|
||||
uint8_t adjustment = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
# define P102_QUERY3 PCONFIG(5)
|
||||
# define P102_QUERY4 PCONFIG(6)
|
||||
# define P102_PZEM_FIRST PCONFIG(7)
|
||||
# define P102_PZEM_ATTEMPT PCONFIG(8)
|
||||
# define P102_PZEM_ATTEMPT PCONFIG_LONG(1)
|
||||
|
||||
# define P102_PZEM_mode_DFLT 0 // Read value
|
||||
# define P102_QUERY1_DFLT 0 // Voltage (V)
|
||||
|
||||
@@ -120,7 +120,7 @@ String Command_GetORSetString(struct EventStruct *event,
|
||||
serialPrintln();
|
||||
return return_result(event, result);
|
||||
}
|
||||
strcpy(target, TmpStr1.c_str());
|
||||
safe_strncpy(target, TmpStr1, len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,18 @@ C016_queue_element::C016_queue_element(const struct EventStruct *event, byte val
|
||||
}
|
||||
}
|
||||
|
||||
C016_queue_element& C016_queue_element::operator=(C016_queue_element&& other) {
|
||||
_timestamp = other._timestamp;
|
||||
TaskIndex = other.TaskIndex;
|
||||
controller_idx = other.controller_idx;
|
||||
sensorType = other.sensorType;
|
||||
valueCount = other.valueCount;
|
||||
for (byte i = 0; i < VARS_PER_TASK; ++i) {
|
||||
values[i] = other.values[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
size_t C016_queue_element::getSize() const {
|
||||
return sizeof(*this);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ public:
|
||||
byte value_count,
|
||||
unsigned long unixTime);
|
||||
|
||||
C016_queue_element& operator=(C016_queue_element&& other);
|
||||
|
||||
|
||||
size_t getSize() const;
|
||||
|
||||
bool isDuplicate(const C016_queue_element& other) const;
|
||||
|
||||
@@ -19,8 +19,17 @@ struct P006_data_struct : public PluginTaskData_base {
|
||||
float readTemperature(void);
|
||||
|
||||
uint8_t oversampling = BMP085_ULTRAHIGHRES;
|
||||
int16_t ac1, ac2, ac3, b1, b2, mb, mc, md = 0;
|
||||
uint16_t ac4, ac5, ac6 = 0;
|
||||
int16_t ac1 = 0;
|
||||
int16_t ac2 = 0;
|
||||
int16_t ac3 = 0;
|
||||
int16_t b1 = 0;
|
||||
int16_t b2 = 0;
|
||||
int16_t mb = 0;
|
||||
int16_t mc = 0;
|
||||
int16_t md = 0;
|
||||
uint16_t ac4 = 0;
|
||||
uint16_t ac5 = 0;
|
||||
uint16_t ac6 = 0;
|
||||
|
||||
bool initialized = false;
|
||||
};
|
||||
|
||||
@@ -58,11 +58,11 @@ public:
|
||||
private:
|
||||
void updateCalibration(uint8_t t);
|
||||
|
||||
Adafruit_MPR121 *keypad = NULL;
|
||||
Adafruit_MPR121 *keypad = nullptr;
|
||||
uint16_t keyLast = 0;
|
||||
int8_t _i2c_addr = -1;
|
||||
bool _use_scancode;
|
||||
bool _keepCalibrationData;
|
||||
bool _use_scancode = false;
|
||||
bool _keepCalibrationData = false;
|
||||
};
|
||||
|
||||
#endif // ifdef USES_P062
|
||||
|
||||
@@ -453,13 +453,13 @@ P092_data_struct::P092_data_struct() {}
|
||||
|
||||
P092_data_struct::~P092_data_struct() {
|
||||
if (DLbus_Data != nullptr) {
|
||||
if (DLbus_Data->ISR_DLB_Pin != 0xFF) {
|
||||
detachInterrupt(digitalPinToInterrupt(DLbus_Data->ISR_DLB_Pin));
|
||||
}
|
||||
delete DLbus_Data;
|
||||
DLbus_Data = nullptr;
|
||||
}
|
||||
|
||||
if (DLbus_Data->ISR_DLB_Pin != 0xFF) {
|
||||
detachInterrupt(digitalPinToInterrupt(DLbus_Data->ISR_DLB_Pin));
|
||||
}
|
||||
}
|
||||
|
||||
bool P092_data_struct::init(int8_t pin1, int P092DeviceIndex, eP092pinmode P092pinmode) {
|
||||
|
||||
@@ -46,7 +46,10 @@ public:
|
||||
volatile boolean ISR_AllBitsReceived = false;
|
||||
volatile uint16_t ISR_PulseCount = 0; // number of received pulses
|
||||
volatile uint16_t ISR_PulseNumber = 0; // max naumber of the received pulses
|
||||
volatile uint16_t ISR_MinPulseWidth, ISR_MaxPulseWidth, ISR_MinDoublePulseWidth, ISR_MaxDoublePulseWidth = 0;
|
||||
volatile uint16_t ISR_MinPulseWidth = 0;
|
||||
volatile uint16_t ISR_MaxPulseWidth = 0;
|
||||
volatile uint16_t ISR_MinDoublePulseWidth = 0;
|
||||
volatile uint16_t ISR_MaxDoublePulseWidth = 0;
|
||||
|
||||
// identification bytes for each DL bus device
|
||||
uint8_t DeviceBytes[2] = { 0 };
|
||||
|
||||
@@ -52,23 +52,23 @@ struct P099_data_struct : public PluginTaskData_base
|
||||
void scaleRawToCalibrated(uint16_t &x, uint16_t &y);
|
||||
|
||||
// This is initialized by calling init()
|
||||
XPT2046_Touchscreen *touchscreen;
|
||||
uint8_t _address_ts_cs;
|
||||
uint8_t _rotation;
|
||||
bool _flipped;
|
||||
uint8_t _z_treshold;
|
||||
bool _send_xy;
|
||||
bool _send_z;
|
||||
bool _useCalibration;
|
||||
uint16_t _ts_x_res;
|
||||
uint16_t _ts_y_res;
|
||||
XPT2046_Touchscreen *touchscreen = nullptr;
|
||||
uint8_t _address_ts_cs = 0;
|
||||
uint8_t _rotation = 0;
|
||||
bool _flipped = 0;
|
||||
uint8_t _z_treshold = 0;
|
||||
bool _send_xy = 0;
|
||||
bool _send_z = 0;
|
||||
bool _useCalibration = 0;
|
||||
uint16_t _ts_x_res = 0;
|
||||
uint16_t _ts_y_res = 0;
|
||||
|
||||
// This is filled during checking of a touchobject
|
||||
uint32_t SurfaceAreas[P099_MaxObjectCount];
|
||||
uint32_t SurfaceAreas[P099_MaxObjectCount] = {0};
|
||||
|
||||
// Counters for debouncing touch button
|
||||
uint32_t TouchTimers[P099_MaxObjectCount];
|
||||
bool TouchStates[P099_MaxObjectCount];
|
||||
uint32_t TouchTimers[P099_MaxObjectCount] = {0};
|
||||
bool TouchStates[P099_MaxObjectCount] = {0};
|
||||
|
||||
// The settings structures
|
||||
// Lets define our own coordinate point
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
P113_data_struct(uint8_t i2c_addr,
|
||||
int timing,
|
||||
bool range);
|
||||
P113_data_struct() = delete;
|
||||
|
||||
bool begin();
|
||||
bool startRead();
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
uint8_t integration_time,
|
||||
bool highDensity);
|
||||
|
||||
P114_data_struct() = delete;
|
||||
|
||||
bool read_sensor(float& _UVA,
|
||||
float& _UVB,
|
||||
float& _UVIndex);
|
||||
|
||||
Reference in New Issue
Block a user