All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: misc: usbtest: remove redundant check on retval < 0
@ 2017-02-12 18:35 Colin King
  2017-02-13  9:49   ` Peter Chen
  2017-02-13 10:45   ` Felipe Balbi
  0 siblings, 2 replies; 8+ messages in thread
From: Colin King @ 2017-02-12 18:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Felipe Balbi, Peter Chen, Alan Stern,
	Mathias Nyman, Lu Baolu, Chunfeng Yun, linux-usb
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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 <colin.king@canonical.com>
---
 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(&iface->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

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

* Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0
  2017-02-12 18:35 [PATCH] usb: misc: usbtest: remove redundant check on retval < 0 Colin King
@ 2017-02-13  9:49   ` Peter Chen
  2017-02-13 10:45   ` Felipe Balbi
  1 sibling, 0 replies; 8+ messages in thread
From: Peter Chen @ 2017-02-13  9:49 UTC (permalink / raw)
  To: Colin King
  Cc: Greg Kroah-Hartman, Felipe Balbi, Peter Chen, Alan Stern,
	Mathias Nyman, Lu Baolu, Chunfeng Yun, linux-usb,
	kernel-janitors, linux-kernel

On Sun, Feb 12, 2017 at 06:35:18PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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 <colin.king@canonical.com>
> ---
>  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(&iface->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 <peter.chen@nxp.com>

-- 

Best Regards,
Peter Chen

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

* Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0
@ 2017-02-13  9:49   ` Peter Chen
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Chen @ 2017-02-13  9:49 UTC (permalink / raw)
  To: Colin King
  Cc: Greg Kroah-Hartman, Felipe Balbi, Peter Chen, Alan Stern,
	Mathias Nyman, Lu Baolu, Chunfeng Yun, linux-usb,
	kernel-janitors, linux-kernel

On Sun, Feb 12, 2017 at 06:35:18PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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 <colin.king@canonical.com>
> ---
>  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(&iface->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 <peter.chen@nxp.com>

-- 

Best Regards,
Peter Chen

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

* Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0
  2017-02-12 18:35 [PATCH] usb: misc: usbtest: remove redundant check on retval < 0 Colin King
@ 2017-02-13 10:45   ` Felipe Balbi
  2017-02-13 10:45   ` Felipe Balbi
  1 sibling, 0 replies; 8+ messages in thread
From: Felipe Balbi @ 2017-02-13 10:45 UTC (permalink / raw)
  To: Colin King, Greg Kroah-Hartman, Peter Chen, Alan Stern,
	Mathias Nyman, Lu Baolu, Chunfeng Yun, linux-usb
  Cc: kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1028 bytes --]


Hi,

Colin King <colin.king@canonical.com> writes:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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 <colin.king@canonical.com>
> ---
>  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(&iface->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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0
@ 2017-02-13 10:45   ` Felipe Balbi
  0 siblings, 0 replies; 8+ messages in thread
From: Felipe Balbi @ 2017-02-13 10:45 UTC (permalink / raw)
  To: Colin King, Greg Kroah-Hartman, Peter Chen, Alan Stern,
	Mathias Nyman, Lu Baolu, Chunfeng Yun, linux-usb
  Cc: kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1028 bytes --]


Hi,

Colin King <colin.king@canonical.com> writes:
> From: Colin Ian King <colin.king@canonical.com>
>
> 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 <colin.king@canonical.com>
> ---
>  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(&iface->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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

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

* Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0
  2017-02-13 10:45   ` Felipe Balbi
  (?)
@ 2017-02-13 16:44   ` Colin Ian King
  -1 siblings, 0 replies; 8+ messages in thread
From: Colin Ian King @ 2017-02-13 16:44 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Peter Chen, Alan Stern,
	Mathias Nyman, Lu Baolu, Chunfeng Yun, linux-usb
  Cc: kernel-janitors, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1344 bytes --]

On 13/02/17 10:45, Felipe Balbi wrote:
> 
> Hi,
> 
> Colin King <colin.king@canonical.com> writes:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> 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 <colin.king@canonical.com>
>> ---
>>  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(&iface->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.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 837 bytes --]

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

* Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0
  2017-02-13 10:45   ` Felipe Balbi
@ 2017-02-13 16:45     ` Alan Stern
  -1 siblings, 0 replies; 8+ messages in thread
From: Alan Stern @ 2017-02-13 16:45 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Colin King, Greg Kroah-Hartman, Peter Chen, Mathias Nyman,
	Lu Baolu, Chunfeng Yun, linux-usb, kernel-janitors, linux-kernel

On Mon, 13 Feb 2017, Felipe Balbi wrote:

> Hi,
> 
> Colin King <colin.king@canonical.com> writes:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > 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 <colin.king@canonical.com>
> > ---
> >  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(&iface->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

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

* Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0
@ 2017-02-13 16:45     ` Alan Stern
  0 siblings, 0 replies; 8+ messages in thread
From: Alan Stern @ 2017-02-13 16:45 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Colin King, Greg Kroah-Hartman, Peter Chen, Mathias Nyman,
	Lu Baolu, Chunfeng Yun, linux-usb, kernel-janitors, linux-kernel

On Mon, 13 Feb 2017, Felipe Balbi wrote:

> Hi,
> 
> Colin King <colin.king@canonical.com> writes:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > 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 <colin.king@canonical.com>
> > ---
> >  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(&iface->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


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

end of thread, other threads:[~2017-02-13 16:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-12 18:35 [PATCH] usb: misc: usbtest: remove redundant check on retval < 0 Colin King
2017-02-13  9:49 ` Peter Chen
2017-02-13  9:49   ` Peter Chen
2017-02-13 10:45 ` Felipe Balbi
2017-02-13 10:45   ` Felipe Balbi
2017-02-13 16:44   ` Colin Ian King
2017-02-13 16:45   ` Alan Stern
2017-02-13 16:45     ` Alan Stern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.