Re: [PATCH v2] usb: core: devices: drop unreachable code in usb_dump_endpoint_descriptor()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
> 
> ---
> 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 of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux