iio: core: Fix IIO_VAL_FRACTIONAL calculation for negative values
authorAnand Ashok Dumbre <anand.ashok.dumbre@xilinx.com>
Mon, 5 Oct 2020 15:05:16 +0000 (08:05 -0700)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 10 Oct 2020 16:52:34 +0000 (17:52 +0100)
commit0e7a3978a40b26b85820afe9e544f0032103f805
tree92c23241fd78080c32b9620bbde231e2081d3a0c
parentc5bf4d645f2d5c4c216dd690c5237d778102c848
iio: core: Fix IIO_VAL_FRACTIONAL calculation for negative values

Fixes IIO_VAL_FRACTIONAL for case when the result is negative and
exponent is 0.

example: if the result is -0.75, tmp0 will be 0 and tmp1 = 75
This causes the output to lose sign because of %d in snprintf
which works for tmp0 <= -1.

Reported-by: kernel test robot <lkp@intel.com> #error: uninitialized symbol tmp
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Anand Ashok Dumbre <anand.ashok.dumbre@xilinx.com>
Link: https://lore.kernel.org/r/1601910316-24111-1-git-send-email-anand.ashok.dumbre@xilinx.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/industrialio-core.c