From: Dan Carpenter <dan.carpenter@oracle.com>
To: Manu Abraham <abraham.manu@gmail.com>
Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>,
Hans Verkuil <hans.verkuil@cisco.com>,
Alexey Khoroshilov <khoroshilov@ispras.ru>,
Linux Media Mailing List <linux-media@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [patch] [media] stv090x: remove indent levels
Date: Wed, 19 Feb 2014 07:44:56 +0000 [thread overview]
Message-ID: <20140219074455.GQ26722@mwanda> (raw)
In-Reply-To: <CAHFNz9LUP4UVROk5RWW_-=LQ5=gC8__zD67aLxNq7bHUMgipCQ@mail.gmail.com>
On Wed, Feb 19, 2014 at 10:52:32AM +0530, Manu Abraham wrote:
> On Tue, Feb 18, 2014 at 2:26 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > On Tue, Feb 18, 2014 at 09:25:36AM +0530, Manu Abraham wrote:
> >> Hi Dan,
> >>
> >> On Thu, Feb 6, 2014 at 2:58 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >> > 1) We can flip the "if (!lock)" check to "if (lock) return lock;" and
> >> > then remove a big chunk of indenting.
> >> > 2) There is a redundant "if (!lock)" which we can remove since we
> >> > already know that lock is zero. This removes another indent level.
> >>
> >>
> >> The stv090x driver is a mature, but slightly complex driver supporting
> >> quite some
> >> different configurations. Is it that some bug you are trying to fix in there ?
> >> I wouldn't prefer unnecessary code churn in such a driver for
> >> something as simple
> >> as gain in an indentation level.
> >
> > I thought the cleanup was jusitification enough, but the real reason I
> > wrote this patch is that testing:
> >
> > if (!lock) {
> > if (!lock) {
> >
> > sets off a static checker warning. That kind of code is puzzling and if
> > we don't clean it up then it wastes a lot of reviewer time.
> >
> > Also when you're reviewing these patches please consider that the
> > original code might be buggy and not simply messy. Perhaps something
> > other than "if (!lock) {" was intended?
> >
>
> I can't seem to find the possible bug in there..
>
> The code:
>
> lock = fn();
> if (!lock) {
> if (condition1) {
> lock = fn()
> } else {
> if (!lock) {
> }
> }
> }
>
> looks harmless to me, AFAICS.
Yes. I thought so too. It's just a messy, but not broken. Let's just
fix the static checker warning so that we don't have to keep reviewing
it every several months.
> Also, please do note that, if the
> function coldlock exits due to some reason for not finding valid symbols,
> stv090x_search is again fired up from the kernel frontend thread.
This sentence really scares me. Are you trying to say that the second
check on lock is valid for certain use cases? That is not possibly
true because it is a stack variable so (ignoring memory corruption)
it can't be modified from outside the code.
Hm...
The code actually looks like this:
lock = fn();
if (!lock) {
if (condition1) {
lock = fn()
} else {
if (!lock) {
while ((cur_step <= steps) && (!lock)) {
lock = stv090x_get_dmdlock(state, (timeout_dmd / 3));
}
}
}
}
Are you sure it's not buggy? Maybe the if statement should be moved
inside the while () condition?
> It is easy to make such cleanup patches and cause breakages, but a
> lot time consuming to fix such issues. My 2c.
Greg K-H and I review more of these cleanup patches than any other
kernel maintainers so I'm aware of the challenges. If you want to write
a smaller patch to fix the static checker warning then I will review it
for you. If you do that then please give me a:
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
regards,
dan carpenter
next prev parent reply other threads:[~2014-02-19 7:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-06 9:28 [patch] [media] stv090x: remove indent levels Dan Carpenter
2014-02-18 3:55 ` Manu Abraham
2014-02-18 8:56 ` Dan Carpenter
2014-02-19 5:34 ` Manu Abraham
2014-02-19 7:44 ` Dan Carpenter [this message]
2014-02-20 3:39 ` Manu Abraham
2014-02-20 9:25 ` Dan Carpenter
2014-02-20 12:57 ` Manu Abraham
2014-02-20 10:24 ` Hans Verkuil
2014-02-20 12:35 ` Dan Carpenter
2014-02-21 8:50 ` [patch v2] [media] stv090x: remove indent levels in stv090x_get_coldlock() Dan Carpenter
2014-02-21 11:45 ` walter harms
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=20140219074455.GQ26722@mwanda \
--to=dan.carpenter@oracle.com \
--cc=abraham.manu@gmail.com \
--cc=hans.verkuil@cisco.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=khoroshilov@ispras.ru \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
/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;
as well as URLs for NNTP newsgroup(s).