Re: [PATCH 19/20] media: platform: vpdma.c: fix comparison to bool

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

 



On Tue, 2020-08-11 at 07:57 -0500, Benoit Parrot wrote:
> Daniel W. S. Almeida <dwlsalmeida@xxxxxxxxx> wrote on Fri [2020-Aug-07 05:35:46 -0300]:
> > From: "Daniel W. S. Almeida" <dwlsalmeida@xxxxxxxxx>
> > 
> > Fix the following coccinelle report:
> > 
> > drivers/media/platform/ti-vpe/vpdma.c:946:5-26: WARNING:
> > Comparison to bool
> > 
> > Found using - Coccinelle (http://coccinelle.lip6.fr)
[]
> > diff --git a/drivers/media/platform/ti-vpe/vpdma.c b/drivers/media/platform/ti-vpe/vpdma.c
[]
> > @@ -943,7 +943,7 @@ int vpdma_hwlist_alloc(struct vpdma_data *vpdma, void *priv)
> >  
> >  	spin_lock_irqsave(&vpdma->lock, flags);
> >  	for (i = 0; i < VPDMA_MAX_NUM_LIST &&
> > -	    vpdma->hwlist_used[i] == true; i++)
> > +	    vpdma->hwlist_used[i]; i++)
> >  		;


A more typical way to write this loop is
not testing i < VPDMA_MAX_NUM_LIST multiple
times like the below:
---
 drivers/media/platform/ti-vpe/vpdma.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/ti-vpe/vpdma.c b/drivers/media/platform/ti-vpe/vpdma.c
index 2e5148ae7a0f..5893917ce50d 100644
--- a/drivers/media/platform/ti-vpe/vpdma.c
+++ b/drivers/media/platform/ti-vpe/vpdma.c
@@ -942,14 +942,13 @@ int vpdma_hwlist_alloc(struct vpdma_data *vpdma, void *priv)
 	unsigned long flags;
 
 	spin_lock_irqsave(&vpdma->lock, flags);
-	for (i = 0; i < VPDMA_MAX_NUM_LIST &&
-	    vpdma->hwlist_used[i] == true; i++)
-		;
-
-	if (i < VPDMA_MAX_NUM_LIST) {
+	for (i = 0; i < VPDMA_MAX_NUM_LIST; i++) {
+		if (vpdma->hwlist_used[i])
+			continue;
 		list_num = i;
 		vpdma->hwlist_used[i] = true;
 		vpdma->hwlist_priv[i] = priv;
+		break;
 	}
 	spin_unlock_irqrestore(&vpdma->lock, flags);
 





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux