Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0

2017-02-13 Thread Colin Ian King
On 13/02/17 10:45, Felipe Balbi wrote:
> 
> Hi,
> 
> Colin King  writes:
>> From: Colin Ian King 
>>
>> The check for retval being less than zero is always true since
>> retval equal to -EPIPE at that point.  Replace the existing
>> conditional with just return retval.
>>
>> Detected with CoverityScan, CID#114349 ("Logically dead code")
>>
>> Signed-off-by: Colin Ian King 
>> ---
>>  drivers/usb/misc/usbtest.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
>> index 3525626..17c0810 100644
>> --- a/drivers/usb/misc/usbtest.c
>> +++ b/drivers/usb/misc/usbtest.c
>> @@ -992,7 +992,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
>>  dev_err(>dev,
>>  "hs dev qualifier --> %d\n",
>>  retval);
>> -return (retval < 0) ? retval : -EDOM;
>> +return retval;
> 
> you're changing return value here, are you sure there's nothing else
> depending on this error?
> 
The code in the current state will never return -EDOM and will always
return retval, so this change actually makes no functional change, it
just removes a redundant check.  So it's not going to make a jot of
difference to the current behaver.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0

2017-02-13 Thread Alan Stern
On Mon, 13 Feb 2017, Felipe Balbi wrote:

> Hi,
> 
> Colin King  writes:
> > From: Colin Ian King 
> >
> > The check for retval being less than zero is always true since
> > retval equal to -EPIPE at that point.  Replace the existing
> > conditional with just return retval.
> >
> > Detected with CoverityScan, CID#114349 ("Logically dead code")
> >
> > Signed-off-by: Colin Ian King 
> > ---
> >  drivers/usb/misc/usbtest.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
> > index 3525626..17c0810 100644
> > --- a/drivers/usb/misc/usbtest.c
> > +++ b/drivers/usb/misc/usbtest.c
> > @@ -992,7 +992,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
> > dev_err(>dev,
> > "hs dev qualifier --> %d\n",
> > retval);
> > -   return (retval < 0) ? retval : -EDOM;
> > +   return retval;
> 
> you're changing return value here, are you sure there's nothing else
> depending on this error?

I bet you didn't look at the original code.  :-)  Just before the start
of the patch there is:

if (retval == -EPIPE) {
...

So no, the patch does not change the return value.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0

2017-02-13 Thread Felipe Balbi

Hi,

Colin King  writes:
> From: Colin Ian King 
>
> The check for retval being less than zero is always true since
> retval equal to -EPIPE at that point.  Replace the existing
> conditional with just return retval.
>
> Detected with CoverityScan, CID#114349 ("Logically dead code")
>
> Signed-off-by: Colin Ian King 
> ---
>  drivers/usb/misc/usbtest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
> index 3525626..17c0810 100644
> --- a/drivers/usb/misc/usbtest.c
> +++ b/drivers/usb/misc/usbtest.c
> @@ -992,7 +992,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
>   dev_err(>dev,
>   "hs dev qualifier --> %d\n",
>   retval);
> - return (retval < 0) ? retval : -EDOM;
> + return retval;

you're changing return value here, are you sure there's nothing else
depending on this error?

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0

2017-02-13 Thread Peter Chen
On Sun, Feb 12, 2017 at 06:35:18PM +, Colin King wrote:
> From: Colin Ian King 
> 
> The check for retval being less than zero is always true since
> retval equal to -EPIPE at that point.  Replace the existing
> conditional with just return retval.
> 
> Detected with CoverityScan, CID#114349 ("Logically dead code")
> 
> Signed-off-by: Colin Ian King 
> ---
>  drivers/usb/misc/usbtest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
> index 3525626..17c0810 100644
> --- a/drivers/usb/misc/usbtest.c
> +++ b/drivers/usb/misc/usbtest.c
> @@ -992,7 +992,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
>   dev_err(>dev,
>   "hs dev qualifier --> %d\n",
>   retval);
> - return (retval < 0) ? retval : -EDOM;
> + return retval;
>   }
>   /* usb2.0 but not high-speed capable; fine */
>   } else if (retval != sizeof(struct usb_qualifier_descriptor)) {

Reviewed-by: Peter Chen 

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: misc: usbtest: remove redundant check on retval < 0

2017-02-12 Thread Colin King
From: Colin Ian King 

The check for retval being less than zero is always true since
retval equal to -EPIPE at that point.  Replace the existing
conditional with just return retval.

Detected with CoverityScan, CID#114349 ("Logically dead code")

Signed-off-by: Colin Ian King 
---
 drivers/usb/misc/usbtest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 3525626..17c0810 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -992,7 +992,7 @@ static int ch9_postconfig(struct usbtest_dev *dev)
dev_err(>dev,
"hs dev qualifier --> %d\n",
retval);
-   return (retval < 0) ? retval : -EDOM;
+   return retval;
}
/* usb2.0 but not high-speed capable; fine */
} else if (retval != sizeof(struct usb_qualifier_descriptor)) {
-- 
2.10.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html