1 From b440f03b5f6426ae28df1d075af9e8b090e77adf Mon Sep 17 00:00:00 2001
2 From: Nathan Chancellor <natechancellor@gmail.com>
3 Date: Thu, 7 Mar 2019 14:45:46 -0700
4 Subject: iio: common: ssp_sensors: Initialize calculated_time in
5 ssp_common_process_data
7 [ Upstream commit 6f9ca1d3eb74b81f811a87002de2d51640d135b1 ]
9 When building with -Wsometimes-uninitialized, Clang warns:
11 drivers/iio/common/ssp_sensors/ssp_iio.c:95:6: warning: variable
12 'calculated_time' is used uninitialized whenever 'if' condition is false
13 [-Wsometimes-uninitialized]
15 While it isn't wrong, this will never be a problem because
16 iio_push_to_buffers_with_timestamp only uses calculated_time
17 on the same condition that it is assigned (when scan_timestamp
18 is not zero). While iio_push_to_buffers_with_timestamp is marked
19 as inline, Clang does inlining in the optimization stage, which
20 happens after the semantic analysis phase (plus inline is merely
21 a hint to the compiler).
23 Fix this by just zero initializing calculated_time.
25 Link: https://github.com/ClangBuiltLinux/linux/issues/394
26 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
27 Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
28 Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
29 Signed-off-by: Sasha Levin <sashal@kernel.org>
31 drivers/iio/common/ssp_sensors/ssp_iio.c | 2 +-
32 1 file changed, 1 insertion(+), 1 deletion(-)
34 diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c b/drivers/iio/common/ssp_sensors/ssp_iio.c
35 index a3ae165f8d9f3..16180e6321bd4 100644
36 --- a/drivers/iio/common/ssp_sensors/ssp_iio.c
37 +++ b/drivers/iio/common/ssp_sensors/ssp_iio.c
38 @@ -80,7 +80,7 @@ int ssp_common_process_data(struct iio_dev *indio_dev, void *buf,
39 unsigned int len, int64_t timestamp)
42 - int64_t calculated_time;
43 + int64_t calculated_time = 0;
44 struct ssp_sensor_data *spd = iio_priv(indio_dev);
46 if (indio_dev->scan_bytes == 0)