Re: [PATCH 3/3] usb: wusbcore: fix below build warning

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

 




On Mon, 18 Aug 2014, Peter Chen wrote:

> linux-2.6/drivers/usb/wusbcore/wa-xfer.c: In function 'wa_buf_in_cb':
> linux-2.6/drivers/usb/wusbcore/wa-xfer.c:2590: warning: 'rpipe' may be used uninitialized in this function
> 
> Signed-off-by: Peter Chen <peter.chen@xxxxxxxxxxxxx>
> ---
>  drivers/usb/wusbcore/wa-xfer.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
> index 3e2e4ed..11c2ec0 100644
> --- a/drivers/usb/wusbcore/wa-xfer.c
> +++ b/drivers/usb/wusbcore/wa-xfer.c
> @@ -2587,7 +2587,7 @@ static void wa_buf_in_cb(struct urb *urb)
>  	struct wa_xfer *xfer = seg->xfer;
>  	struct wahc *wa;
>  	struct device *dev;
> -	struct wa_rpipe *rpipe;
> +	struct wa_rpipe *rpipe = NULL;
>  	unsigned rpipe_ready = 0, isoc_data_frame_count = 0;
>  	unsigned long flags;
>  	int resubmit_dti = 0, active_buf_in_urbs;
> @@ -2671,7 +2671,7 @@ static void wa_buf_in_cb(struct urb *urb)
>  		spin_unlock_irqrestore(&xfer->lock, flags);
>  		if (done)
>  			wa_xfer_completion(xfer);
> -		if (rpipe_ready)
> +		if (rpipe_ready && rpipe)
>  			wa_xfer_delayed_run(rpipe);
>  		break;
>  	case -ECONNRESET:	/* URB unlinked; no need to do anything */
> -- 
> 1.7.9.5
> 
> 

Hi Peter, 
This change isn't strictly necessary because rpipe_ready is initialized to 
0 and rpipe is guaranteed to be initialized if rpipe_ready is true.  That 
being said, if you want to clean up the warning, you could just move the 
rpipe initialization up so that it will always be initialized in the 
context of the rpipe_ready test like this:

diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
index 3e2e4ed..c4fb9e1 100644
--- a/drivers/usb/wusbcore/wa-xfer.c
+++ b/drivers/usb/wusbcore/wa-xfer.c
@@ -2633,6 +2633,7 @@ static void wa_buf_in_cb(struct urb *urb)
 		spin_lock_irqsave(&xfer->lock, flags);
 
 		seg->result += urb->actual_length;
+		rpipe = xfer->ep->hcpriv;
 		if (isoc_data_frame_count > 0) {
 			int result, urb_frame_count;
 
@@ -2659,7 +2660,6 @@ static void wa_buf_in_cb(struct urb *urb)
 			  resubmit_dti = (isoc_data_frame_count ==
 							urb_frame_count);
 		} else if (active_buf_in_urbs == 0) {
-			rpipe = xfer->ep->hcpriv;
 			dev_dbg(dev,
 				"xfer %p 0x%08X#%u: data in done (%zu bytes)\n",
 				xfer, wa_xfer_id(xfer), seg->index,

---

That way, the variable is only initialized once.

Tom
--
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