davinci: light: Avoid uint32_t underflow

Change-Id: If4f9360cc301ee8ba9f432dbbe3379c2c634c574
This commit is contained in:
Demon000 2019-09-06 13:47:29 +02:00 committed by Arian
parent e5440961f0
commit feedda1d84
No known key found for this signature in database
GPG Key ID: 48029380598CE3B9

View File

@ -74,6 +74,10 @@ static uint32_t getBrightness(const LightState& state) {
} }
static inline uint32_t scaleBrightness(uint32_t brightness, uint32_t maxBrightness) { static inline uint32_t scaleBrightness(uint32_t brightness, uint32_t maxBrightness) {
if (brightness == 0) {
return 0;
}
return (brightness - 1) * (maxBrightness - 1) / (0xFF - 1) + 1; return (brightness - 1) * (maxBrightness - 1) / (0xFF - 1) + 1;
} }