mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
code optimizations based on static analysis checks
This commit is contained in:
@@ -82,7 +82,7 @@ char * Helpers::itoa(char * result, int32_t value, const uint8_t base) {
|
||||
return result;
|
||||
}
|
||||
|
||||
char * ptr = result, *ptr1 = result, tmp_char;
|
||||
char * ptr = result, *ptr1 = result;
|
||||
int16_t tmp_value;
|
||||
|
||||
do {
|
||||
@@ -97,6 +97,7 @@ char * Helpers::itoa(char * result, int32_t value, const uint8_t base) {
|
||||
}
|
||||
|
||||
*ptr-- = '\0';
|
||||
char tmp_char;
|
||||
while (ptr1 < ptr) {
|
||||
tmp_char = *ptr;
|
||||
*ptr-- = *ptr1;
|
||||
@@ -136,7 +137,7 @@ char * Helpers::render_boolean(char * result, bool value) {
|
||||
}
|
||||
|
||||
// depending on format render a number or a string
|
||||
char * Helpers::render_enum(char * result, const std::vector<const __FlashStringHelper *> value, const uint8_t no) {
|
||||
char * Helpers::render_enum(char * result, const std::vector<const __FlashStringHelper *> &value, const uint8_t no) {
|
||||
if (no >= value.size()) {
|
||||
return nullptr; // out of bounds
|
||||
}
|
||||
@@ -459,7 +460,7 @@ bool Helpers::value2bool(const char * v, bool & value) {
|
||||
}
|
||||
|
||||
// checks to see if a string is member of a vector and return the index, also allow true/false for on/off
|
||||
bool Helpers::value2enum(const char * v, uint8_t & value, const std::vector<const __FlashStringHelper *> strs) {
|
||||
bool Helpers::value2enum(const char * v, uint8_t & value, const std::vector<const __FlashStringHelper *> &strs) {
|
||||
if ((v == nullptr) || (strlen(v) == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user