From: Sam Ravnborg <sam@ravnborg.org>
To: josh@joshtriplett.org
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Hartley Sweeten <HartleyS@visionengravers.com>,
"Marcos A. Di Pietro" <marcosadp@gmail.com>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
linux-sparse@vger.kernel.org
Subject: Re: [PATCH] Staging/comedi: Fixes static analysis warning raised by sparse
Date: Sun, 15 Jun 2014 21:32:27 +0200 [thread overview]
Message-ID: <20140615193227.GA24515@ravnborg.org> (raw)
In-Reply-To: <20140611214529.GB16940@cloud>
Hi Josh.
On Wed, Jun 11, 2014 at 02:45:29PM -0700, josh@joshtriplett.org wrote:
> On Thu, Jun 12, 2014 at 12:24:25AM +0300, Dan Carpenter wrote:
> > Let's forward this to the Sparse mailing list.
> >
> > We're seeing a Sparse false positive testing
> > drivers/staging/comedi/drivers/ni_pcimio.c.
> >
> > CHECK drivers/staging/comedi/drivers/ni_pcimio.c
> > drivers/staging/comedi/drivers/ni_stc.h:720:26: warning: shift too big (4294967295) for type int
> > drivers/staging/comedi/drivers/ni_stc.h:720:26: warning: shift too big (4294967295) for type int
> > drivers/staging/comedi/drivers/ni_stc.h:720:26: warning: shift too big (4294967295) for type int
> > drivers/staging/comedi/drivers/ni_stc.h:720:26: warning: shift too big (4294967295) for type int
> >
> > I have created some test code to demonstrate the problem (attached).
> >
> > The check_shift_count() warning is only supposed to be printed for
> > number literals but because of the way inline functions are expanded it
> > still complains even though channel is a variable.
>
> Thanks for the test case; this definitely makes no sense. I don't think
> Sparse will suddenly develop enough range analysis or reachability
> analysis to handle this case; I think the right answer is to avoid
> giving such warnings for shifts with a non-constant RHS.
Something like the appended?
It seems to work for me - and it cured a lot of warnings in math-emu.c on sparc.
If it looks OK I will do a proper patch submission.
Sam
diff --git a/expand.c b/expand.c
index 0f6720c..4a96de4 100644
--- a/expand.c
+++ b/expand.c
@@ -187,7 +187,7 @@ static int simplify_int_binop(struct expression *expr, struct symbol *ctype)
return 0;
r = right->value;
if (expr->op == SPECIAL_LEFTSHIFT || expr->op == SPECIAL_RIGHTSHIFT) {
- if (r >= ctype->bit_size) {
+ if (expr->flags & Int_const_expr && r >= ctype->bit_size) {
if (conservative)
return 0;
r = check_shift_count(expr, ctype, r);
next prev parent reply other threads:[~2014-06-15 19:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <53965E53.5080504@gmail.com>
[not found] ` <20140610054741.GE5500@mwanda>
[not found] ` <DC148C5AA1CEBA4E87973D432B1C2D8825E9AE6A@P3PWEX4MB008.ex4.secureserver.net>
[not found] ` <20140611065612.GQ5015@mwanda>
[not found] ` <DC148C5AA1CEBA4E87973D432B1C2D8825E9CBD6@P3PWEX4MB008.ex4.secureserver.net>
2014-06-11 21:24 ` [PATCH] Staging/comedi: Fixes static analysis warning raised by sparse Dan Carpenter
2014-06-11 21:45 ` josh
2014-06-15 19:32 ` Sam Ravnborg [this message]
2014-06-16 7:40 ` Dan Carpenter
2014-06-16 8:06 ` Sam Ravnborg
2014-06-28 18:07 ` Christopher Li
2014-06-28 19:20 ` Josh Triplett
2014-06-29 3:09 ` Christopher Li
2014-06-30 17:49 ` Christopher Li
2014-06-30 18:32 ` Christopher Li
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=20140615193227.GA24515@ravnborg.org \
--to=sam@ravnborg.org \
--cc=HartleyS@visionengravers.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=josh@joshtriplett.org \
--cc=linux-sparse@vger.kernel.org \
--cc=marcosadp@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.