Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1579260 > unrolled thread
| Started by | Colin King <colin.king@canonical.com> |
|---|---|
| First post | 2017-02-12 19:40 +0100 |
| Last post | 2017-02-13 17:50 +0100 |
| Articles | 5 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH] usb: misc: usbtest: remove redundant check on retval < 0 Colin King <colin.king@canonical.com> - 2017-02-12 19:40 +0100
Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0 Peter Chen <hzpeterchen@gmail.com> - 2017-02-13 11:00 +0100
Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0 Felipe Balbi <felipe.balbi@linux.intel.com> - 2017-02-13 11:50 +0100
Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0 Alan Stern <stern@rowland.harvard.edu> - 2017-02-13 17:50 +0100
Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0 Colin Ian King <colin.king@canonical.com> - 2017-02-13 17:50 +0100
| From | Colin King <colin.king@canonical.com> |
|---|---|
| Date | 2017-02-12 19:40 +0100 |
| Subject | [PATCH] usb: misc: usbtest: remove redundant check on retval < 0 |
| Message-ID | <ta7e1-1hK-5@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Peter Chen <hzpeterchen@gmail.com> |
|---|---|
| Date | 2017-02-13 11:00 +0100 |
| Message-ID | <talAm-1ZB-15@gated-at.bofh.it> |
| In reply to | #1579260 |
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
[toc] | [prev] | [next] | [standalone]
| From | Felipe Balbi <felipe.balbi@linux.intel.com> |
|---|---|
| Date | 2017-02-13 11:50 +0100 |
| Message-ID | <tammJ-2yB-3@gated-at.bofh.it> |
| In reply to | #1579260 |
[Multipart message — attachments visible in raw view] — view raw
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
[toc] | [prev] | [next] | [standalone]
| From | Alan Stern <stern@rowland.harvard.edu> |
|---|---|
| Date | 2017-02-13 17:50 +0100 |
| Subject | Re: [PATCH] usb: misc: usbtest: remove redundant check on retval < 0 |
| Message-ID | <tarZ7-6el-1@gated-at.bofh.it> |
| In reply to | #1579594 |
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
[toc] | [prev] | [next] | [standalone]
| From | Colin Ian King <colin.king@canonical.com> |
|---|---|
| Date | 2017-02-13 17:50 +0100 |
| Message-ID | <tarZ7-6el-9@gated-at.bofh.it> |
| In reply to | #1579594 |
[Multipart message — attachments visible in raw view] — view raw
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.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web