Skip to content

Commit

Permalink
drivers: fix double promotion warning in sensor_value_from_float
Browse files Browse the repository at this point in the history
fix double promotion warning when compiling when compiling with
-Wdouble-promotion

Signed-off-by: Ryan McClelland <[email protected]>
  • Loading branch information
XenuIsWatching authored and fabiobaltieri committed Jul 14, 2023
1 parent bed68af commit 2984565
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/zephyr/drivers/sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ static inline int sensor_value_from_double(struct sensor_value *val, double inp)
*/
static inline int sensor_value_from_float(struct sensor_value *val, float inp)
{
float val2 = (inp - (int32_t)inp) * 1000000.0;
float val2 = (inp - (int32_t)inp) * 1000000.0f;

if (val2 < INT32_MIN || val2 > (float)(INT32_MAX - 1)) {
return -ERANGE;
Expand Down

0 comments on commit 2984565

Please sign in to comment.