linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* usb: core: Move variable initialization to appropriate place
@ 2019-01-30 14:48 Suwan Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Suwan Kim @ 2019-01-30 14:48 UTC (permalink / raw)
  To: gregkh, stern; +Cc: linux-usb, mathias.nyman

It is better to initialize the variable 'cfgno' in the for loop than
at the current place.

Signed-off-by: Suwan Kim <suwan.kim027@gmail.com>
---
 drivers/usb/core/config.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 4a0945c04b4c..7bb6b1bd06c8 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -805,7 +805,6 @@ int usb_get_configuration(struct usb_device *dev)
 	unsigned char *bigbuffer;
 	struct usb_config_descriptor *desc;
 
-	cfgno = 0;
 	if (ncfg > USB_MAXCONFIG) {
 		dev_warn(ddev, "too many configurations: %d, "
 		    "using maximum allowed: %d\n", ncfg, USB_MAXCONFIG);
@@ -831,7 +830,7 @@ int usb_get_configuration(struct usb_device *dev)
 	if (!desc)
 		goto err2;
 
-	for (; cfgno < ncfg; cfgno++) {
+	for (cfgno = 0; cfgno < ncfg; cfgno++) {
 		/* We grab just the first descriptor so we know how long
 		 * the whole configuration is */
 		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,

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

* usb: core: Move variable initialization to appropriate place
@ 2019-01-30 15:38 Alan Stern
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Stern @ 2019-01-30 15:38 UTC (permalink / raw)
  To: Suwan Kim; +Cc: gregkh, linux-usb, mathias.nyman

On Wed, 30 Jan 2019, Suwan Kim wrote:

> It is better to initialize the variable 'cfgno' in the for loop than
> at the current place.
> 
> Signed-off-by: Suwan Kim <suwan.kim027@gmail.com>
> ---
>  drivers/usb/core/config.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
> index 4a0945c04b4c..7bb6b1bd06c8 100644
> --- a/drivers/usb/core/config.c
> +++ b/drivers/usb/core/config.c
> @@ -805,7 +805,6 @@ int usb_get_configuration(struct usb_device *dev)
>  	unsigned char *bigbuffer;
>  	struct usb_config_descriptor *desc;
>  
> -	cfgno = 0;
>  	if (ncfg > USB_MAXCONFIG) {
>  		dev_warn(ddev, "too many configurations: %d, "
>  		    "using maximum allowed: %d\n", ncfg, USB_MAXCONFIG);
> @@ -831,7 +830,7 @@ int usb_get_configuration(struct usb_device *dev)
>  	if (!desc)
>  		goto err2;
>  
> -	for (; cfgno < ncfg; cfgno++) {
> +	for (cfgno = 0; cfgno < ncfg; cfgno++) {
>  		/* We grab just the first descriptor so we know how long
>  		 * the whole configuration is */
>  		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,

Acked-by: Alan Stern <stern@rowland.harvard.edu>

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

end of thread, other threads:[~2019-01-30 15:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-30 14:48 usb: core: Move variable initialization to appropriate place Suwan Kim
  -- strict thread matches above, loose matches on Subject: below --
2019-01-30 15:38 Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).