]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.9/iio-common-ssp_sensors-initialize-calculated_time-in.patch
Linux 4.14.123
[thirdparty/kernel/stable-queue.git] / queue-4.9 / iio-common-ssp_sensors-initialize-calculated_time-in.patch
1 From db1da1d38f04a1fd7a8a10c25bd8e96377332d25 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
6
7 [ Upstream commit 6f9ca1d3eb74b81f811a87002de2d51640d135b1 ]
8
9 When building with -Wsometimes-uninitialized, Clang warns:
10
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]
14
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).
22
23 Fix this by just zero initializing calculated_time.
24
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>
30 ---
31 drivers/iio/common/ssp_sensors/ssp_iio.c | 2 +-
32 1 file changed, 1 insertion(+), 1 deletion(-)
33
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)
40 {
41 __le32 time;
42 - int64_t calculated_time;
43 + int64_t calculated_time = 0;
44 struct ssp_sensor_data *spd = iio_priv(indio_dev);
45
46 if (indio_dev->scan_bytes == 0)
47 --
48 2.20.1
49