From: Dan Carpenter <dan.carpenter@oracle.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
kernel-janitors@vger.kernel.org,
Gilles Muller <Gilles.Muller@lip6.fr>,
Nicolas Palix <nicolas.palix@imag.fr>,
Michal Marek <michal.lkml@markovi.net>,
cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scripts/coccinelle/misc/shift.cocci: detect < or > that should be a shift
Date: Thu, 8 Feb 2018 17:04:35 +0300 [thread overview]
Message-ID: <20180208140435.drxepn4badqj76sr@mwanda> (raw)
In-Reply-To: <alpine.DEB.2.20.1802081457350.13345@hadrien>
On Thu, Feb 08, 2018 at 02:58:56PM +0100, Julia Lawall wrote:
>
>
> On Thu, 8 Feb 2018, Dan Carpenter wrote:
>
> > On Thu, Feb 08, 2018 at 01:53:54PM +0100, Julia Lawall wrote:
> > > This checks for a comparison using < or > between two constants,
> > > considering both explicit constants (1, 2, etc) and macros defined
> > > with #define. False positives are possible in the latter case, when
> > > a macro may have multiple possible definitions and it is indeed
> > > necessary to check the value. There are currently two such false
> > > positives, in drivers/net/ethernet/chelsio/cxgb3/sge.c:
> > >
> > > q->fl[0].use_pages = FL0_PG_CHUNK_SIZE > 0;
> > > q->fl[1].use_pages = FL1_PG_CHUNK_SIZE > 0;
> > >
> >
> > We could eliminate both these false postives by ignoring >> vs >. Did
> > searching for > actually find any bugs? I think you were right that
> > right shifting a constant is way less common than left shifting and I
> > have some smatch scripts where I ignore right shifting bugs.
> >
> > On the other hand, two false positives are not a big deal.
>
> I found no bugs with > at the moment. I figured that the person could
> have just as easily written 0 < FL0_PG_CHUNK_SIZE, so it was not worth
^^^^^^^^^^^^^^^^^^^^^
That's a Yoda speak type condition though so it's less common.
Unrelated, but I fixed a Yoda condition today where the test was
reversed so I feel like Yoda conditions are more likely to be buggy
(because they are hard to read).
regards,
dan carpenter
next prev parent reply other threads:[~2018-02-08 14:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-08 12:53 Julia Lawall
2018-02-08 13:53 ` Dan Carpenter
2018-02-08 13:58 ` Julia Lawall
2018-02-08 14:04 ` Dan Carpenter [this message]
2018-02-09 14:10 ` scripts/coccinelle/misc/shift.cocci: Refactoring? SF Markus Elfring
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=20180208140435.drxepn4badqj76sr@mwanda \
--to=dan.carpenter@oracle.com \
--cc=Gilles.Muller@lip6.fr \
--cc=cocci@systeme.lip6.fr \
--cc=julia.lawall@lip6.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.lkml@markovi.net \
--cc=nicolas.palix@imag.fr \
--cc=wsa+renesas@sang-engineering.com \
--cc=yamada.masahiro@socionext.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
all inboxes | Powered by JetHome®