Message ID | 20200218160954.42815-1-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [v1] usb: core: Make use of acpi_evaluate_object() status | expand |
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
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!
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; }
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(-)