Message ID | 558d5094-64b5-f870-9b18-3451c0b44337@omp.ru (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] usb: core: devices: drop unreachable code in usb_dump_endpoint_descriptor() | expand |
On Wed, Feb 09, 2022 at 01:45:15PM +0300, Sergey Shtylyov wrote: > The *switch* statement in usb_dump_endpoint_descriptor() does handle > all possible endpoint types expilicitly, so the *default* label is > unreachable... > > Found by Linux Verification Center (linuxtesting.org) with the SVACE static > analysis tool. > > Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> > > --- > This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. > > Changes in version 2: > - fixed typos in the patch description; > - reformatted the patch description. > > drivers/usb/core/devices.c | 2 -- > 1 file changed, 2 deletions(-) > > Index: usb/drivers/usb/core/devices.c > =================================================================== > --- usb.orig/drivers/usb/core/devices.c > +++ usb/drivers/usb/core/devices.c > @@ -168,8 +168,6 @@ static char *usb_dump_endpoint_descripto > case USB_ENDPOINT_XFER_INT: > type = "Int."; > break; > - default: /* "can't happen" */ > - return start; > } We write code for humans first, compiler/cpu second. These two lines provide a huge hint to a human, and the compiler/cpu does not care at all as it is optimized away. So this makes no real change except make it harder for humans to understand and read the code, which is not a change anyone should make. sorry, greg k-h
Index: usb/drivers/usb/core/devices.c =================================================================== --- usb.orig/drivers/usb/core/devices.c +++ usb/drivers/usb/core/devices.c @@ -168,8 +168,6 @@ static char *usb_dump_endpoint_descripto case USB_ENDPOINT_XFER_INT: type = "Int."; break; - default: /* "can't happen" */ - return start; } interval = usb_decode_interval(desc, speed);
The *switch* statement in usb_dump_endpoint_descriptor() does handle all possible endpoint types expilicitly, so the *default* label is unreachable... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> --- This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo. Changes in version 2: - fixed typos in the patch description; - reformatted the patch description. drivers/usb/core/devices.c | 2 -- 1 file changed, 2 deletions(-)