platform/x86: thinkpad_acpi: remove redundant assignment to variable i
Subsystems (2)
PATCH 1/1 platform/x86: thinkpad_acpi: remove redundant assignment to variable i
The variable i is being initialized with the value 0 that is never read, it is being re-assigned 0 again in a for-loop statement later on. The initialization is redundant and can be removed.
The initialization of variable n can also be deferred after the sanity check on pointer n and the declaration of all the int variables can be combined as a final code clear-up.
Cleans up clang scan build warning:
warning: Value stored to 'i' is never read [deadcode.DeadStores]
--- drivers/platform/x86/thinkpad_acpi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +3 -5
@@ -6208,17 +6208,15 @@ static int thermal_get_sensor(int idx, s32 *value)static int thermal_get_sensors (struct ibm_thermal_sensors_struct *s) { -int res, i; -int n; - - n =8 ; - i =0 ; +int res, i, n;if (!s)return -EINVAL ;if (thermal_read_mode ==TPACPI_THERMAL_TPEC_16 ) n =16 ; +else + n =8 ;for (i =0 ; i < n; i++) { res =thermal_get_sensor (i, &s->temp[i]);
Signature · 1 line
2.39.2
Hi,
Quoted 4 lines · Colin Ian King
The variable i is being initialized with the value 0 that is never read, it is being re-assigned 0 again in a for-loop statement later on. The initialization is redundant and can be removed.
Quoted 8 lines
The initialization of variable n can also be deferred after the sanity check on pointer n and the declaration of all the int variables can be combined as a final code clear-up.
Cleans up clang scan build warning:
warning: Value stored to 'i' is never read [deadcode.DeadStores]Signed-off-by Colin Ian King <[email protected]>
Thanks, patch looks good to me:
Regards,
Hans
Quoted 29 lines
--- drivers/platform/x86/thinkpad_acpi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/platform/x86/thinkpad_acpi.c +3
-5@@ -6208,17 +6208,15 @@ static int thermal_get_sensor(int idx, s32 *value)static int thermal_get_sensors (struct ibm_thermal_sensors_struct *s) { -int res, i; -int n; - - n =8 ; - i =0 ; +int res, i, n;if (!s)return -EINVAL ;if (thermal_read_mode ==TPACPI_THERMAL_TPEC_16 ) n =16 ; +else + n =8 ;for (i =0 ; i < n; i++) { res =thermal_get_sensor (i, &s->temp[i]);
Ilpo Järvinen
maintainerQuoted 9 lines · Colin Ian King
The variable i is being initialized with the value 0 that is never read, it is being re-assigned 0 again in a for-loop statement later on. The initialization is redundant and can be removed.
The initialization of variable n can also be deferred after the sanity check on pointer n and the declaration of all the int variables can be combined as a final code clear-up.
[...]
Thank you for your contribution, it has been applied to my local review-ilpo branch. Note it will show up in the public platform-drivers-x86/review-ilpo branch only once I've pushed my local branch there, which might take a while.
The list of commits applied:
[1/1] platform/x86: thinkpad_acpi: remove redundant assignment to variable i
commit: 214509e5d61d294193b220f397418e76879f74c0
--
i.