]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
iio: common: ssp_sensors: Initialize calculated_time in ssp_common_process_data
authorNathan Chancellor <natechancellor@gmail.com>
Thu, 7 Mar 2019 21:45:46 +0000 (14:45 -0700)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838700
[ Upstream commit 6f9ca1d3eb74b81f811a87002de2d51640d135b1 ]

When building with -Wsometimes-uninitialized, Clang warns:

drivers/iio/common/ssp_sensors/ssp_iio.c:95:6: warning: variable
'calculated_time' is used uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]

While it isn't wrong, this will never be a problem because
iio_push_to_buffers_with_timestamp only uses calculated_time
on the same condition that it is assigned (when scan_timestamp
is not zero). While iio_push_to_buffers_with_timestamp is marked
as inline, Clang does inlining in the optimization stage, which
happens after the semantic analysis phase (plus inline is merely
a hint to the compiler).

Fix this by just zero initializing calculated_time.

Link: https://github.com/ClangBuiltLinux/linux/issues/394
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/iio/common/ssp_sensors/ssp_iio.c

index 645f2e3975db45e7edc1a3640ba600c39b64b1ea..e38f704d88b7e7f9c52481b7eee5fb8115ea1566 100644 (file)
@@ -81,7 +81,7 @@ int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
                            unsigned int len, int64_t timestamp)
 {
        __le32 time;
-       int64_t calculated_time;
+       int64_t calculated_time = 0;
        struct ssp_sensor_data *spd = iio_priv(indio_dev);
 
        if (indio_dev->scan_bytes == 0)