mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] USB: remove redundant assignment to temp
@ 2017-11-07 10:27 Colin King
  2017-11-07 15:42 ` Alan Stern
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2017-11-07 10:27 UTC (permalink / raw)
  To: Alan Stern, Greg Kroah-Hartman, linux-usb; +Cc: kernel-janitors, linux-kernel

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

The variable temp is being set at the end of each loop iteration
but this value is never read, it is either being updated in just
the case 1 block or at the end of the loop.  Thus the assignment
is redundant and can be removed.  Cleans up clang warning:

drivers/usb/host/ehci-dbg.c:840:4: warning: Value stored to 'temp'
is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/usb/host/ehci-dbg.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 7fb21d01b3d0..70d4768958be 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -838,7 +838,6 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
 			default:		/* unknown */
 				break;
 			}
-			temp = (cap >> 8) & 0xff;
 		}
 	}
 #endif
-- 
2.14.1

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

* Re: [PATCH] USB: remove redundant assignment to temp
  2017-11-07 10:27 [PATCH] USB: remove redundant assignment to temp Colin King
@ 2017-11-07 15:42 ` Alan Stern
  2017-11-07 16:45   ` Colin Ian King
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Stern @ 2017-11-07 15:42 UTC (permalink / raw)
  To: Colin King; +Cc: Greg Kroah-Hartman, linux-usb, kernel-janitors, linux-kernel

On Tue, 7 Nov 2017, Colin King wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> The variable temp is being set at the end of each loop iteration
> but this value is never read, it is either being updated in just
> the case 1 block or at the end of the loop.  Thus the assignment
> is redundant and can be removed.  Cleans up clang warning:
> 
> drivers/usb/host/ehci-dbg.c:840:4: warning: Value stored to 'temp'
> is never read
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/usb/host/ehci-dbg.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
> index 7fb21d01b3d0..70d4768958be 100644
> --- a/drivers/usb/host/ehci-dbg.c
> +++ b/drivers/usb/host/ehci-dbg.c
> @@ -838,7 +838,6 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
>  			default:		/* unknown */
>  				break;
>  			}
> -			temp = (cap >> 8) & 0xff;
>  		}
>  	}
>  #endif

Good catch, but the solution is wrong.  The original code was mistaken;
it should have said:

			offset = (cap >> 8) & 0xff;

You can see that something like this is necessary if you consider the 
code path for the case where (cap & 0xff) != 1 -- the loop would just 
read the same capability value over and over again.

Would you like to submit a revised patch?

Alan Stern

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

* Re: [PATCH] USB: remove redundant assignment to temp
  2017-11-07 15:42 ` Alan Stern
@ 2017-11-07 16:45   ` Colin Ian King
  0 siblings, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2017-11-07 16:45 UTC (permalink / raw)
  To: Alan Stern; +Cc: Greg Kroah-Hartman, linux-usb, kernel-janitors, linux-kernel

On 07/11/17 15:42, Alan Stern wrote:
> On Tue, 7 Nov 2017, Colin King wrote:
> 
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The variable temp is being set at the end of each loop iteration
>> but this value is never read, it is either being updated in just
>> the case 1 block or at the end of the loop.  Thus the assignment
>> is redundant and can be removed.  Cleans up clang warning:
>>
>> drivers/usb/host/ehci-dbg.c:840:4: warning: Value stored to 'temp'
>> is never read
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  drivers/usb/host/ehci-dbg.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
>> index 7fb21d01b3d0..70d4768958be 100644
>> --- a/drivers/usb/host/ehci-dbg.c
>> +++ b/drivers/usb/host/ehci-dbg.c
>> @@ -838,7 +838,6 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
>>  			default:		/* unknown */
>>  				break;
>>  			}
>> -			temp = (cap >> 8) & 0xff;
>>  		}
>>  	}
>>  #endif
> 
> Good catch, but the solution is wrong.  The original code was mistaken;
> it should have said:
> 
> 			offset = (cap >> 8) & 0xff;
> 
> You can see that something like this is necessary if you consider the 
> code path for the case where (cap & 0xff) != 1 -- the loop would just 
> read the same capability value over and over again.

Thanks for pointing that out, makes complete sense.

> 
> Would you like to submit a revised patch?

Resent as: "usb: host: fix incorrect updating of offset"
> 
> Alan Stern
> 
Colin

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

end of thread, other threads:[~2017-11-07 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-07 10:27 [PATCH] USB: remove redundant assignment to temp Colin King
2017-11-07 15:42 ` Alan Stern
2017-11-07 16:45   ` Colin Ian King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®