From 68f825bfddabd7f6ec87c11915048e4024c77dab Mon Sep 17 00:00:00 2001 From: Gustavo Lima Chaves Date: Thu, 8 Jun 2017 15:57:49 -0700 Subject: [PATCH] Fix dangerous floating point comparison. Signed-off-by: Gustavo Lima Chaves --- .../iio+network/iio-magnetometer-console-and-mqtt-publish.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/samples/iio+network/iio-magnetometer-console-and-mqtt-publish.c b/src/samples/iio+network/iio-magnetometer-console-and-mqtt-publish.c index b80c0a991..6f52427ef 100644 --- a/src/samples/iio+network/iio-magnetometer-console-and-mqtt-publish.c +++ b/src/samples/iio+network/iio-magnetometer-console-and-mqtt-publish.c @@ -411,7 +411,7 @@ scale(double *x, double *y, double *z) if (sqr_norm < MAGNETIC_LOW) sanity_norm = MAGNETIC_LOW; - if (sanity_norm && sqr_norm) { + if (fpclassify(sanity_norm) != FP_ZERO && fpclassify(sqr_norm) != FP_ZERO) { scale = sanity_norm / sqr_norm; scale = sqrt(scale); *x = *x * scale;