mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-09-11 17:14:27 +00:00
[Cleanup] Fix some possible uninitialised members & other loose ends
This commit is contained in:
@@ -66,8 +66,8 @@
|
||||
// #endif
|
||||
|
||||
|
||||
#define MAX31865_RD_ADDRESS(n) (MAX31865_READ_ADDR_BASE + n)
|
||||
#define MAX31865_WR_ADDRESS(n) (MAX31865_WRITE_ADDR_BASE + n)
|
||||
#define MAX31865_RD_ADDRESS(n) (MAX31865_READ_ADDR_BASE + (n))
|
||||
#define MAX31865_WR_ADDRESS(n) (MAX31865_WRITE_ADDR_BASE + (n))
|
||||
|
||||
# define PLUGIN_039
|
||||
# define PLUGIN_ID_039 39
|
||||
|
||||
@@ -667,7 +667,7 @@ range_pattern_helper_data range_pattern_helper_shared(pluginID_t plugin, struct
|
||||
data.isMask = !parseString(Line, 5).isEmpty();
|
||||
|
||||
if (data.isMask) {
|
||||
data.mask = event->Par4 & ((1 << data.numBytes * 8) - 1);
|
||||
data.mask = event->Par4 & ((1 << (data.numBytes * 8)) - 1);
|
||||
data.mask &= ((1 << data.numBits) - 1);
|
||||
data.mask = data.mask << data.deltaStart;
|
||||
} else {
|
||||
@@ -676,7 +676,7 @@ range_pattern_helper_data range_pattern_helper_shared(pluginID_t plugin, struct
|
||||
}
|
||||
|
||||
if (isWritePattern) { // write pattern is present
|
||||
data.write = event->Par3 & ((1 << data.numBytes * 8) - 1); // limit number of bytes
|
||||
data.write = event->Par3 & ((1 << (data.numBytes * 8)) - 1); // limit number of bytes
|
||||
data.write &= ((1 << data.numBits) - 1); // limit to number of bits
|
||||
data.write = data.write << data.deltaStart; // shift to start from starting pin
|
||||
} else { // write pattern not present
|
||||
|
||||
@@ -32,6 +32,24 @@ queue_element_formatted_uservar::queue_element_formatted_uservar(EventStruct *ev
|
||||
}
|
||||
}
|
||||
|
||||
queue_element_formatted_uservar& queue_element_formatted_uservar::operator=(queue_element_formatted_uservar&& other) {
|
||||
idx = other.idx;
|
||||
_timestamp = other._timestamp;
|
||||
TaskIndex = other.TaskIndex;
|
||||
controller_idx = other.controller_idx;
|
||||
sensorType = other.sensorType;
|
||||
valueCount = other.valueCount;
|
||||
|
||||
#ifdef USE_SECOND_HEAP
|
||||
HeapSelectIram ephemeral;
|
||||
#endif // ifdef USE_SECOND_HEAP
|
||||
|
||||
for (size_t i = 0; i < VARS_PER_TASK; ++i) {
|
||||
txt[i] = std::move(other.txt[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
size_t queue_element_formatted_uservar::getSize() const {
|
||||
size_t total = sizeof(*this);
|
||||
|
||||
|
||||
@@ -22,11 +22,15 @@ public:
|
||||
|
||||
queue_element_formatted_uservar(struct EventStruct *event);
|
||||
|
||||
size_t getSize() const;
|
||||
queue_element_formatted_uservar& operator=(queue_element_formatted_uservar&& other);
|
||||
|
||||
bool isDuplicate(const queue_element_formatted_uservar& other) const;
|
||||
size_t getSize() const;
|
||||
|
||||
const UnitMessageCount_t* getUnitMessageCount() const { return nullptr; }
|
||||
bool isDuplicate(const queue_element_formatted_uservar& other) const;
|
||||
|
||||
const UnitMessageCount_t * getUnitMessageCount() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
String txt[VARS_PER_TASK];
|
||||
int idx = 0;
|
||||
|
||||
@@ -19,6 +19,23 @@ queue_element_single_value_base::queue_element_single_value_base(queue_element_s
|
||||
}
|
||||
}
|
||||
|
||||
queue_element_single_value_base& queue_element_single_value_base::operator=(queue_element_single_value_base&& rval) {
|
||||
idx = rval.idx;
|
||||
_timestamp = rval._timestamp;
|
||||
TaskIndex = rval.TaskIndex;
|
||||
controller_idx = rval.controller_idx;
|
||||
valuesSent = rval.valuesSent;
|
||||
valueCount = rval.valueCount;
|
||||
#ifdef USE_SECOND_HEAP
|
||||
HeapSelectIram ephemeral;
|
||||
#endif // ifdef USE_SECOND_HEAP
|
||||
|
||||
for (byte i = 0; i < VARS_PER_TASK; ++i) {
|
||||
txt[i] = std::move(rval.txt[i]);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool queue_element_single_value_base::checkDone(bool succesfull) const {
|
||||
if (succesfull) { ++valuesSent; }
|
||||
return valuesSent >= valueCount || valuesSent >= VARS_PER_TASK;
|
||||
|
||||
@@ -22,17 +22,22 @@ public:
|
||||
queue_element_single_value_base(const struct EventStruct *event,
|
||||
byte value_count);
|
||||
|
||||
queue_element_single_value_base(const queue_element_single_value_base &rval) = delete;
|
||||
queue_element_single_value_base(const queue_element_single_value_base& rval) = delete;
|
||||
|
||||
queue_element_single_value_base(queue_element_single_value_base &&rval);
|
||||
queue_element_single_value_base(queue_element_single_value_base&& rval);
|
||||
|
||||
bool checkDone(bool succesfull) const;
|
||||
queue_element_single_value_base& operator=(queue_element_single_value_base&& other);
|
||||
|
||||
size_t getSize() const;
|
||||
|
||||
bool isDuplicate(const queue_element_single_value_base& other) const;
|
||||
bool checkDone(bool succesfull) const;
|
||||
|
||||
const UnitMessageCount_t* getUnitMessageCount() const { return nullptr; }
|
||||
size_t getSize() const;
|
||||
|
||||
bool isDuplicate(const queue_element_single_value_base& other) const;
|
||||
|
||||
const UnitMessageCount_t * getUnitMessageCount() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
String txt[VARS_PER_TASK];
|
||||
int idx = 0;
|
||||
|
||||
@@ -604,16 +604,16 @@ String LoadStringArray(SettingsType::Enum settingsType, int index, String string
|
||||
#endif
|
||||
}
|
||||
|
||||
const uint16_t bufferSize = 128;
|
||||
const uint32_t bufferSize = 128;
|
||||
|
||||
// FIXME TD-er: For now stack allocated, may need to be heap allocated?
|
||||
if (maxStringLength >= bufferSize) { return F("Max 128 chars allowed"); }
|
||||
char buffer[bufferSize];
|
||||
|
||||
String result;
|
||||
uint16_t readPos = 0;
|
||||
uint16_t nextStringPos = 0;
|
||||
uint16_t stringCount = 0;
|
||||
uint32_t readPos = 0;
|
||||
uint32_t nextStringPos = 0;
|
||||
uint32_t stringCount = 0;
|
||||
String tmpString;
|
||||
tmpString.reserve(bufferSize);
|
||||
|
||||
@@ -624,14 +624,29 @@ String LoadStringArray(SettingsType::Enum settingsType, int index, String string
|
||||
bufferSize,
|
||||
readPos);
|
||||
|
||||
for (int i = 0; i < bufferSize && stringCount < nrStrings; ++i) {
|
||||
uint16_t curPos = readPos + i;
|
||||
while (stringCount < nrStrings && static_cast<int>(readPos) < max_size) {
|
||||
const uint32_t readSize = std::min(bufferSize, max_size - readPos);
|
||||
result += LoadFromFile(settingsType,
|
||||
index,
|
||||
(byte *)&buffer,
|
||||
readSize,
|
||||
readPos);
|
||||
|
||||
if (curPos >= nextStringPos) {
|
||||
if (buffer[i] == 0) {
|
||||
if (maxStringLength != 0) {
|
||||
// Specific string length, so we have to set the next string position.
|
||||
nextStringPos += maxStringLength;
|
||||
for (uint32_t i = 0; i < readSize && stringCount < nrStrings; ++i) {
|
||||
const uint32_t curPos = readPos + i;
|
||||
|
||||
if (curPos >= nextStringPos) {
|
||||
if (buffer[i] == 0) {
|
||||
if (maxStringLength != 0) {
|
||||
// Specific string length, so we have to set the next string position.
|
||||
nextStringPos += maxStringLength;
|
||||
}
|
||||
strings[stringCount] = tmpString;
|
||||
tmpString = "";
|
||||
tmpString.reserve(readSize);
|
||||
++stringCount;
|
||||
} else {
|
||||
tmpString += buffer[i];
|
||||
}
|
||||
strings[stringCount] = tmpString;
|
||||
tmpString = "";
|
||||
|
||||
@@ -915,7 +915,13 @@ bool getConvertArgumentString(const String& marker,
|
||||
|
||||
// FIXME TD-er: These macros really increase build size
|
||||
struct ConvertArgumentData {
|
||||
ConvertArgumentData(String& s, bool useURLencode) : str(s), URLencode(useURLencode) {}
|
||||
ConvertArgumentData(String& s, bool useURLencode)
|
||||
: str(s),
|
||||
arg1(0.0f), arg2(0.0f),
|
||||
startIndex(0), endIndex(0),
|
||||
URLencode(useURLencode) {}
|
||||
|
||||
ConvertArgumentData() = delete;
|
||||
|
||||
String& str;
|
||||
float arg1, arg2 = 0.0f;
|
||||
|
||||
@@ -206,7 +206,9 @@ void SystemVariables::parseSystemVariables(String& s, boolean useURLencode)
|
||||
while ((v_index != -1)) {
|
||||
unsigned int i;
|
||||
if (validUIntFromString(s.substring(v_index + 2), i)) {
|
||||
const String key = String(F("%v")) + String(i) + '%';
|
||||
String key = F("%v");
|
||||
key += i;
|
||||
key += '%';
|
||||
if (s.indexOf(key) != -1) {
|
||||
const bool trimTrailingZeros = true;
|
||||
const String value = doubleToString(getCustomFloatVar(i), 6, trimTrailingZeros);
|
||||
|
||||
@@ -32,6 +32,7 @@ else:
|
||||
"-DUSES_P026", # System info
|
||||
"-DUSES_P027", # INA219
|
||||
"-DUSES_P028", # BME280
|
||||
"-DUSES_P033", # Dummy
|
||||
"-DUSES_P036", # FrameOLED
|
||||
"-DUSES_P045", # MPU6050
|
||||
"-DUSES_P049", # MHZ19
|
||||
|
||||
Reference in New Issue
Block a user