From: Joe Perches <joe@perches.com>
To: Benoit Parrot <bparrot@ti.com>,
"Daniel W. S. Almeida" <dwlsalmeida@gmail.com>
Cc: skhan@linuxfoundation.org,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 19/20] media: platform: vpdma.c: fix comparison to bool
Date: Tue, 11 Aug 2020 11:34:09 -0700 [thread overview]
Message-ID: <5dd3d10088dbc8a126bc788237f5206130a090ae.camel@perches.com> (raw)
In-Reply-To: <20200811125748.s3pdpwjmqmd5bffb@ti.com>
On Tue, 2020-08-11 at 07:57 -0500, Benoit Parrot wrote:
> Daniel W. S. Almeida <dwlsalmeida@gmail.com> wrote on Fri [2020-Aug-07 05:35:46 -0300]:
> > From: "Daniel W. S. Almeida" <dwlsalmeida@gmail.com>
> >
> > 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);
prev parent reply other threads:[~2020-08-11 18:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-07 8:35 Daniel W. S. Almeida
2020-08-11 12:57 ` Benoit Parrot
2020-08-11 18:34 ` Joe Perches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5dd3d10088dbc8a126bc788237f5206130a090ae.camel@perches.com \
--to=joe@perches.com \
--cc=bparrot@ti.com \
--cc=dwlsalmeida@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®