mirror of
https://github.com/esphome/esphome.git
synced 2025-10-08 12:53:45 +01:00
[ltr501] Fix clang-tidy sign comparison errors (#11057)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include <limits>
|
||||
|
||||
using esphome::i2c::ErrorCode;
|
||||
|
||||
@@ -28,30 +29,30 @@ bool operator!=(const GainTimePair &lhs, const GainTimePair &rhs) {
|
||||
|
||||
template<typename T, size_t size> T get_next(const T (&array)[size], const T val) {
|
||||
size_t i = 0;
|
||||
size_t idx = -1;
|
||||
while (idx == -1 && i < size) {
|
||||
size_t idx = std::numeric_limits<size_t>::max();
|
||||
while (idx == std::numeric_limits<size_t>::max() && i < size) {
|
||||
if (array[i] == val) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (idx == -1 || i + 1 >= size)
|
||||
if (idx == std::numeric_limits<size_t>::max() || i + 1 >= size)
|
||||
return val;
|
||||
return array[i + 1];
|
||||
}
|
||||
|
||||
template<typename T, size_t size> T get_prev(const T (&array)[size], const T val) {
|
||||
size_t i = size - 1;
|
||||
size_t idx = -1;
|
||||
while (idx == -1 && i > 0) {
|
||||
size_t idx = std::numeric_limits<size_t>::max();
|
||||
while (idx == std::numeric_limits<size_t>::max() && i > 0) {
|
||||
if (array[i] == val) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
if (idx == -1 || i == 0)
|
||||
if (idx == std::numeric_limits<size_t>::max() || i == 0)
|
||||
return val;
|
||||
return array[i - 1];
|
||||
}
|
||||
|
Reference in New Issue
Block a user