linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] usb: core: Make use of acpi_evaluate_object() status
@ 2020-02-18 16:09 Andy Shevchenko
  2020-02-18 18:17 ` Sergei Shtylyov
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2020-02-18 16:09 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-usb; +Cc: 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 <andriy.shevchenko@linux.intel.com>
---
 drivers/usb/core/usb-acpi.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index f434a2060552..41b91f4c207d 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -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;
 	}
 
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] usb: core: Make use of acpi_evaluate_object() status
  2020-02-18 16:09 [PATCH v1] usb: core: Make use of acpi_evaluate_object() status Andy Shevchenko
@ 2020-02-18 18:17 ` Sergei Shtylyov
  2020-02-18 18:33   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2020-02-18 18:17 UTC (permalink / raw)
  To: Andy Shevchenko, Greg Kroah-Hartman, linux-usb

Hi! :-)

On 02/18/2020 07:09 PM, Andy Shevchenko wrote:

> 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 <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/usb/core/usb-acpi.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
> index f434a2060552..41b91f4c207d 100644
> --- a/drivers/usb/core/usb-acpi.c
> +++ b/drivers/usb/core/usb-acpi.c
[...]
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] usb: core: Make use of acpi_evaluate_object() status
  2020-02-18 18:17 ` Sergei Shtylyov
@ 2020-02-18 18:33   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-02-18 18:33 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Greg Kroah-Hartman, linux-usb

On Tue, Feb 18, 2020 at 09:17:47PM +0300, Sergei Shtylyov wrote:
> On 02/18/2020 07:09 PM, Andy Shevchenko wrote:

...

> > +	if (!upc || (upc->type != ACPI_TYPE_PACKAGE) || upc->package.count != 4) {
> >  		goto out;
> >  	}
> 
>    I'd drop {} here, while at it.

Yep, makes sense, thanks!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-18 18:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-18 16:09 [PATCH v1] usb: core: Make use of acpi_evaluate_object() status Andy Shevchenko
2020-02-18 18:17 ` Sergei Shtylyov
2020-02-18 18:33   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).