Skip to content
Commit 61f06523 authored by Thomas Stranger's avatar Thomas Stranger Committed by Henrik Brix Andersen
Browse files

drivers: sensor: ltrf216a: fix overflow in conversion



The conversion of the raw sensor value overflows because
only a 32 bit multiplication is executed.
Fix the issue by promoting the raw sensor value to uint64_t before
executing the multiplication.

Analysis:
The current implementation overflows for all raw values grater
than 9544(14-bit).
But according to the datasheet the sensor has a maximum resolution of
20-bit. So Multiplying that value with 450.000 would need at least 39
bit to avoid an overflow, hence do it using 64-bit arithmetic.

Fixes CID 330657

Signed-off-by: default avatarThomas Stranger <thomas.stranger@outlook.com>
parent 25227aa4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment