Skip to contentSkip to conversation

usb: core: Move variable initialization to appropriate place

PATCH Suwan Kim 1 participant 1 message Jan 30, 2019 USB

lore
Share & tools
lore

Suwan Kim

author
#0 lore raw

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

---
 drivers/usb/core/config.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/core/config.c +1 -2
index 4a0945c04b4c..7bb6b1bd06c8 100644
@@ -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,