* [PATCH][next] platform/x86: thinkpad_acpi: remove redundant assignment to variable i
@ 2024-01-06 15:47 Colin Ian King
2024-01-08 14:56 ` Hans de Goede
2024-01-24 11:02 ` Ilpo Järvinen
0 siblings, 2 replies; 3+ messages in thread
From: Colin Ian King @ 2024-01-06 15:47 UTC (permalink / raw)
To: Henrique de Moraes Holschuh, Hans de Goede, Ilpo Järvinen,
ibm-acpi-devel, platform-driver-x86
Cc: kernel-janitors, linux-kernel
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>
---
drivers/platform/x86/thinkpad_acpi.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index c4895e9bc714..7bf91cfd3e51 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -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]);
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] platform/x86: thinkpad_acpi: remove redundant assignment to variable i
2024-01-06 15:47 [PATCH][next] platform/x86: thinkpad_acpi: remove redundant assignment to variable i Colin Ian King
@ 2024-01-08 14:56 ` Hans de Goede
2024-01-24 11:02 ` Ilpo Järvinen
1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2024-01-08 14:56 UTC (permalink / raw)
To: Colin Ian King, Henrique de Moraes Holschuh, Ilpo Järvinen,
ibm-acpi-devel, platform-driver-x86
Cc: kernel-janitors, linux-kernel
Hi,
On 1/6/24 16:47, Colin Ian King wrote:
> 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>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
> drivers/platform/x86/thinkpad_acpi.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index c4895e9bc714..7bf91cfd3e51 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -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]);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] platform/x86: thinkpad_acpi: remove redundant assignment to variable i
2024-01-06 15:47 [PATCH][next] platform/x86: thinkpad_acpi: remove redundant assignment to variable i Colin Ian King
2024-01-08 14:56 ` Hans de Goede
@ 2024-01-24 11:02 ` Ilpo Järvinen
1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2024-01-24 11:02 UTC (permalink / raw)
To: Henrique de Moraes Holschuh, Hans de Goede, ibm-acpi-devel,
platform-driver-x86, Colin Ian King
Cc: kernel-janitors, linux-kernel
On Sat, 06 Jan 2024 15:47:40 +0000, Colin Ian King wrote:
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-24 11:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-06 15:47 [PATCH][next] platform/x86: thinkpad_acpi: remove redundant assignment to variable i Colin Ian King
2024-01-08 14:56 ` Hans de Goede
2024-01-24 11:02 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®