* [PATCH -next] platform/surface: remove status assignment without reading
@ 2020-10-29 11:47 Zou Wei
2020-10-29 11:52 ` Andy Shevchenko
2020-10-29 13:05 ` Maximilian Luz
0 siblings, 2 replies; 3+ messages in thread
From: Zou Wei @ 2020-10-29 11:47 UTC (permalink / raw)
To: hdegoede, mgross, luzmaximilian
Cc: platform-driver-x86, linux-kernel, Zou Wei
The status local variable is assigned but never read:
drivers/platform/surface/surface3-wmi.c:60:14: warning:
variable ‘status’ set but not used [-Wunused-but-set-variable]
acpi_status status;
^~~~~~
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
---
drivers/platform/surface/surface3-wmi.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/platform/surface/surface3-wmi.c b/drivers/platform/surface/surface3-wmi.c
index 130b6f5..ae1416c 100644
--- a/drivers/platform/surface/surface3-wmi.c
+++ b/drivers/platform/surface/surface3-wmi.c
@@ -57,12 +57,10 @@ static DEFINE_MUTEX(s3_wmi_lock);
static int s3_wmi_query_block(const char *guid, int instance, int *ret)
{
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
- acpi_status status;
union acpi_object *obj;
int error = 0;
mutex_lock(&s3_wmi_lock);
- status = wmi_query_block(guid, instance, &output);
obj = output.pointer;
--
2.6.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH -next] platform/surface: remove status assignment without reading
2020-10-29 11:47 [PATCH -next] platform/surface: remove status assignment without reading Zou Wei
@ 2020-10-29 11:52 ` Andy Shevchenko
2020-10-29 13:05 ` Maximilian Luz
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-10-29 11:52 UTC (permalink / raw)
To: Zou Wei
Cc: Hans de Goede, Mark Gross, Maximilian Luz, Platform Driver,
Linux Kernel Mailing List
On Thu, Oct 29, 2020 at 1:36 PM Zou Wei <zou_wei@huawei.com> wrote:
>
> The status local variable is assigned but never read:
...
> mutex_lock(&s3_wmi_lock);
> - status = wmi_query_block(guid, instance, &output);
What are you doing?!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] platform/surface: remove status assignment without reading
2020-10-29 11:47 [PATCH -next] platform/surface: remove status assignment without reading Zou Wei
2020-10-29 11:52 ` Andy Shevchenko
@ 2020-10-29 13:05 ` Maximilian Luz
1 sibling, 0 replies; 3+ messages in thread
From: Maximilian Luz @ 2020-10-29 13:05 UTC (permalink / raw)
To: Zou Wei, hdegoede, mgross
Cc: platform-driver-x86, linux-kernel, Benjamin Tissoires
On 10/29/20 12:47 PM, Zou Wei wrote:
> The status local variable is assigned but never read:
[...]
> static int s3_wmi_query_block(const char *guid, int instance, int *ret)
> {
> struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
> - acpi_status status;
> union acpi_object *obj;
> int error = 0;
>
> mutex_lock(&s3_wmi_lock);
> - status = wmi_query_block(guid, instance, &output);
I assume you want to remove the "status =" and not the whole line...
Regardless, I personally would prefer explicit error handling (as is
done in other contexts with wmi_query_block(), see e.g.
platform/x86/intel-wmi-sbl-fw-update.c. Although, yes, the "if (!obj |
..." should cover the error case as far as I can tell.
Also there seems to be the same issue in platform/x86/msi-wmi.c.
On a related note:
Does anyone know if the mutex here is really required? If there are any
problems, I believe it should rather go to s3_wmi_send_lid_state() and
also wrap the input_report_switch() / input_sync(). Otherwise, if there
were any race-type situations, not covering that could lead to wrong
updates:
Thread 1 Thread 2
s3_query_lid() returns old
s3_query_lid() returns new
input_report_switch()
input_sync()
input_report_switch()
input_sync()
I don't really expect those situations here as s3_wmi_send_lid_state()
is only used in probe(), resume(), and notify() (please correct me if
I'm wrong), so the mutex does seem weird to me here.
Otherwise if it's needed, a comment explaining why wouldn't hurt.
Regards,
Max
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-29 13:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-29 11:47 [PATCH -next] platform/surface: remove status assignment without reading Zou Wei
2020-10-29 11:52 ` Andy Shevchenko
2020-10-29 13:05 ` Maximilian Luz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox