Force braces around multi-line statements (#3094)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Oxan van Leeuwen
2022-01-24 20:56:36 +01:00
committed by GitHub
parent 6b27f2d2cf
commit 80d03a631e
125 changed files with 770 additions and 504 deletions
+13 -10
View File
@@ -206,19 +206,21 @@ void rgb_to_hsv(float red, float green, float blue, int &hue, float &saturation,
float min_color_value = std::min(std::min(red, green), blue);
float delta = max_color_value - min_color_value;
if (delta == 0)
if (delta == 0) {
hue = 0;
else if (max_color_value == red)
} else if (max_color_value == red) {
hue = int(fmod(((60 * ((green - blue) / delta)) + 360), 360));
else if (max_color_value == green)
} else if (max_color_value == green) {
hue = int(fmod(((60 * ((blue - red) / delta)) + 120), 360));
else if (max_color_value == blue)
} else if (max_color_value == blue) {
hue = int(fmod(((60 * ((red - green) / delta)) + 240), 360));
}
if (max_color_value == 0)
if (max_color_value == 0) {
saturation = 0;
else
} else {
saturation = delta / max_color_value;
}
value = max_color_value;
}
@@ -339,14 +341,15 @@ size_t parse_hex(const char *str, size_t length, uint8_t *data, size_t count) {
uint8_t val;
size_t chars = std::min(length, 2 * count);
for (size_t i = 2 * count - chars; i < 2 * count; i++, str++) {
if (*str >= '0' && *str <= '9')
if (*str >= '0' && *str <= '9') {
val = *str - '0';
else if (*str >= 'A' && *str <= 'F')
} else if (*str >= 'A' && *str <= 'F') {
val = 10 + (*str - 'A');
else if (*str >= 'a' && *str <= 'f')
} else if (*str >= 'a' && *str <= 'f') {
val = 10 + (*str - 'a');
else
} else {
return 0;
}
data[i >> 1] = !(i & 1) ? val << 4 : data[i >> 1] | val;
}
return chars;
+9 -5
View File
@@ -167,9 +167,10 @@ void IRAM_ATTR HOT Scheduler::call() {
{
// Don't copy-by value yet
auto &item = this->items_[0];
if ((now - item->last_execution) < item->interval)
if ((now - item->last_execution) < item->interval) {
// Not reached timeout yet, done for this call
break;
}
uint8_t major = item->next_execution_major();
if (this->millis_major_ - major > 1)
break;
@@ -190,10 +191,11 @@ void IRAM_ATTR HOT Scheduler::call() {
// - timeouts/intervals get cancelled
{
WarnIfComponentBlockingGuard guard{item->component};
if (item->type == SchedulerItem::RETRY)
if (item->type == SchedulerItem::RETRY) {
retry_result = item->retry_callback();
else
} else {
item->void_callback();
}
}
}
@@ -257,17 +259,19 @@ void HOT Scheduler::pop_raw_() {
void HOT Scheduler::push_(std::unique_ptr<Scheduler::SchedulerItem> item) { this->to_add_.push_back(std::move(item)); }
bool HOT Scheduler::cancel_item_(Component *component, const std::string &name, Scheduler::SchedulerItem::Type type) {
bool ret = false;
for (auto &it : this->items_)
for (auto &it : this->items_) {
if (it->component == component && it->name == name && it->type == type && !it->remove) {
to_remove_++;
it->remove = true;
ret = true;
}
for (auto &it : this->to_add_)
}
for (auto &it : this->to_add_) {
if (it->component == component && it->name == name && it->type == type) {
it->remove = true;
ret = true;
}
}
return ret;
}