mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	[ltr_als_ps] Fix clang-tidy sign comparison errors (#11058)
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; | ||||
|  | ||||
| @@ -14,30 +15,30 @@ static const uint8_t MAX_TRIES = 5; | ||||
|  | ||||
| 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