Re: [PATCH 1/3] usb: dwc2: gadget: fix below build warning

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

 



On Monday, August 18, 2014 5:32 PM, Peter Chen wrote:
> 
> linux-2.6/drivers/usb/dwc2/gadget.c: In function 's3c_hsotg_irq_enumdone':
> linux-2.6/drivers/usb/dwc2/gadget.c:1904: warning: 'ep_mps' may be used uninitialized in this function

(+cc  Dinh Nguyen)

I think that this warning is false.
Because, 'ep_mps' cannot be used uninitialized in s3c_hsotg_irq_enumdone().

static void s3c_hsotg_irq_enumdone(struct s3c_hsotg *hsotg)
{
	int ep0_mps = 0, ep_mps;

	case DSTS_ENUMSPD_FS:
	case DSTS_ENUMSPD_FS48:
		ep0_mps = EP0_MPS_LIMIT;
		ep_mps = 1023;
		break;

	case DSTS_ENUMSPD_HS:
		ep0_mps = EP0_MPS_LIMIT;
		ep_mps = 1024;
		break;

In the case of DSTS_ENUMSPD_FS, DSTS_ENUMSPD_FS48, and DSTS_ENUMSPD_HS,
both 'ep0_mps' and 'ep_mps' are initialized.

	case DSTS_ENUMSPD_LS:
		hsotg->gadget.speed = USB_SPEED_LOW;
		break;

In the case of DSTS_ENUMSPD_LS, 'ep_mps' is uninitialized.
But, 'ep0_mps' is also '0'.

	.....

	if (ep0_mps) {
		int i;
		s3c_hsotg_set_ep_maxpacket(hsotg, 0, ep0_mps);
		for (i = 1; i < hsotg->num_of_eps; i++)
		s3c_hsotg_set_ep_maxpacket(hsotg, i, ep_mps);
	}

If 'ep0_mps' is '0', 'ep_mps' will not be used.
So, uninitialized 'ep_mps' cannot be used.

However, in the future, it is not sure that the current scheme
will not be modified. Thus, in order to make sure the code safety,
this patch may be necessary.

Best regards,
Jingoo Han

> 
> Signed-off-by: Peter Chen <peter.chen@xxxxxxxxxxxxx>
> ---
>  drivers/usb/dwc2/gadget.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 2421eaa..832cab7 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -1901,7 +1901,7 @@ static void s3c_hsotg_epint(struct s3c_hsotg *hsotg, unsigned int idx,
>  static void s3c_hsotg_irq_enumdone(struct s3c_hsotg *hsotg)
>  {
>  	u32 dsts = readl(hsotg->regs + DSTS);
> -	int ep0_mps = 0, ep_mps;
> +	int ep0_mps = 0, ep_mps = 1024;
> 
>  	/*
>  	 * This should signal the finish of the enumeration phase
> --
> 1.7.9.5


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux