iio: invensense: remove redundant initialization of variable period
Subsystems (2)
PATCH 1/1 iio: invensense: remove redundant initialization of variable period
The variable period is being initialized with a value that is never read, it is being re-assigned a new value later on before it is read. The initialization is redundant and can be removed.
Cleans up clang scan build warning:
Value stored to 'period' during its initialization is never read [deadcode.DeadStores]
--- drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/common/inv_sensors/inv_sensors_timestamp.c +1 -1
@@ -126,7 +126,7 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,struct inv_sensors_timestamp_interval *it;int64_t delta, interval;const uint32_t fifo_mult = fifo_period / ts->chip.clock_period; -uint32_t period = ts->period; +uint32_t period;bool valid = false;if (fifo_nb ==0 )
Signature · 1 line
2.39.2
Jonathan Cameron
maintainerQuoted 9 lines · On Sat, 6 Jan 2024 15:32:02 +0000 Colin Ian King <[email protected]>…
The variable period is being initialized with a value that is never read, it is being re-assigned a new value later on before it is read. The initialization is redundant and can be removed.
Cleans up clang scan build warning:
Value stored to 'period' during its initialization is never read [deadcode.DeadStores]Signed-off-by Colin Ian King <[email protected]>
Hi Colin,
I definitely want input from someone who can test this. There is direct use of ts->period as well as the local variable that is indeed overwritten as you've noted. Feels like naming needs some work and perhaps reduce the scope of the period local variable so it's obvious it was only intended for more local use than it currently looks like.
Thanks,
Jonathan
Quoted 17 lines
--- drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/common/inv_sensors/inv_sensors_timestamp.c +1
-1@@ -126,7 +126,7 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,struct inv_sensors_timestamp_interval *it;int64_t delta, interval;const uint32_t fifo_mult = fifo_period / ts->chip.clock_period; -uint32_t period = ts->period; +uint32_t period;bool valid = false;if (fifo_nb ==0 )
Jean-Baptiste Maneyrol
Acked-byHello Colin & Jonathan,
this is OK for me, thanks for the patch.
The initialization is certainly coming from first development and is not needed.
Thanks,
JB
From: Jonathan Cameron <[email protected]>
Sent: Sunday, January 7, 2024 17:07
To: Colin Ian King <[email protected]>
Cc: Lars-Peter Clausen <[email protected]>; Jean-Baptiste Maneyrol <[email protected]>; Andy Shevchenko <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Subject: Re: [PATCH][next] iio: invensense: remove redundant initialization of variable period
On Sat, 6 Jan 2024 15: 32: 02 +0000 Colin Ian King <colin. i. king@ gmail. com> wrote: > The variable period is being initialized with a value that is never > read, it is being re-assigned a new value later on before it is read. >
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Quoted 9 lines · On Sat, 6 Jan 2024 15:32:02 +0000 Colin Ian King <[email protected]>…
The variable period is being initialized with a value that is never read, it is being re-assigned a new value later on before it is read. The initialization is redundant and can be removed.
Cleans up clang scan build warning:
Value stored to 'period' during its initialization is never read [deadcode.DeadStores]Signed-off-by Colin Ian King <[email protected]>
Hi Colin,
I definitely want input from someone who can test this. There is direct use of ts->period as well as the local variable that is indeed overwritten as you've noted. Feels like naming needs some work and perhaps reduce the scope of the period local variable so it's obvious it was only intended for more local use than it currently looks like.
Thanks,
Jonathan
Quoted 17 lines
--- drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/common/inv_sensors/inv_sensors_timestamp.c +1
-1@@ -126,7 +126,7 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,struct inv_sensors_timestamp_interval *it;int64_t delta, interval;const uint32_t fifo_mult = fifo_period / ts->chip.clock_period; -uint32_t period = ts->period; +uint32_t period;bool valid = false;if (fifo_nb ==0 )
Jonathan Cameron
maintainerQuoted 6 lines · On Sun, 7 Jan 2024 20:18:03 +0000 Jean-Baptiste Maneyrol…
Hello Colin & Jonathan,
this is OK for me, thanks for the patch.
The initialization is certainly coming from first development and is not needed.
Applied to the togreg branch of iio.git and pushed out as testing. I'll be rebasing that tree on rc1 once available.
Thanks,
Jonathan
Quoted 60 lines
Thanks,
JBFrom: Jonathan Cameron <[email protected]>
Sent: Sunday, January 7, 2024 17:07
To: Colin Ian King <[email protected]>
Cc: Lars-Peter Clausen <[email protected]>; Jean-Baptiste Maneyrol <[email protected]>; Andy Shevchenko <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Subject: Re: [PATCH][next] iio: invensense: remove redundant initialization of variable period
On Sat, 6 Jan 2024 15: 32: 02 +0000 Colin Ian King <colin. i. king@ gmail. com> wrote: > The variable period is being initialized with a value that is never > read, it is being re-assigned a new value later on before it is read. >
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEndQuoted 9 lines · On Sat, 6 Jan 2024 15:32:02 +0000 Colin Ian King <[email protected]>…
The variable period is being initialized with a value that is never read, it is being re-assigned a new value later on before it is read. The initialization is redundant and can be removed.
Cleans up clang scan build warning:
Value stored to 'period' during its initialization is never read [deadcode.DeadStores]Signed-off-by Colin Ian King <[email protected]>Hi Colin,
I definitely want input from someone who can test this. There is direct use of
ts->periodas well as the local variable that is indeed overwritten as you've noted. Feels like naming needs some work and perhaps reduce the scope of the period local variable so it's obvious it was only intended for more local use than it currently looks like.Thanks,
Jonathan
Quoted 17 lines
--- drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iio/common/inv_sensors/inv_sensors_timestamp.c +1
-1@@ -126,7 +126,7 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,struct inv_sensors_timestamp_interval *it;int64_t delta, interval;const uint32_t fifo_mult = fifo_period / ts->chip.clock_period; -uint32_t period = ts->period; +uint32_t period;bool valid = false;if (fifo_nb ==0 )