drivers/sensors: Fixed the overflow problem of uint32_t subtracting large from small.
Signed-off-by: likun17 <likun17@xiaomi.com>
This commit is contained in:
parent
a5729a81e3
commit
d88e0eac02
|
@ -399,7 +399,7 @@ static void sensor_generate_timing(FAR struct sensor_upperhalf_s *upper,
|
|||
static bool sensor_is_updated(FAR struct sensor_upperhalf_s *upper,
|
||||
FAR struct sensor_user_s *user)
|
||||
{
|
||||
long delta = upper->state.generation - user->state.generation;
|
||||
long delta = (long long)upper->state.generation - user->state.generation;
|
||||
|
||||
if (delta <= 0)
|
||||
{
|
||||
|
@ -431,7 +431,7 @@ static void sensor_catch_up(FAR struct sensor_upperhalf_s *upper,
|
|||
long delta;
|
||||
|
||||
circbuf_peek(&upper->timing, &generation, TIMING_BUF_ESIZE);
|
||||
delta = generation - user->state.generation;
|
||||
delta = (long long)generation - user->state.generation;
|
||||
if (delta > 0)
|
||||
{
|
||||
user->bufferpos = upper->timing.tail / TIMING_BUF_ESIZE;
|
||||
|
|
Loading…
Reference in New Issue