platform/x86: thinkpad_acpi: remove redundant assignment to variable i
authorColin Ian King <colin.i.king@gmail.com>
Sat, 6 Jan 2024 15:47:40 +0000 (15:47 +0000)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Wed, 24 Jan 2024 10:33:17 +0000 (12:33 +0200)
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]

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240106154740.55202-1-colin.i.king@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/thinkpad_acpi.c

index c4895e9bc7148ae991a541508a0672a9ae0345bf..7bf91cfd3e51a459f54e6b0d0f939b63ec3fe994 100644 (file)
@@ -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]);