usb: core: Make use of acpi_evaluate_object() status
PATCH 1/1 usb: core: Make use of acpi_evaluate_object() status
Compiler is not happy about dangling variable:
.../core/usb-acpi.c: In function ‘usb_acpi_get_connect_type’:.../core/usb-acpi.c:90:14: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
90 | acpi_status status;
| ^~~~~~Make use of it by checking the status and bail out in case of error.
--- drivers/usb/core/usb-acpi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/usb/core/usb-acpi.c +5 -3
@@ -86,7 +86,7 @@ static enum usb_port_connect_type usb_acpi_get_connect_type(acpi_handle handle, {enum usb_port_connect_type connect_type =USB_PORT_CONNECT_TYPE_UNKNOWN ;struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; -union acpi_object *upc; +union acpi_object *upc =NULL ;acpi_status status;/*
@@ -98,9 +98,11 @@ static enum usb_port_connect_type usb_acpi_get_connect_type(acpi_handle handle,* no connectable, the port would be not used. */ status =acpi_evaluate_object (handle,"_UPC" ,NULL , &buffer); +if (ACPI_FAILURE (status)) + goto out; + upc = buffer.pointer; -if (!upc || (upc->type !=ACPI_TYPE_PACKAGE ) - || upc->package.count !=4 ) { +if (!upc || (upc->type !=ACPI_TYPE_PACKAGE ) || upc->package.count !=4 ) { goto out; }
Signature · 1 line
2.25.0
Hi! :-)
Quoted 18 lines · Andy Shevchenko
Compiler is not happy about dangling variable:
.../core/usb-acpi.c: In function ‘usb_acpi_get_connect_type’:.../core/usb-acpi.c:90:14: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]90 | acpi_status status; | ^~~~~~Make use of it by checking the status and bail out in case of error.
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/usb/core/usb-acpi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/usb/core/usb-acpi.c +0
-0
[...]
drivers/usb/core/usb-acpi.c static enum usb_port_connect_type usb_acpi_get_connect_type(acpi_handle handle, · line 107
Quoted 13 lines
drivers/usb/core/usb-acpi.c +4
-2@@ -98,9 +98,11 @@ static enum usb_port_connect_type usb_acpi_get_connect_type(acpi_handle handle,* no connectable, the port would be not used. */ status =acpi_evaluate_object (handle,"_UPC" ,NULL , &buffer); +if (ACPI_FAILURE (status)) + goto out; + upc = buffer.pointer; -if (!upc || (upc->type !=ACPI_TYPE_PACKAGE ) - || upc->package.count !=4 ) { +if (!upc || (upc->type !=ACPI_TYPE_PACKAGE ) || upc->package.count !=4 ) { goto out; }
I'd drop {} here, while at it.
MBR, Sergei
Quoted 1 line · Sergei Shtylyov
On 02/18/2020 07:09 PM, Andy Shevchenko wrote:
...
Quoted 5 lines
drivers/usb/core/usb-acpi.c static enum usb_port_connect_type usb_acpi_get_connect_type(acpi_handle handle, · line 107
Quoted 3 lines
drivers/usb/core/usb-acpi.c +1
-0+if (!upc || (upc->type !=ACPI_TYPE_PACKAGE ) || upc->package.count !=4 ) { goto out; }I'd drop {} here, while at it.
Yep, makes sense, thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko